Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Help getting started with GLSL?

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 Chaosenemy   Members   

152
Like
0Likes
Like

Posted 15 January 2012 - 07:35 PM

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!

#2 Nairou   Members   

430
Like
0Likes
Like

Posted 20 January 2012 - 12:49 PM

If you really want to get into GLSL, you should learn with a newer version of OpenGL (3.1 or higher), as the old-school functions used in your post have been deprecated. Here is a tutorial I found easy to follow: http://www.opengl-tutorial.org/




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.