Skip to content

Commit

Permalink
Update for latest versions of dependencies
Browse files Browse the repository at this point in the history
Egoboo was updated for the latest version of Idlib and Idlib: Game Engine.
  • Loading branch information
michaelheilmann committed Jan 17, 2018
1 parent 2e4884c commit c9d7199
Show file tree
Hide file tree
Showing 111 changed files with 5,288 additions and 6,056 deletions.
2 changes: 2 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
[submodule "idlib"]
path = idlib
url = https://github.com/primordialmachine/idlib
branch = develop
[submodule "idlib-game-engine"]
path = idlib-game-engine
url = https://github.com/egoboo/idlib-game-engine.git
branch = develop
4 changes: 2 additions & 2 deletions cartman/src/cartman/cartman.c
Original file line number Diff line number Diff line change
Expand Up @@ -1911,7 +1911,7 @@ void cartman_save_mesh( const char * modname, cartman_mpd_t * pmesh )
make_planmap( pmesh );
if (Resources::get().bmphitemap )
{
SDL_SaveBMP_RW(Resources::get().bmphitemap.get(), vfs_openRWopsWrite(newloadname.c_str()), 1 );
Ego::ImageManager::get().save_as_bmp(Resources::get().bmphitemap, newloadname);
}

// make_newloadname(modname, SLASH_STR "gamedat" SLASH_STR "level.png", newloadname);
Expand All @@ -1924,7 +1924,7 @@ void cartman_save_mesh( const char * modname, cartman_mpd_t * pmesh )

cartman_mpd_save_vfs( /*modname,*/ pmesh );

show_name( newloadname, WHITE );
show_name( newloadname, Ego::Math::Colour4f::white() );
}

//--------------------------------------------------------------------------------------------
Expand Down
65 changes: 18 additions & 47 deletions cartman/src/cartman/cartman_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@
#include "cartman/cartman_select.h"
#include "cartman/cartman_math.h"
#include "egolib/FileFormats/Globals.hpp"
#include "egolib/Image/ImageManager.hpp"
#include "egolib/Image/SDL_Image_Extensions.h"
#include "egolib/Graphics/GraphicsSystem.hpp"
#include "cartman/Clocks.h"

//--------------------------------------------------------------------------------------------

const Ego::Math::Colour4f WHITE = Ego::Math::Colour4f::white();
const Ego::Math::Colour4f BLACK = Ego::Math::Colour4f::black();

std::shared_ptr<Ego::Font> gfx_font_ptr = NULL;

//--------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -203,7 +201,7 @@ void make_hitemap( cartman_mpd_t * pmesh )
{
if ( NULL == pmesh ) pmesh = &mesh;

Resources::get().bmphitemap = Ego::SDL::createSurface( pmesh->info.getTileCountX() << 2, pmesh->info.getTileCountY() << 2 );
Resources::get().bmphitemap = Ego::ImageManager::get().createImage( pmesh->info.getTileCountX() << 2, pmesh->info.getTileCountY() << 2 );
if ( NULL == Resources::get().bmphitemap ) return;

for (int pixy = 0, y = 16; pixy < ( pmesh->info.getTileCountY() << 2 ); pixy++, y += 32 )
Expand All @@ -220,7 +218,7 @@ void make_hitemap( cartman_mpd_t * pmesh )
if ( HAS_BITS( pfan->fx, MAPFX_IMPASS ) ) level = 254; // Impass
if ( HAS_BITS( pfan->fx, MAPFX_WALL ) && HAS_BITS( pfan->fx, MAPFX_IMPASS ) ) level = 255; // Both

Ego::SDL::putPixel(Resources::get().bmphitemap, pixx, pixy, level );
Ego::set_pixel(Resources::get().bmphitemap.get(), Ego::Math::Colour3b((uint8_t)level, (uint8_t)level, (uint8_t)level), { pixx, pixy });
}
}
}
Expand All @@ -230,16 +228,12 @@ void make_hitemap( cartman_mpd_t * pmesh )
void make_planmap( cartman_mpd_t * pmesh )
{
int x, y, putx, puty;
//SDL_Surface* bmptemp;

//bmptemp = SDL_GL_createSurface(64, 64);
//if(NULL != bmptemp) return;

if ( NULL == pmesh ) pmesh = &mesh;

Resources::get().bmphitemap = Ego::SDL::createSurface( pmesh->info.getTileCountX() * TINYXY, pmesh->info.getTileCountY() * TINYXY );
Resources::get().bmphitemap = Ego::ImageManager::get().createImage( pmesh->info.getTileCountX() * TINYXY, pmesh->info.getTileCountY() * TINYXY );

SDL_FillRect( Resources::get().bmphitemap.get(), NULL, make_rgb(Resources::get().bmphitemap, Ego::Math::Colour3b::black()) );
Ego::fill( Resources::get().bmphitemap.get(), Ego::Math::Colour3b::black());

puty = 0;
for ( y = 0; y < pmesh->info.getTileCountY(); y++ )
Expand All @@ -252,8 +246,7 @@ void make_planmap( cartman_mpd_t * pmesh )

if ( NULL != tx_tile )
{
SDL_Rect dst = {static_cast<int16_t>(putx), static_cast<int16_t>(puty), TINYXY, TINYXY};
cartman_BlitSurface(tx_tile->m_source.get(), nullptr, Resources::get().bmphitemap.get(), &dst);
Ego::blit(tx_tile->m_source.get(), Resources::get().bmphitemap.get(), Point2f(static_cast<int16_t>(putx), static_cast<int16_t>(puty)));
}
putx += TINYXY;
}
Expand Down Expand Up @@ -892,7 +885,7 @@ void ogl_beginFrame()
glEnable( GL_TEXTURE_2D );

renderer.setBlendingEnabled(true);
renderer.setBlendFunction(id::blend_function::source_alpha, id::blend_function::one_minus_source_alpha);
renderer.setBlendFunction(id::color_blend_parameter::source0_alpha, id::color_blend_parameter::one_minus_source0_alpha);

auto drawableSize = Ego::GraphicsSystem::get().window->getDrawableSize();
renderer.setViewportRectangle(0, 0, drawableSize.x(), drawableSize.y());
Expand All @@ -914,27 +907,6 @@ void ogl_endFrame()
glPopAttrib();
}

//--------------------------------------------------------------------------------------------
void draw_sprite( SDL_Surface * dst, SDL_Surface * sprite, int x, int y )
{
SDL_Rect rdst;

if ( NULL == dst || NULL == sprite ) return;

rdst.x = x;
rdst.y = y;
rdst.w = sprite->w;
rdst.h = sprite->h;

cartman_BlitSurface( sprite, NULL, dst, &rdst );
}

//--------------------------------------------------------------------------------------------
int cartman_BlitSurface( SDL_Surface *src, ::SDL_Rect *srcrect, SDL_Surface *dst, ::SDL_Rect *dstrect )
{
return SDL_BlitSurface( src, srcrect, dst, dstrect );
}

//--------------------------------------------------------------------------------------------
SDL_Surface *cartman_LoadIMG(const std::string& name)
{
Expand Down Expand Up @@ -1079,55 +1051,55 @@ void load_img()
}

fileName = "editor/ref.png";
Resources::get().tx_ref = Ego::Renderer::get().createTexture();;
Resources::get().tx_ref = Ego::Renderer::get().createTexture();
if (!Resources::get().tx_ref->load(fileName, gfx_loadImage(fileName)))
{
Log::get() << Log::Entry::create(Log::Level::Warning, __FILE__, __LINE__, "unable to load image ",
"`", fileName, "`", Log::EndOfEntry );
}

fileName = "editor/drawref.png";
Resources::get().tx_drawref = Ego::Renderer::get().createTexture();;
Resources::get().tx_drawref = Ego::Renderer::get().createTexture();
if (!Resources::get().tx_drawref->load(fileName, gfx_loadImage(fileName)))
{
Log::get() << Log::Entry::create(Log::Level::Warning, __FILE__, __LINE__, "unable to load image ",
"`", fileName, "`", Log::EndOfEntry );
}

fileName = "editor/anim.png";
Resources::get().tx_anim = Ego::Renderer::get().createTexture();;
Resources::get().tx_anim = Ego::Renderer::get().createTexture();
if (!Resources::get().tx_anim->load(fileName, gfx_loadImage(fileName)))
{
Log::get() << Log::Entry::create(Log::Level::Warning, __FILE__, __LINE__, "unable to load image ",
"`", fileName, "`", Log::EndOfEntry);
}

fileName = "editor/water.png";
Resources::get().tx_water = Ego::Renderer::get().createTexture();;
Resources::get().tx_water = Ego::Renderer::get().createTexture();
if (!Resources::get().tx_water->load(fileName, gfx_loadImage(fileName)))
{
Log::get() << Log::Entry::create(Log::Level::Warning, __FILE__, __LINE__, "unable to load image ",
"`", fileName, "`", Log::EndOfEntry);
}

fileName = "editor/slit.png";
Resources::get().tx_wall = Ego::Renderer::get().createTexture();;
Resources::get().tx_wall = Ego::Renderer::get().createTexture();
if (!Resources::get().tx_wall->load(fileName, gfx_loadImage(fileName)))
{
Log::get() << Log::Entry::create(Log::Level::Warning, __FILE__, __LINE__, "unable to load image ",
"`", fileName, "`", Log::EndOfEntry);
}

fileName = "editor/impass.png";
Resources::get().tx_impass = Ego::Renderer::get().createTexture();;
Resources::get().tx_impass = Ego::Renderer::get().createTexture();
if (!Resources::get().tx_impass->load(fileName, gfx_loadImage(fileName)))
{
Log::get() << Log::Entry::create(Log::Level::Warning, __FILE__, __LINE__, "unable to load image ",
"`", fileName, "`", Log::EndOfEntry);
}

fileName = "editor/damage.png";
Resources::get().tx_damage = Ego::Renderer::get().createTexture();;
Resources::get().tx_damage = Ego::Renderer::get().createTexture();
if (!Resources::get().tx_damage->load(fileName, gfx_loadImage(fileName)))
{
Log::get() << Log::Entry::create(Log::Level::Warning, __FILE__, __LINE__, "unable to load image ",
Expand Down Expand Up @@ -1165,12 +1137,12 @@ void get_small_tiles( SDL_Surface* bmpload )

Resources::get().tx_smalltile[numsmalltile] = Ego::Renderer::get().createTexture();

image = Ego::SDL::createSurface( SMALLXY, SMALLXY );
image = Ego::ImageManager::get().createImage( SMALLXY, SMALLXY );
if (!image)
{
throw std::runtime_error("unable to create surface");
}
SDL_FillRect( image.get(), NULL, make_rgb( image, Ego::Math::Colour3b::black() ) );
Ego::fill(image.get(), Ego::Math::Colour3b::black());
SDL_SoftStretch( bmpload, &src1, image.get(), NULL );

Resources::get().tx_smalltile[numsmalltile]->load(image);
Expand Down Expand Up @@ -1215,13 +1187,12 @@ void get_big_tiles( SDL_Surface* bmpload )

Resources::get().tx_bigtile[numbigtile] = Ego::Renderer::get().createTexture();

image = Ego::SDL::createSurface( SMALLXY, SMALLXY );
image = Ego::ImageManager::get().createImage( SMALLXY, SMALLXY );
if (!image)
{
throw std::runtime_error("unable to create surface");
}
SDL_FillRect( image.get(), NULL, make_rgb( image, Ego::Math::Colour3b::black() ) );

Ego::fill(image.get(), Ego::Math::Colour3b::black());
SDL_SoftStretch( bmpload, &src1, image.get(), NULL );

Resources::get().tx_bigtile[numbigtile]->load(image);
Expand Down
27 changes: 0 additions & 27 deletions cartman/src/cartman/cartman_gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,6 @@ inline Ego::Math::Colour4f make_rgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
return (Ego::Math::Colour4f)Ego::Math::Colour4b(r, g, b, a);
}

inline uint32_t make_rgb(const std::shared_ptr<const SDL_Surface>& surface, const Ego::Math::Colour3b& colour) {
return SDL_MapRGB(surface->format, colour.get_r(), colour.get_g(), colour.get_b());
}

inline uint32_t make_rgba(const std::shared_ptr<const SDL_Surface>& surface, const Ego::Math::Colour4b& colour) {
return SDL_MapRGBA(surface->format, colour.get_r(), colour.get_g(), colour.get_b(), colour.get_a());
}

#define POINT_SIZE(X) ( (X) * 0.5f + 4.0f )
#define MAXPOINTSIZE 16.0f

Expand Down Expand Up @@ -113,9 +105,6 @@ extern uint16_t damagetilemindistance;
extern int damagetileamount; // Amount of damage
extern uint8_t damagetiletype; // Type of damage

extern const Ego::Math::Colour4f WHITE;
extern const Ego::Math::Colour4f BLACK;

extern std::shared_ptr<Ego::Font> gfx_font_ptr;

//--------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -146,8 +135,6 @@ void ogl_endFrame();

// SDL routines
void draw_sprite( SDL_Surface * dst, SDL_Surface * sprite, int x, int y );
int cartman_BlitScreen( SDL_Surface * bmp, SDL_Rect * prect );
int cartman_BlitSurface( SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect );
SDL_Surface * cartman_LoadIMG( const std::string& szName );

// camera stuff
Expand All @@ -164,20 +151,6 @@ void get_tiles(SDL_Surface* bmpload);
std::shared_ptr<Ego::Texture> tiny_tile_at( cartman_mpd_t * pmesh, Index2D index2d );
std::shared_ptr<Ego::Texture> tile_at( cartman_mpd_t * pmesh, int fan );

/**
* @todo
* This is by-passing the image loader, remove.
*/
inline std::shared_ptr<SDL_Surface> gfx_loadImage(const std::string& pathname)
{
SDL_Surface *image = IMG_Load_RW(vfs_openRWopsRead(pathname.c_str()), 1);
if (!image)
{
return nullptr;
}
return std::shared_ptr<SDL_Surface>(image, [ ](SDL_Surface *surface) { SDL_FreeSurface(surface); });
}

// initialization
struct GFX : Ego::App<GFX>
{
Expand Down
24 changes: 10 additions & 14 deletions cartman/src/cartman/cartman_gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "cartman/cartman_input.h"
#include "cartman/cartman_math.h"
#include "cartman/cartman_gfx.h"
#include "egolib/Image/ImageManager.hpp"
#include "egolib/Image/SDL_Image_Extensions.h"

//--------------------------------------------------------------------------------------------
Expand All @@ -32,23 +33,18 @@ ui_state_t ui;
namespace Cartman { namespace Gui {

Cursor::Cursor() :
_surface(Ego::SDL::createSurface(8, 8)) {
uint32_t col = make_rgb(_surface, Ego::Math::Colour3b::white()); // opaque (255) white (255,255,255)
uint32_t loc = make_rgb(_surface, Ego::Math::Colour3b(24, 24, 24)); // opaque (255) black-grey (24,24,24)
uint32_t clr = make_rgba(_surface, Ego::Math::Colour4b(0, 0, 0, 64)); // almost transparent (64) black (0,0,0)

// Simple triangle
SDL_Rect rtmp;
rtmp.x = 0;
rtmp.y = 0;
rtmp.w = 8;
rtmp.h = 1;
SDL_FillRect(_surface.get(), &rtmp, loc);
_surface(Ego::ImageManager::get().createImage(8, 8)) {
auto col = Ego::Math::Colour3b::white(); // opaque (255) white (255, 255, 255)
auto loc = Ego::Math::Colour3b(24, 24, 24); // opaque (255) black-grey (24, 24, 24)
auto clr = Ego::Math::Colour4b(Ego::Math::Colour3b::black(), 64); // almost transparent (64) black (0, 0, 0)

auto rtmp = Rectangle2f(Point2f(0, 0), Point2f(8, 1));
Ego::fill(_surface.get(), Ego::Math::Colour3b(24, 24, 24), rtmp);

for (int y = 0; y < 8; y++) {
for (int x = 0; x < 8; x++) {
if (x + y < 8) Ego::SDL::putPixel(_surface, x, y, col);
else Ego::SDL::putPixel(_surface, x, y, clr);
if (x + y < 8) Ego::set_pixel(_surface.get(), col, { x, y });
else Ego::set_pixel(_surface.get(), clr, { x, y });
}
}
}
Expand Down
Loading

0 comments on commit c9d7199

Please sign in to comment.