# glVertexPointer with stride.

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

## 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 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 on other sites
Oki... that is working nice! :)

Thank you!

##### 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.

1. 1
2. 2
Rutin
23
3. 3
JoeJ
20
4. 4
5. 5
gaxio
13

• 24
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631734
• Total Posts
3001933
×