Skip to content

Commit

Permalink
Use GL_RGBA8 for atlas texture format, and minor tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
grantramsay committed Mar 17, 2019
1 parent 617c032 commit 8ce51e6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions apps/freeablo/farender/spritecache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ namespace FARender

void SpriteCache::evict()
{
if (!Render::SpriteGroup::canDelete())
if (!Render::SpriteGroup::canDeleteSprites())
return;

std::list<uint32_t>::reverse_iterator it;
Expand All @@ -282,7 +282,7 @@ namespace FARender

void SpriteCache::clear()
{
if (!Render::SpriteGroup::canDelete())
if (!Render::SpriteGroup::canDeleteSprites())
return;

for (std::list<uint32_t>::iterator it = mUsedList.begin(); it != mUsedList.end(); it++)
Expand Down
3 changes: 1 addition & 2 deletions components/render/atlastexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ namespace Render
// Allocate memory for texture array (by passing NULL).
// NOTE: For GL_COMPRESSED_RGBA image dimensions need to be padded to a
// multiple/alignment of 4: https://forums.khronos.org/showthread.php/77554
// Also may need to clear texture if there are
glTexImage2D(GL_TEXTURE_2D,
0,
/*GL_RGBA8*/ GL_RGB5_A1 /*GL_COMPRESSED_RGBA*/,
/*GL_RGB5_A1*/ GL_RGBA8 /*GL_COMPRESSED_RGBA*/,
mTextureWidth,
mTextureHeight,
0,
Expand Down
2 changes: 1 addition & 1 deletion components/render/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Render
public:
SpriteGroup(const std::string& path);
SpriteGroup(const std::vector<Sprite> sprites) : mSprites(sprites), mAnimLength(sprites.size()) {}
static bool canDelete();
static bool canDeleteSprites();
void destroy();

Sprite& operator[](size_t index);
Expand Down
11 changes: 6 additions & 5 deletions components/render/sdl2backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "../cel/celframe.h"

#include "../level/level.h"
#include <boost/make_unique.hpp>
#include <faio/fafileobject.h>
#include <misc/assert.h>
#include <misc/savePNG.h>
Expand Down Expand Up @@ -60,8 +61,8 @@ int AmdPowerXpressRequestHighPerformance = 1;

namespace Render
{
// atlasTexture is optional as to not instantiate until opengl is setup.
boost::optional<AtlasTexture> atlasTexture = boost::none;
// atlasTexture is unique_ptr as to not instantiate until opengl is setup.
std::unique_ptr<AtlasTexture> atlasTexture = nullptr;

/* Caches level sprites/positions etc in a format that can be directly injected into GL VBOs. */
class DrawLevelCache
Expand Down Expand Up @@ -161,7 +162,7 @@ namespace Render
int major = glVersion[0] - '0';
int minor = glVersion[2] - '0';
if (major < 3 || (major == 3 && minor < 3))
std::cerr << "ERROR: Minimum OpenGL version is 3.3. Your current version is " << major << "." << minor << std::endl;
message_and_abort_fmt("ERROR: Minimum OpenGL version is 3.3. Your current version is %d.%d\n", major, minor);

/*int oglIdx = -1;
int nRD = SDL_GetNumRenderDrivers();
Expand All @@ -184,7 +185,7 @@ namespace Render
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);

atlasTexture = AtlasTexture();
atlasTexture = boost::make_unique<AtlasTexture>();

if (nk_ctx)
{
Expand Down Expand Up @@ -967,7 +968,7 @@ namespace Render
jo_gif_end(&gif);
}

bool SpriteGroup::canDelete()
bool SpriteGroup::canDeleteSprites()
{
// Sprites can not currently be removed from atlas texture.
return false;
Expand Down
2 changes: 1 addition & 1 deletion components/render/sdl_gl_funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
GLenum err; \
while ((err = glGetError()) != GL_NO_ERROR) \
{ \
fprintf(stderr, "glError %s:%d, 0x%04X\n", __FILE__, __LINE__, err); \
message_and_abort_fmt("glError %s:%d, 0x%04X\n", __FILE__, __LINE__, err); \
} \
}

Expand Down

0 comments on commit 8ce51e6

Please sign in to comment.