View Full Version : problem of Built-in variables
04-02-2011, 07:22 AM
In the Orange Book, gl_position=MVPMatrix*MCVertex,however, in some GLSL courses, gl_position=ftransform(),i did not find ftransform() in the OpenGL Quick Reference Guide and also did not found variables such as gl_FrontMaterial,but it works in RenderMonkey, can some one tell me where i can get the major difference between different GLSL version?
04-02-2011, 07:53 AM
It is because ftransform is deprecated since GLSL 1.3 I guess
Rendermonkey probably use a compatibility context.
In newer versions of GLSL you need to set up the matrices you want to use inside shader code.
Take a look at glsl 4.1 spec. There is a section called changes.
04-02-2011, 09:25 AM
so you mean that i have to use functions such as glVertexAtrib() and glBindAttribLocation() to give value to MVMatrix instead of using gl_ModelViewMatrix directly?
04-02-2011, 01:38 PM
Yes, if you are using a core context of version 3.1 or later.
04-02-2011, 01:40 PM
You set the uniform MVPMatrix value with "glGetUniformLocation and glUniformMatrix4fv". The attribute MCVertex is set using "glVertexAtrib() and glBindAttribLocation()"
After you compile your vertex shader, then you have to first get
//Get handle to shader uniform
GLint h_MVPMatrix = glGetUniformLocation(program,"MVPMatrix");
then you need to set the MVPMatrix in the vertex shader
where your_matrix has 16 elements and controlled by you (instead of glTranslate/glRotate, etc) ... the form of the matrix is described in the Section. OpenGL Transformation Matrix (http://www.songho.ca/opengl/gl_transform.html).
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.