Skip to content

Commit

Permalink
Remove references to renderer back-end from high-level code
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelheilmann committed Dec 9, 2015
1 parent 1a706a2 commit f07b364
Show file tree
Hide file tree
Showing 39 changed files with 133 additions and 135 deletions.
4 changes: 2 additions & 2 deletions cartman/src/cartman/cartman.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ void Views::render_tile_window(std::shared_ptr<Cartman_Window> pwin, float zoom_

int fan = pwin->pmesh->get_ifan(mapx, mapy);

Ego::OpenGL::Texture * tx_tile = NULL;
Ego::Texture * tx_tile = NULL;
if ( VALID_MPD_TILE_RANGE( fan ) )
{
tx_tile = tile_at( pwin->pmesh, fan );
Expand Down Expand Up @@ -511,7 +511,7 @@ void Views::render_fx_window(std::shared_ptr<Cartman_Window> pwin, float zoom_hr

int fan = pwin->pmesh->get_ifan(mapx, mapy);

Ego::OpenGL::Texture *tx_tile = NULL;
Ego::Texture *tx_tile = NULL;
if ( VALID_MPD_TILE_RANGE( fan ) )
{
tx_tile = tile_at( pwin->pmesh, fan );
Expand Down
46 changes: 23 additions & 23 deletions cartman/src/cartman/cartman_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,21 @@ oglx_video_parameters_t ogl_vparam;

SDL_Surface * bmphitemap = NULL; // Heightmap image

Ego::OpenGL::Texture *tx_point; // Vertex image
Ego::OpenGL::Texture *tx_pointon; // Vertex image ( select_vertsed )
Ego::OpenGL::Texture *tx_ref; // Meshfx images
Ego::OpenGL::Texture *tx_drawref; //
Ego::OpenGL::Texture *tx_anim; //
Ego::OpenGL::Texture *tx_water; //
Ego::OpenGL::Texture *tx_wall; //
Ego::OpenGL::Texture *tx_impass; //
Ego::OpenGL::Texture *tx_damage; //
Ego::OpenGL::Texture *tx_slippy; //

Ego::OpenGL::Texture *tx_smalltile[MAXTILE]; // Tiles
Ego::OpenGL::Texture *tx_bigtile[MAXTILE]; //
Ego::OpenGL::Texture *tx_tinysmalltile[MAXTILE]; // Plan tiles
Ego::OpenGL::Texture *tx_tinybigtile[MAXTILE]; //
Ego::Texture *tx_point; // Vertex image
Ego::Texture *tx_pointon; // Vertex image ( select_vertsed )
Ego::Texture *tx_ref; // Meshfx images
Ego::Texture *tx_drawref; //
Ego::Texture *tx_anim; //
Ego::Texture *tx_water; //
Ego::Texture *tx_wall; //
Ego::Texture *tx_impass; //
Ego::Texture *tx_damage; //
Ego::Texture *tx_slippy; //

Ego::Texture *tx_smalltile[MAXTILE]; // Tiles
Ego::Texture *tx_bigtile[MAXTILE]; //
Ego::Texture *tx_tinysmalltile[MAXTILE]; // Plan tiles
Ego::Texture *tx_tinybigtile[MAXTILE]; //

int numsmalltile = 0; //
int numbigtile = 0; //
Expand Down Expand Up @@ -139,7 +139,7 @@ SDL_Color MAKE_SDLCOLOR( Uint8 BB, Uint8 RR, Uint8 GG )
}

//--------------------------------------------------------------------------------------------
Ego::OpenGL::Texture * tiny_tile_at( cartman_mpd_t * pmesh, int mapx, int mapy )
Ego::Texture * tiny_tile_at( cartman_mpd_t * pmesh, int mapx, int mapy )
{
Uint16 tx_bits, basetile;
Uint8 fantype, fx;
Expand Down Expand Up @@ -202,7 +202,7 @@ Ego::OpenGL::Texture * tiny_tile_at( cartman_mpd_t * pmesh, int mapx, int mapy )
}

//--------------------------------------------------------------------------------------------
Ego::OpenGL::Texture *tile_at( cartman_mpd_t * pmesh, int fan )
Ego::Texture *tile_at( cartman_mpd_t * pmesh, int fan )
{
int img;
Uint16 img_base;
Expand Down Expand Up @@ -308,7 +308,7 @@ void make_planmap( cartman_mpd_t * pmesh )
putx = 0;
for ( x = 0; x < pmesh->info.getTileCountX(); x++ )
{
Ego::OpenGL::Texture * tx_tile;
Ego::Texture * tx_tile;
tx_tile = tiny_tile_at( pmesh, x, y );

if ( NULL != tx_tile )
Expand Down Expand Up @@ -408,7 +408,7 @@ void draw_top_fan( select_lst_t& plst, int fan, float zoom_hrz, float zoom_vrt )
if ( point_size > 0 )
{
int select_rv;
Ego::OpenGL::Texture * tx_tmp;
Ego::Texture * tx_tmp;

select_rv = select_lst_t::find(plst, vert);
if ( select_rv < 0 )
Expand Down Expand Up @@ -500,7 +500,7 @@ void draw_side_fan( select_lst_t& plst, int fan, float zoom_hrz, float zoom_vrt
for ( cnt = 0; cnt < pdef->numvertices; cnt++ )
{
int select_rv;
Ego::OpenGL::Texture * tx_tmp = NULL;
Ego::Texture * tx_tmp = NULL;

vert = faketoreal[cnt];

Expand Down Expand Up @@ -568,7 +568,7 @@ void draw_schematic(std::shared_ptr<Cartman_Window> pwin, int fantype, int x, in
}

//--------------------------------------------------------------------------------------------
void draw_top_tile( float x0, float y0, int fan, Ego::OpenGL::Texture * tx_tile, bool draw_tile, cartman_mpd_t * pmesh )
void draw_top_tile( float x0, float y0, int fan, Ego::Texture * tx_tile, bool draw_tile, cartman_mpd_t * pmesh )
{
static simple_vertex_t loc_vrt[4];

Expand Down Expand Up @@ -787,7 +787,7 @@ void draw_tile_fx( float x, float y, Uint8 fx, float scale )
}

//--------------------------------------------------------------------------------------------
void ogl_draw_sprite_2d(Ego::OpenGL::Texture * img, float x, float y, float width, float height )
void ogl_draw_sprite_2d(Ego::Texture * img, float x, float y, float width, float height )
{
float w, h;
float min_s, max_s, min_t, max_t;
Expand Down Expand Up @@ -836,7 +836,7 @@ void ogl_draw_sprite_2d(Ego::OpenGL::Texture * img, float x, float y, float widt
}

//--------------------------------------------------------------------------------------------
void ogl_draw_sprite_3d(Ego::OpenGL::Texture * img, cart_vec_t pos, cart_vec_t vup, cart_vec_t vright, float width, float height )
void ogl_draw_sprite_3d(Ego::Texture * img, cart_vec_t pos, cart_vec_t vup, cart_vec_t vright, float width, float height )
{
float w, h;
float min_s, max_s, min_t, max_t;
Expand Down
40 changes: 20 additions & 20 deletions cartman/src/cartman/cartman_gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,21 @@ extern camera_t cam;

extern SDL_Surface * bmphitemap; // Heightmap image

extern Ego::OpenGL::Texture *tx_point; // Vertex image
extern Ego::OpenGL::Texture *tx_pointon; // Vertex image ( select_vertsed )
extern Ego::OpenGL::Texture *tx_ref; // Meshfx images
extern Ego::OpenGL::Texture *tx_drawref; //
extern Ego::OpenGL::Texture *tx_anim; //
extern Ego::OpenGL::Texture *tx_water; //
extern Ego::OpenGL::Texture *tx_wall; //
extern Ego::OpenGL::Texture *tx_impass; //
extern Ego::OpenGL::Texture *tx_damage; //
extern Ego::OpenGL::Texture *tx_slippy; //

extern Ego::OpenGL::Texture *tx_smalltile[MAXTILE]; // Tiles
extern Ego::OpenGL::Texture *tx_bigtile[MAXTILE]; //
extern Ego::OpenGL::Texture *tx_tinysmalltile[MAXTILE]; // Plan tiles
extern Ego::OpenGL::Texture *tx_tinybigtile[MAXTILE]; //
extern Ego::Texture *tx_point; // Vertex image
extern Ego::Texture *tx_pointon; // Vertex image ( select_vertsed )
extern Ego::Texture *tx_ref; // Meshfx images
extern Ego::Texture *tx_drawref; //
extern Ego::Texture *tx_anim; //
extern Ego::Texture *tx_water; //
extern Ego::Texture *tx_wall; //
extern Ego::Texture *tx_impass; //
extern Ego::Texture *tx_damage; //
extern Ego::Texture *tx_slippy; //

extern Ego::Texture *tx_smalltile[MAXTILE]; // Tiles
extern Ego::Texture *tx_bigtile[MAXTILE]; //
extern Ego::Texture *tx_tinysmalltile[MAXTILE]; // Plan tiles
extern Ego::Texture *tx_tinybigtile[MAXTILE]; //

extern int numsmalltile; //
extern int numbigtile; //
Expand Down Expand Up @@ -143,12 +143,12 @@ void make_planmap( cartman_mpd_t * pmesh );
void draw_top_fan( select_lst_t& plst, int fan, float zoom_hrz, float zoom_vrt );
void draw_side_fan( select_lst_t& plst, int fan, float zoom_hrz, float zoom_vrt );
void draw_schematic(std::shared_ptr<Cartman_Window> pwin, int fantype, int x, int y);
void draw_top_tile( float x0, float y0, int fan, Ego::OpenGL::Texture * tx_tile, bool draw_tile, cartman_mpd_t * pmesh );
void draw_top_tile( float x0, float y0, int fan, Ego::Texture * tx_tile, bool draw_tile, cartman_mpd_t * pmesh );
void draw_tile_fx( float x, float y, Uint8 fx, float scale );

// ogl routines
void ogl_draw_sprite_2d( Ego::OpenGL::Texture * img, float x, float y, float width, float height );
void ogl_draw_sprite_3d( Ego::OpenGL::Texture * img, cart_vec_t pos, cart_vec_t vup, cart_vec_t vright, float width, float height );
void ogl_draw_sprite_2d( Ego::Texture * img, float x, float y, float width, float height );
void ogl_draw_sprite_3d( Ego::Texture * img, cart_vec_t pos, cart_vec_t vup, cart_vec_t vright, float width, float height );
void ogl_draw_box_xy( float x, float y, float z, float w, float h, float color[] );
void ogl_draw_box_xz( float x, float y, float z, float w, float d, float color[] );
void ogl_beginFrame();
Expand All @@ -171,8 +171,8 @@ void load_img();
void get_tiles(SDL_Surface* bmpload);

// misc
Ego::OpenGL::Texture * tiny_tile_at( cartman_mpd_t * pmesh, int mapx, int mapy );
Ego::OpenGL::Texture * tile_at( cartman_mpd_t * pmesh, int fan );
Ego::Texture * tiny_tile_at( cartman_mpd_t * pmesh, int mapx, int mapy );
Ego::Texture * tile_at( cartman_mpd_t * pmesh, int fan );

/**
* @todo
Expand Down
2 changes: 1 addition & 1 deletion cartman/src/cartman/cartman_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct Cartman_Window
{
Uint8 on; // Draw it?

Ego::OpenGL::Texture *tex; // Window images
Ego::Texture *tex; // Window images

// Window position
int x;
Expand Down
4 changes: 2 additions & 2 deletions egolib/src/egolib/Graphics/Font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace Ego
struct Font::StringCacheData : Id::NonCopyable
{
Uint32 lastUseInTicks;
Ego::OpenGL::Texture *tex;
Ego::Texture *tex;
std::string text;

StringCacheData() :
Expand Down Expand Up @@ -113,7 +113,7 @@ namespace Ego
}
}

void Font::drawTextToTexture(Ego::OpenGL::Texture *tex, const std::string &text, const Ego::Math::Colour3f &colour) const
void Font::drawTextToTexture(Ego::Texture *tex, const std::string &text, const Ego::Math::Colour3f &colour) const
{
if (!tex)
{
Expand Down
8 changes: 3 additions & 5 deletions egolib/src/egolib/Graphics/Font.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
#include "egolib/Math/Colour4f.hpp"

namespace Ego {
namespace OpenGL {
struct Texture;
} // namespace OpenGL
class Texture;
} // namespace Ego

namespace Ego
Expand Down Expand Up @@ -77,7 +75,7 @@ namespace Ego
* @param colour
* the colour of the text (default white)
*/
void drawTextToTexture(Ego::OpenGL::Texture *tex, const std::string &text,
void drawTextToTexture(Ego::Texture *tex, const std::string &text,
const Ego::Math::Colour3f &color = Ego::Math::Colour3f::white()) const;

#if 0
Expand All @@ -98,7 +96,7 @@ namespace Ego
* @param colour
* the colour of the text (default white)
*/
void drawTextBoxToTexture(Ego::OpenGL::Texture *tex, const std::string &text, int width, int height, int spacing,
void drawTextBoxToTexture(Ego::Texture *tex, const std::string &text, int width, int height, int spacing,
const Ego::Math::Colour3f &color = Ego::Math::Colour3f::white()) const;
#endif

Expand Down
6 changes: 3 additions & 3 deletions egolib/src/egolib/Graphics/TextureManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void TextureManager::updateDeferredLoading()
{
std::lock_guard<std::mutex> lock(_deferredLoadingMutex);
for(const std::string &filePath : _requestedLoadDeferredTextures) {
std::shared_ptr<Ego::OpenGL::Texture> loadTexture = std::make_shared<Ego::OpenGL::Texture>();
std::shared_ptr<Ego::Texture> loadTexture = std::make_shared<Ego::OpenGL::Texture>();
ego_texture_load_vfs(loadTexture.get(), filePath.c_str(), TRANSCOLOR);
_textureCache[filePath] = loadTexture;
Log::get().debug("Deferred texture load: %s\n", filePath.c_str());
Expand All @@ -84,15 +84,15 @@ void TextureManager::updateDeferredLoading()
_notifyDeferredLoadingComplete.notify_all();
}

const std::shared_ptr<Ego::OpenGL::Texture>& TextureManager::getTexture(const std::string &filePath)
const std::shared_ptr<Ego::Texture>& TextureManager::getTexture(const std::string &filePath)
{
//Not loaded yet?
auto result = _textureCache.find(filePath);
if(result == _textureCache.end()) {

if(SDL_GL_GetCurrentContext() != nullptr) {
//We are the main OpenGL context thread so we can load textures
std::shared_ptr<Ego::OpenGL::Texture> loadTexture = std::make_shared<Ego::OpenGL::Texture>();
std::shared_ptr<Ego::Texture> loadTexture = std::make_shared<Ego::OpenGL::Texture>();
ego_texture_load_vfs(loadTexture.get(), filePath.c_str(), TRANSCOLOR);
_textureCache[filePath] = loadTexture;
}
Expand Down
6 changes: 3 additions & 3 deletions egolib/src/egolib/Graphics/TextureManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ struct TextureManager : public Ego::Core::Singleton <TextureManager>
* The texture loaded by this texture manager. Could be the error texture if the specified
* path cannot be found.
**/
const std::shared_ptr<Ego::OpenGL::Texture>& getTexture(const std::string &filePath);
const std::shared_ptr<Ego::Texture>& getTexture(const std::string &filePath);

void updateDeferredLoading();

private:
std::forward_list<std::shared_ptr<Ego::OpenGL::Texture>> _unload;
std::unordered_map<std::string, std::shared_ptr<Ego::OpenGL::Texture>> _textureCache;
std::forward_list<std::shared_ptr<Ego::Texture>> _unload;
std::unordered_map<std::string, std::shared_ptr<Ego::Texture>> _textureCache;

std::mutex _deferredLoadingMutex;
std::forward_list<std::string> _requestedLoadDeferredTextures;
Expand Down
4 changes: 2 additions & 2 deletions egolib/src/egolib/Profiles/ModuleProfile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ModuleProfile

ModuleFilter getModuleType() const;

inline Ego::OpenGL::Texture *getIcon() {
inline Ego::Texture *getIcon() {
return _icon;
}

Expand Down Expand Up @@ -136,7 +136,7 @@ class ModuleProfile
ModuleFilter _moduleType; ///< Main quest, town, sidequest or whatever
bool _beaten; ///< The module has been marked with the [BEAT] eapansion

Ego::OpenGL::Texture *_icon; ///< the index of the module's tile image
Ego::Texture *_icon; ///< the index of the module's tile image
std::string _vfsPath; ///< the virtual pathname of the module ("mp_module/advent.mod")
std::string _folderName; ///< Folder name of module ("advent.mod")

Expand Down
2 changes: 1 addition & 1 deletion egolib/src/egolib/Renderer/DeferredOpenGLTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ DeferredOpenGLTexture::DeferredOpenGLTexture(const std::string &filePath) :
//Do not load texture until its needed
}

const Ego::OpenGL::Texture& DeferredOpenGLTexture::get()
const Ego::Texture& DeferredOpenGLTexture::get()
{
if(!_loaded) {
if(_filePath.empty()) {
Expand Down
8 changes: 4 additions & 4 deletions egolib/src/egolib/Renderer/DeferredOpenGLTexture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ namespace Ego

DeferredOpenGLTexture(const std::string &filePath);

const Ego::OpenGL::Texture* get_ptr() const { return &const_cast<DeferredOpenGLTexture*>(this)->get(); }
const Ego::Texture* get_ptr() const { return &const_cast<DeferredOpenGLTexture*>(this)->get(); }

const Ego::OpenGL::Texture& get();
const Ego::Texture& get();

void release();

void setTextureSource(const std::string &filePath);

//Type cast operator
operator const Ego::OpenGL::Texture&() const {return const_cast<DeferredOpenGLTexture*>(this)->get();}
operator const Ego::Texture&() const {return const_cast<DeferredOpenGLTexture*>(this)->get();}

/**
* @return
Expand All @@ -39,7 +39,7 @@ namespace Ego
}

private:
std::shared_ptr<Ego::OpenGL::Texture> _texture;
std::shared_ptr<Ego::Texture> _texture;
std::string _filePath;
bool _loaded;
};
Expand Down
2 changes: 1 addition & 1 deletion egolib/src/egolib/fileutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,7 @@ bool ego_texture_exists_vfs(const std::string &filename)
return false;
}

bool ego_texture_load_vfs(Ego::OpenGL::Texture *texture, const char *filename, Uint32 key)
bool ego_texture_load_vfs(Ego::Texture *texture, const char *filename, Uint32 key)
{
// Get rid of any old data.
texture->release();
Expand Down
2 changes: 1 addition & 1 deletion egolib/src/egolib/fileutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ bool copy_to_delimiter_vfs(vfs_FILE * fileread, vfs_FILE * filewrite, int delim,
* succeeds (i.e. the image was successfully loaded into the texture) or all
* combinations failed.
*/
bool ego_texture_load_vfs(Ego::OpenGL::Texture *texture, const char *filename, uint32_t key = INVALID_KEY);
bool ego_texture_load_vfs(Ego::Texture *texture, const char *filename, uint32_t key = INVALID_KEY);

bool ego_texture_exists_vfs(const std::string &filename);

Expand Down
2 changes: 1 addition & 1 deletion egolib/src/egolib/font_bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void font_bmp_load_vfs( const std::string& szBitmap, const char* szSpacing )
/// of each font on that bitmap... Bitmap must have 16x6 fonts
font_bmp_init();

const std::shared_ptr<Ego::OpenGL::Texture> &fontTexture = TextureManager::get().getTexture(szBitmap);
const std::shared_ptr<Ego::Texture> &fontTexture = TextureManager::get().getTexture(szBitmap);
if (fontTexture->isDefault())
{
std::ostringstream os;
Expand Down
2 changes: 1 addition & 1 deletion game/src/game/Entities/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2934,7 +2934,7 @@ const std::shared_ptr<Object>& Object::getAttachedPlatform() const
return _currentModule->getObjectHandler()[onwhichplatform_ref];
}

const Ego::OpenGL::Texture* Object::getIcon() const
const Ego::Texture* Object::getIcon() const
{
//Is it a spellbook?
if (getProfile()->getSpellEffectType() == ObjectProfile::NO_SKIN_OVERRIDE)
Expand Down
2 changes: 1 addition & 1 deletion game/src/game/Entities/Object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ class Object : public PhysicsData, public Id::NonCopyable, public Ego::Physics::

void dropAllItems();

const Ego::OpenGL::Texture* getIcon() const;
const Ego::Texture* getIcon() const;

private:

Expand Down

0 comments on commit f07b364

Please sign in to comment.