Skip to content

Commit

Permalink
fix #5923
Browse files Browse the repository at this point in the history
Conflicts:
	rts/Rendering/Textures/Bitmap.cpp
  • Loading branch information
rt committed Mar 14, 2018
1 parent 6a15411 commit 059d585
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions rts/Rendering/Textures/Bitmap.cpp
Expand Up @@ -579,7 +579,11 @@ unsigned int CBitmap::CreateTexture(float aniso, bool mipmaps) const
return bm.CreateTexture(aniso, mipmaps);
}

unsigned int texture;

constexpr unsigned int intFormats[] = {0, GL_R8 , GL_RG8, GL_RGB8, GL_RGBA8};
constexpr unsigned int extFormats[] = {0, GL_RED, GL_RG , GL_RGB , GL_RGBA }; // GL_R is not accepted for [1]

unsigned int texture = 0;

glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
Expand All @@ -593,14 +597,10 @@ unsigned int CBitmap::CreateTexture(float aniso, bool mipmaps) const

if (mipmaps) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

glBuildMipmaps(GL_TEXTURE_2D, GL_RGBA8, xsize, ysize, GL_RGBA, GL_UNSIGNED_BYTE, &mem[0]);
glBuildMipmaps(GL_TEXTURE_2D, intFormats[channels], xsize, ysize, extFormats[channels], GL_UNSIGNED_BYTE, &mem[0]);
} else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA8 ,xsize, ysize, 0,GL_RGBA, GL_UNSIGNED_BYTE, &mem[0]);
//gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA8 ,xsize, ysize, GL_RGBA, GL_UNSIGNED_BYTE, &mem[0]);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, xsize, ysize, 0, GL_RGBA, GL_UNSIGNED_BYTE, &mem[0]);
glTexImage2D(GL_TEXTURE_2D, 0, intFormats[channels], xsize, ysize, 0, extFormats[channels], GL_UNSIGNED_BYTE, &mem[0]);
}

return texture;
Expand Down

0 comments on commit 059d585

Please sign in to comment.