Don't overwrite GL state when creating text-rendering data. Closes #1994

This commit is contained in:
baldurk
2020-07-27 11:09:20 +01:00
parent 287bb81fca
commit 691ee0c348
2 changed files with 16 additions and 9 deletions
+3 -3
View File
@@ -88,13 +88,13 @@ void WrappedOpenGL::ContextData::CreateDebugData()
ResetPixelPackState(false, 1);
ResetPixelUnpackState(false, 1);
GLuint curtex = 0;
GL.glGetIntegerv(eGL_TEXTURE_BINDING_2D, (GLint *)&curtex);
GLenum oldActive = eGL_TEXTURE0;
GL.glGetIntegerv(eGL_ACTIVE_TEXTURE, (GLint *)&oldActive);
GL.glActiveTexture(eGL_TEXTURE0);
GLuint curtex = 0;
GL.glGetIntegerv(eGL_TEXTURE_BINDING_2D, (GLint *)&curtex);
GLenum texFmt = eGL_R8;
if(Legacy())
texFmt = eGL_LUMINANCE;
+13 -6
View File
@@ -96,8 +96,9 @@ in v2f vertIn;
layout(location = 0, index = 0) out vec4 Color;
layout(binding = 0) uniform sampler2D checker;
layout(binding = 1) uniform sampler2D smiley;
layout(binding = 0) uniform sampler2D smiley;
layout(binding = 1) uniform sampler2D white;
layout(binding = 2) uniform sampler2D checker;
layout(std140) uniform constsbuf
{
@@ -127,7 +128,7 @@ void main()
return;
}
Color = texture(smiley, vertIn.uv.xy * 2.0f) * texture(checker, vertIn.uv.xy * 5.0f);
Color = texture(smiley, vertIn.uv.xy * 2.0f) * texture(white, vertIn.uv.xy * 2.0f) * texture(checker, vertIn.uv.xy * 5.0f);
Color.w = 1.0f;
}
@@ -155,6 +156,7 @@ void main()
glBindTexture(GL_TEXTURE_2D, offscreen);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 128, 128);
glActiveTexture(GL_TEXTURE0);
GLuint smiley = MakeTexture();
glBindTexture(GL_TEXTURE_2D, smiley);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, rgba8.width, rgba8.height);
@@ -162,9 +164,14 @@ void main()
rgba8.data.data());
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, smiley);
uint32_t whiteData[4 * 4];
memset(whiteData, 0xff, sizeof(whiteData));
GLuint white = MakeTexture();
glBindTexture(GL_TEXTURE_2D, white);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 4, 4);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, whiteData);
glActiveTexture(GL_TEXTURE0);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, 0);
std::string vssrc = common + vertex;
@@ -209,7 +216,7 @@ void main()
auto SetupSampler = []() {
GLuint sampler = 0;
glGenSamplers(1, &sampler);
glBindSampler(1, sampler);
glBindSampler(0, sampler);
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_R, GL_REPEAT);
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);