Skip to main content
GameDev.net gamedev.net
🔒 Locked

GLSL program -- No results

Started by vodoo Oct 19, 2008 at 1:45 PM 0 replies 850+ views
Original Post
vodoo
vodoo
Hello All. I am a newbie to GLSL. I intend to rotate a triangle by some degrees using GLSL. I created a triangle using glBegin(GL_TRIANGLES).using glShadeModel(GL_FLAT) with blue color. Now in the vertex shader I am doing following: -------------------------------------------------------------------------- //This is vertex shader that rotates the triangle by 180 deg. void main(void) { vec4 vf_new_position; //local variable. float fAngle = 0.0; fAngle = radians(180.0); vf_new_position = vec4(gl_Vertex); //z coordinate remains unchanged.i.e rotation is around z axis. vf_new_position.x = cos( fAngle )*(gl_Vertex.x/gl_Vertex[3]) - sin( fAngle )*(gl_Vertex.y/gl_Vertex[3]) ; vf_new_position.y = sin( fAngle )*(gl_Vertex.x/gl_Vertex[3]) + cos( fAngle )*(gl_Vertex.y/gl_Vertex[3]) ; vf_new_position.z = (gl_Vertex.z/gl_Vertex[3]) ; vf_new_position.w = gl_Vertex; gl_Position = gl_ModelViewMatrix * vf_new_position; } -------------------------------------------------------------------------- After compiling and executing, I am getting a blank screen. Note: I checked the shader and program log file --- no errors. What can be the real problem? Why can 't I see triangle rotated? Help appreciated.
V-man
V-man
What is gl_Vertex[3]?
Perhaps you should replace by gl_Vertex.w

Here, there is a mismatch
vf_new_position.w = gl_Vertex;

You probably need
vf_new_position.w = gl_Vertex.w;

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.