Jump to content
  • Advertisement
Sign in to follow this  
Chaosenemy

Help getting started with GLSL?

This topic is 2522 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to get a very simple vertex shader running but nothing seems to be happening. The shader loads, compiles, and links successfully - no errors. When I try to use it however, nothing renders. Here is my shader code:


void main(void)
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}


As far as I know, the above code should just render the vertex like usual, correct?
Here is my drawing code in the application itself:



glUseProgram(programObject);
glBegin(GL_QUADS);
glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f(0.0f, -1.0f, -1.0f);
glVertex3f(0.0f, -1.0f, 1.0f);
glVertex3f(0.0f, 1.0f, 1.0f);
glVertex3f(0.0f, 1.0f, -1.0f);
glEnd();
glUseProgram(0);


If I comment out 'glUseProgram(programObject)' the quad renders just fine. Otherwise, nothing is rendered at all from what I can see anyways.

I know this is simple but I swear I've Googled the hell out of it and can't figure out what I'm doing wrong. Any help would be much appreciated. Thanks.

EDIT: Figured it out. Apparently if you don't specify a color in the shader source, it draws the vertex black. So I wasn't seeing it on my black background. D'oh!

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!