TINYGL: Cleanup code

This commit is contained in:
Paweł Kołodziejski 2021-12-04 14:27:35 +01:00
parent a9746518e4
commit 86dc65250e
No known key found for this signature in database
GPG Key ID: 0BDADC9E74440FF7
3 changed files with 9 additions and 10 deletions

View File

@ -45,7 +45,8 @@ void initSharedState(GLContext *c) {
void endSharedState(GLContext *c) {
GLSharedState *s = &c->shared_state;
free_texture(c, 0);
uint h = 0;
free_texture(c, h);
for (int i = 0; i < MAX_DISPLAY_LISTS; i++) {
// TODO
}

View File

@ -34,7 +34,7 @@
namespace TinyGL {
static GLTexture *find_texture(GLContext *c, unsigned int h) {
static GLTexture *find_texture(GLContext *c, uint h) {
GLTexture *t;
t = c->shared_state.texture_hash_table[h % TEXTURE_HASH_TABLE_SIZE];
@ -43,10 +43,10 @@ static GLTexture *find_texture(GLContext *c, unsigned int h) {
return t;
t = t->next;
}
return NULL;
return nullptr;
}
void free_texture(GLContext *c, int h) {
void free_texture(GLContext *c, uint h) {
free_texture(c, find_texture(c, h));
}
@ -74,7 +74,7 @@ void free_texture(GLContext *c, GLTexture *t) {
gl_free(t);
}
GLTexture *alloc_texture(GLContext *c, int h) {
GLTexture *alloc_texture(GLContext *c, uint h) {
GLTexture *t, **ht;
t = (GLTexture *)gl_zalloc(sizeof(GLTexture));
@ -82,7 +82,7 @@ GLTexture *alloc_texture(GLContext *c, int h) {
ht = &c->shared_state.texture_hash_table[h % TEXTURE_HASH_TABLE_SIZE];
t->next = *ht;
t->prev = NULL;
t->prev = nullptr;
if (t->next)
t->next->prev = t;
*ht = t;
@ -95,13 +95,11 @@ GLTexture *alloc_texture(GLContext *c, int h) {
}
void glInitTextures(GLContext *c) {
// textures
c->texture_2d_enabled = 0;
c->current_texture = find_texture(c, 0);
c->texture_mag_filter = TGL_LINEAR;
c->texture_min_filter = TGL_NEAREST_MIPMAP_LINEAR;
#if defined(SCUMM_LITTLE_ENDIAN)
c->colorAssociationList.push_back({Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), TGL_RGBA, TGL_UNSIGNED_BYTE});
c->colorAssociationList.push_back({Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), TGL_RGBA, TGL_UNSIGNED_BYTE});
c->colorAssociationList.push_back({Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24), TGL_BGRA, TGL_UNSIGNED_BYTE});
c->colorAssociationList.push_back({Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0), TGL_RGB, TGL_UNSIGNED_BYTE});

View File

@ -433,8 +433,8 @@ void gl_shade_vertex(GLContext *c, GLVertex *v);
void glInitTextures(GLContext *c);
void glEndTextures(GLContext *c);
GLTexture *alloc_texture(GLContext *c, int h);
void free_texture(GLContext *c, int h);
GLTexture *alloc_texture(GLContext *c, uint h);
void free_texture(GLContext *c, uint h);
void free_texture(GLContext *c, GLTexture *t);
// image_util.c