D opengl custom vs fixed matrix oddity

I recently worked on switching to processing my matrix controls so that my engine is ready to switch to a 4.0+ context, although I am currently using 2.1 context with Derelict. I tried all kinds of matrix calculations and nothing works with my shader (nothing on the screen except the FPS counter, if I do not return to the fixed pipe, or if I switch vs to set gl_Position = vec4 (position, 1.0);). Even when I get the values ​​that OpenGL usually sets and puts into them, I get the same thing.

I added print both from my matrix and from the line in which the fixed pipeline returned to callbacks and the output was IDENTICAL. I already checked and double checked my shader code, so I'm pretty lost where this error comes from.

This happens on both OSX and Windows. I have a glGetError()check for every draw call, and I am not getting any errors. Shaders link and verify without warning or error.

code for uniform loading:

glUniformMatrix4fv(ModelViewLoc,1, GL_FALSE ,modelview);
glUniformMatrix4fv(ProjectionLoc,1, GL_FALSE ,projection);

Vertex Shader:

#version 120

//layout(location = 0) in vec3 position;
attribute vec3 position;

uniform mat4 ModelView;
uniform mat4 Projection;

void main()
        {
                mat4 mvp = Projection*ModelView;
                gl_Position = mvp * vec4(position,1.0);
                //gl_Position = vec4(position,1.0);
        }

Fragment Shader:

#version 120

uniform float slider;

        void main()
        {
                vec4 diffuse = vec4(vec3(slider),1.0);

                gl_FragColor = diffuse;
        }

debug output:

Model 1:

OpenGL ModelView: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -2, -2, -8, 1]
mine:             [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -2, -2, -8, 1]

OpenGL Projection:[1.30323, 0, 0, 0, 0, 1.30323, 0, 0, 0, 0, -1.0002, -1, 0, 0, -0.20002, 0]
mine:             [1.30323, 0, 0, 0, 0, 1.30323, 0, 0, 0, 0, -1.0002, -1, 0, 0, -0.20002, 0]

Model 2:

OpenGL ModelView: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2, 2, -8, 1]
mine:             [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2, 2, -8, 1]

OpenGL Projection:[1.30323, 0, 0, 0, 0, 1.30323, 0, 0, 0, 0, -1.0002, -1, 0, 0, -0.20002, 0]
mine:             [1.30323, 0, 0, 0, 0, 1.30323, 0, 0, 0, 0, -1.0002, -1, 0, 0, -0.20002, 0]

* UPDATE * I released the code for the matrix lib @ github.com / mclark4386 / DMath See something there? ^^;

+3
source share

All Articles