# HG changeset patch # User Matti Hamalainen # Date 1610454798 -7200 # Node ID 3863ad92f8d86fde1208a2c9e9b2be2a91a1fa70 # Parent ff739727dfec322c0c5bc0e53b6cdc976862f038 Rename a variable. diff -r ff739727dfec -r 3863ad92f8d8 dmglrender.cpp --- a/dmglrender.cpp Sat Oct 31 18:14:17 2020 +0200 +++ b/dmglrender.cpp Tue Jan 12 14:33:18 2021 +0200 @@ -165,6 +165,19 @@ } +#define TWIDTH 8 +#define THEIGHT 8 +static char texSrc8[TWIDTH * THEIGHT + 1] = + "..%##%.." + ".%####%." + "%#*..*#%" + "##....##" + "########" + "##....##" + "##....##" + "##....##"; + + bool DMGLSimpleRenderer::initRenderer2(void) { // Dump some information @@ -215,24 +228,14 @@ // Create texture bitmap -#define TWIDTH 8 -#define THEIGHT 8 - char texSrc[TWIDTH * THEIGHT + 1] = - "..%##%.." - ".%####%." - "%#*..*#%" - "##....##" - "########" - "##....##" - "##....##" - "##....##"; for (int yc = 0; yc < THEIGHT; yc++) { - Uint8 *dp = ((Uint8 *) texSrc) + yc * TWIDTH; + Uint8 *dp8 = ((Uint8 *) texSrc8) + yc * TWIDTH; + for (int xc = 0; xc < TWIDTH; xc++) { - Uint8 col = dp[xc]; + Uint8 col = dp8[xc]; switch (col) { case '.': col = 0; break; @@ -240,16 +243,16 @@ case '*': col = 128; break; default: col = 192; break; } - dp[xc] = col; + dp8[xc] = col; } } // Upload to GPU texture - glGenTextures(1, &tex); - glBindTexture(GL_TEXTURE_2D, tex); + glGenTextures(1, &tex8); + glBindTexture(GL_TEXTURE_2D, tex8); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, TWIDTH, THEIGHT, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, texSrc); + glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, TWIDTH, THEIGHT, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, texSrc8); glBindTexture(GL_TEXTURE_2D, 0); return checkErrors(); @@ -370,7 +373,7 @@ // Draw texture glColor3ub(0xff, 0xff, 0xff); glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, tex); + glBindTexture(GL_TEXTURE_2D, tex8); glBegin(GL_QUADS); float s = 0.50f; glTexCoord2i(-1, 0); glVertex2f(0, 0); diff -r ff739727dfec -r 3863ad92f8d8 dmglrender.h --- a/dmglrender.h Sat Oct 31 18:14:17 2020 +0200 +++ b/dmglrender.h Tue Jan 12 14:33:18 2021 +0200 @@ -16,7 +16,7 @@ struct DMGLSimpleRenderer : DMSimpleRenderer { SDL_GLContext sdlGLContext; - GLuint tex; + GLuint tex8; DMGLSimpleRenderer() {