Jump to content

  • Log In with Google      Sign In   
  • Create Account

Rendering Shadows


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
4 replies to this topic

#1 aviel   Members   -  Reputation: 100

Like
0Likes
Like

Posted 10 May 2011 - 07:53 PM

So, I've been following nehe's guide to creating shadows, and for whatever reason the shadows just aren't rendering. Not having an excellent understanding of things like the stencil-buffer means I'm sort of learning things as I go along. I hate outsourcing my debugging, but I'm kind of stumped here. does anybody know what's wrong?
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
glPushAttrib( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_POLYGON_BIT | GL_STENCIL_BUFFER_BIT );
glDisable( GL_LIGHTING );
glDepthMask( GL_FALSE );
glDepthFunc( GL_LEQUAL );
glEnable( GL_STENCIL_TEST );
glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
glStencilFunc( GL_ALWAYS, 1, 0xFFFFFFFFL );

glFrontFace( GL_CCW );
glStencilOp( GL_KEEP, GL_KEEP, GL_INCR );

//shadow volume quad drawing code here
//I've checked to make sure that the code to draw the volume is running
//so I thought I'd spare you that

glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);

glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glStencilFunc(GL_NOTEQUAL, 0, 0xffffffff);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);

glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glOrtho(0, 1, 1, 0, 0, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glBegin(GL_QUADS);
	glVertex2i(0, 0);
	glVertex2i(0, 1);
	glVertex2i(1, 1);
	glVertex2i(1, 0);
glEnd();

glEnable(GL_DEPTH_TEST);
glPopMatrix();
glPopAttrib();

glEnable(GL_LIGHTING);
glDisable(GL_STENCIL_TEST);
glShadeModel(GL_SMOOTH);
glDisable(GL_CULL_FACE);

And I run that every frame. I have a feeling it's a problem in how I arranged the various gl*() commands. Only the large, screen-covering shadow is drawing with no parts being cut out.

Sponsor:

#2 owl   Banned   -  Reputation: 364

Like
0Likes
Like

Posted 10 May 2011 - 08:23 PM

This is not the answer to your problem but it might help. You may want to set up two little test programs, one running Nehe's code and the other one running your own. Then spot the parts that are different. It's very likely that it is there where your bug lies in. Once you detect the bug you might even be able to understand the "why".
I like the Walrus best.

#3 aviel   Members   -  Reputation: 100

Like
0Likes
Like

Posted 10 May 2011 - 08:25 PM

I appreciate the advice, but I can assure you I've done that. I don't post for advice on fora just because my code didn't compile the first time and I'm too lazy to check what "missing semicolon on line 13" means.

I have actually copied most of his code verbatim, and the parts that aren't his I have tested work. Although I suppose there must be some part of that statement that is false, seeing as shadows don't display :)

#4 owl   Banned   -  Reputation: 364

Like
0Likes
Like

Posted 10 May 2011 - 08:30 PM

I'm just about to start making my own implementation of this lesson myself. If I get to understand more after I'm done I might come back with some actual help. In the meantime I hope someone can lay you a hand.
I like the Walrus best.

#5 aviel   Members   -  Reputation: 100

Like
0Likes
Like

Posted 10 May 2011 - 09:02 PM

Thanks, I appreciate it. Still can't figure out why it isn't working :/




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.



PARTNERS