Talk About Network

Google





Graphics > OpenGL 3D API > Re: drawing ele...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 10 Topic 4760 of 5061
Post > Topic >>

Re: drawing elements: why only one index buffer

by sheam <shea08@[EMAIL PROTECTED] > May 22, 2008 at 04:21 AM

> You're not forced to use glInterleavedArrays.
> 
> #include <stdint.h>
> typedef uint32_t colorRGBA;
> typedef struct Vector3d { GLfloat x,y,z; } Vector3d;
> typedev struct Vector2d { GLfloat u,v; } Vector2d;
> typedef struct Vertex
> {
>         Vector2d texcoord;
>         colorRGBA color;
>         Vector3d normal;
>         Vector3d coord;
> } Vertex;
> 
> void setVAPointer(Vertex *V)
> {
>         glVertexPointer(3, GL_FLOAT, sizeof(Vertex), &(V->coord));
>         glNormalPointer(GL_FLOAT, sizeof(Vertex), &(V->normal));
>         glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex),
> &(V->colorRGBA));
>         glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), &(V->texcoord));
> }

This is exactly what I am currently doing, but using Draw Arrays, not 
draw elements.  I'll switch my code up to use DrawElements, to try and 
take advantage of vertext caching.

> 
> In fact in most implementations glInterleavedArrays is just a
> shorthand for a arrangement of these calls.
> 
> Wolfgang Draxinger
> 
> P.S.: Note, that it's impossible in pure C/C++ without extensions
> to exactly define the memory layout of structs. Thank good most
> compilers provide pragmas/extensions to do this. Given this fact
> 

Can't this be acomplished with an __aligned__ tag in gcc?  I think there 
is a 'pack' pragma with visual C++, iirc.


Thanks for the insight,
~S
 




 10 Posts in Topic:
drawing elements: why only one index buffer
sheam <shea08@[EMAIL P  2008-05-21 02:38:47 
Re: drawing elements: why only one index buffer
fungus <openglMYSOCKS@  2008-05-20 19:52:38 
Re: drawing elements: why only one index buffer
sheam <shea08@[EMAIL P  2008-05-21 23:24:03 
Re: drawing elements: why only one index buffer
Wolfgang Draxinger <wd  2008-05-21 10:49:27 
Re: drawing elements: why only one index buffer
sheam <shea08@[EMAIL P  2008-05-21 23:32:01 
Re: drawing elements: why only one index buffer
Wolfgang Draxinger <wd  2008-05-22 02:55:23 
Re: drawing elements: why only one index buffer
sheam <shea08@[EMAIL P  2008-05-22 04:21:26 
Re: drawing elements: why only one index buffer
Wolfgang Draxinger <wd  2008-05-23 01:20:32 
Re: drawing elements: why only one index buffer
"jbwest" <jb  2008-05-21 17:55:50 
Re: drawing elements: why only one index buffer
fungus <openglMYSOCKS@  2008-05-21 17:58:30 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 14:35:07 PST 2009.