Răsfoiți Sursa

Fix texture scrambling

Daniele Bartolini 12 ani în urmă
părinte
comite
b0a22b332a
2 a modificat fișierele cu 30 adăugiri și 29 ștergeri
  1. 1 1
      engine/renderers/RenderContext.h
  2. 29 28
      engine/renderers/gl/GLRenderer.cpp

+ 1 - 1
engine/renderers/RenderContext.h

@@ -168,7 +168,7 @@ public:
 
 	uint64_t		m_flags;
 
-	Matrix4x4			pose;
+	Matrix4x4		pose;
 	GPUProgramId	program;
 	VertexBufferId	vb;
 	IndexBufferId	ib;

+ 29 - 28
engine/renderers/gl/GLRenderer.cpp

@@ -336,6 +336,35 @@ public:
 				GL_CHECK(glDisable(GL_BLEND));
 			}
 
+			// Bind textures
+			{
+				uint64_t flags = STATE_TEXTURE_0;
+				for (uint32_t unit = 0; unit < STATE_MAX_TEXTURES; unit++)
+				{
+					const Sampler& sampler = cur_state.samplers[unit];
+
+					if (sampler.sampler_id.id != INVALID_ID)
+					{
+						switch (sampler.flags & SAMPLER_MASK)
+						{
+							case SAMPLER_TEXTURE:
+							{
+								Texture& texture = m_textures[sampler.sampler_id.index];
+								texture.commit(unit, sampler.flags);
+								break;
+							}
+							default:
+							{
+								CE_ASSERT(false, "Oops, sampler unknown");
+								break;
+							}
+						}
+					}
+
+					flags <<= 1;
+				}
+			}
+
 			// Bind GPU program
 			if (cur_state.program.id != INVALID_ID)
 			{
@@ -421,34 +450,6 @@ public:
 				GL_CHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
 			}
 
-			// Bind textures
-			{
-				uint64_t flags = STATE_TEXTURE_0;
-				for (uint32_t unit = 0; unit < STATE_MAX_TEXTURES; unit++)
-				{
-					const Sampler& sampler = cur_state.samplers[unit];
-
-					if (sampler.sampler_id.id != INVALID_ID)
-					{
-						switch (sampler.flags & SAMPLER_MASK)
-						{
-							case SAMPLER_TEXTURE:
-							{
-								Texture& texture = m_textures[sampler.sampler_id.index];
-								texture.commit(unit, sampler.flags);
-								break;
-							}
-							default:
-							{
-								CE_ASSERT(false, "Oops, sampler unknown");
-								break;
-							}
-						}
-					}
-
-					flags <<= 1;
-				}
-			}
 		}
 
 		GL_CHECK(glFinish());