Sign in to follow this  

glVertexPointer with stride.

This topic is 4309 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

Hi. Im trying to implement z-fail shadows. I planing to create a shadow matrix to apply on the geometry to close the back capping. But I need to set the 'w' to 0.0f. So I'm trying to load my vertex data as V4D and then set w = 0.0f at loading time. But when I what to render my geometry the usual way, I need to set w = 1.0f. But I dont want to reloading the data to memory. It would be to expencive. I thought I might use the 'stride' in glVertexPointer, to render my 4D vertices as 3D vertices. And not have to change the actual data. (I'm using glDrawElements) But I can't find out how to do it... :(

Share this post


Link to post
Share on other sites
There's no reason why glVertexPointer shouldn't work for you. Have you tried:
glVertexPointer(3, GL_FLOAT, 4 * sizeof(float), ptr);


The size setting (3) only reads XYZ data while the stride setting allows the W component to be skipped in memory.

Share this post


Link to post
Share on other sites
this is a common problem with the gl*pointer functions - people assume that the stride value is the amount of data to skip, where as in fact it's the amount of data to skip AND the amount of data to send.

Share this post


Link to post
Share on other sites

This topic is 4309 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this