Use explicit shader attributes.
This commit is contained in:
@@ -91,9 +91,9 @@ namespace OpenRA.Platforms.Default
|
||||
throw new InvalidProgramException("Missing OpenGL extension GL_EXT_framebuffer_object. See graphics.log for details.");
|
||||
}
|
||||
|
||||
GL.EnableClientState(ArrayCap.VertexArray);
|
||||
GL.EnableVertexAttribArray(Shader.VertexPosAttributeIndex);
|
||||
ErrorHandler.CheckGlError();
|
||||
GL.EnableClientState(ArrayCap.TextureCoordArray);
|
||||
GL.EnableVertexAttribArray(Shader.TexCoordAttributeIndex);
|
||||
ErrorHandler.CheckGlError();
|
||||
|
||||
SDL.SDL_SetModState(SDL.SDL_Keymod.KMOD_NONE);
|
||||
|
||||
@@ -18,6 +18,9 @@ namespace OpenRA.Platforms.Default
|
||||
{
|
||||
class Shader : ThreadAffine, IShader
|
||||
{
|
||||
public const int VertexPosAttributeIndex = 0;
|
||||
public const int TexCoordAttributeIndex = 1;
|
||||
|
||||
readonly Dictionary<string, int> samplers = new Dictionary<string, int>();
|
||||
readonly Dictionary<int, ITexture> textures = new Dictionary<int, ITexture>();
|
||||
readonly int program;
|
||||
@@ -62,6 +65,12 @@ namespace OpenRA.Platforms.Default
|
||||
// Assemble program
|
||||
program = GL.CreateProgram();
|
||||
ErrorHandler.CheckGlError();
|
||||
|
||||
GL.BindAttribLocation(program, VertexPosAttributeIndex, "aVertexPosition");
|
||||
ErrorHandler.CheckGlError();
|
||||
GL.BindAttribLocation(program, TexCoordAttributeIndex, "aVertexTexCoord");
|
||||
ErrorHandler.CheckGlError();
|
||||
|
||||
GL.AttachShader(program, vertexShader);
|
||||
ErrorHandler.CheckGlError();
|
||||
GL.AttachShader(program, fragmentShader);
|
||||
|
||||
@@ -63,9 +63,9 @@ namespace OpenRA.Platforms.Default
|
||||
VerifyThreadAffinity();
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, buffer);
|
||||
ErrorHandler.CheckGlError();
|
||||
GL.VertexPointer(3, VertexPointerType.Float, VertexSize, IntPtr.Zero);
|
||||
GL.VertexAttribPointer(Shader.VertexPosAttributeIndex, 3, VertexAttribPointerType.Float, false, VertexSize, IntPtr.Zero);
|
||||
ErrorHandler.CheckGlError();
|
||||
GL.TexCoordPointer(4, TexCoordPointerType.Float, VertexSize, new IntPtr(12));
|
||||
GL.VertexAttribPointer(Shader.TexCoordAttributeIndex, 4, VertexAttribPointerType.Float, false, VertexSize, new IntPtr(12));
|
||||
ErrorHandler.CheckGlError();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user