Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Demiurge666

........Vertex Array Issue..........don't laugh

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

Hello Fello Citizens of GameDev.net!! I've sailed across many seas to reach such a joyful kingdom! Atlast I've found it!! I've found the wonderful, magical kingdom of gamedev.net!! A million apoligies for my bright existence. My golden presence has aluminated your atmosphere more so than the sun could ever achieve! I've encountered such inadmissible conflict. Jehovah is viewed by Gnostics as fundamentally evil, jealous, rigid, lacking in compassion and prone to genocide.
   GLubyte g_ColorArray[ PARAMETER ][3];
   GLfloat g_VertexArray[ PARAMETER ][3];
   GLubyte g_IndexArray[ PARAMETER ];



GLvoid BuildArrays( )
{

     GLfloat b_x = 0.0f, b_z = 0.0f;

     for( GLfloat degree = 0.0f; degree < PARAMETER; degree++ )
     {
     
        GLint index = GLint(degree);
        b_x = GLfloat( RADIUS * cos(degree) );
        b_z = GLfloat( RADIUS * sin(degree) );
        
        g_ColorArray[ index ][0] = 255;
        g_ColorArray[ index ][1] = 255;
        g_ColorArray[ index ][2] = 255;
        
        g_VertexArray[ index ][0] = b_x;
        g_VertexArray[ index ][1] = 5.0f;
        g_VertexArray[ index ][2] = b_z;
        
        g_IndexArray[ index ] = index;
     }

}

GLvoid RenderPoints( )
{

     glEnableClientState( GL_COLOR_ARRAY );
     glEnableClientState( GL_VERTEX_ARRAY );
     
     glColorPointer( 3, GL_UNSIGNED_BYTE, 0, g_ColorArray );
     glVertexPointer( 3, GL_FLOAT, 0, g_VertexArray );
     
     glEnable( GL_POINT_SMOOTH );  // Anti-aliasing

     
     glPointSize( 20.0f );
     glDrawElements( GL_POINT, PARAMETER, GL_UNSIGNED_BYTE, g_IndexArray );
     
     glDisable( GL_POINT_SMOOTH );
     
     glDisableClientState( GL_COLOR_ARRAY );
     glDisableClientState( GL_VERTEX_ARRAY );
}
I build the arrays in my initiation function and render the points with my mainloop(so its called every frame). I'm trying to plot points to form a circle using vertex arrays. It isn't rendering ANY points at all. What is wrong? [edited by - Demiurge666 on April 12, 2004 6:45:24 PM]

Share this post


Link to post
Share on other sites
Advertisement
quote:

Will you be buried here among the dead in silent secret?


No young Soldier!! I shall present my inadmissible conflict shortly.


Jehovah is viewed by Gnostics as fundamentally evil, jealous, rigid, lacking in compassion and prone to genocide.

Share this post


Link to post
Share on other sites
Aha ! I have a few suggestions - each is seemingly stupid but which i fall into ALL the time !

1. are you sure you''re actaully looking at this object - if your gluPerspective function is looking elsewhere then you won''t see it ! Double check !

2. -ve z is into the page - if it''s drawn with +ve z values then you''ll have to turn around your camera.


3. Ahem, in the c math library sin and cos are in radians and not degrees. What you are drawing won''t look anything like you think. There are 2*pi rads in a circle. Therefore one degree is 2pi/360 = about 0.01 radians !
1 radian (which is what you''re plotting) is 57 degrees !
360/(pi*2).

cheers





Share this post


Link to post
Share on other sites
Also, I couldn''t help but think you should pass the vertex arrays in at initialisation rather than on rendering the scene each time - from what I know (notmuch !) vertex arrays are stored in faster to access memory - which sort of means its a bit silly passing them all in 20 times a second - on big scenes I''m guessing it will slow down the rendering.

cheers


Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If by "passing in" you mean the gl*Pointer() methods, then no, he is using them correctly. These methods don''t actually represent a transfer of data in memory, all they are is setting a pointer to the block of memory that will be rendered when the corresponding multi/draw/elements/arrays function is called.

Share this post


Link to post
Share on other sites
I have a camera so I''m able to move around in my 3D environment. I don''t see it anyway man. I made it so that the circle would be near(or around) the original. NOTHING is being plotted. Its either bad math of something wrong with the vertex arrays.

BTW : My math is correct. I used that same equation in my other OpenGL demo and it plotted points in circular order(my other demo was done w/o vertex arrays). So I doubt its my math.

Jehovah is viewed by Gnostics as fundamentally evil, jealous, rigid, lacking in compassion and prone to genocide.

Share this post


Link to post
Share on other sites
Here is my new code. It still doesn''t work. What the hell is going on?


#define PI 3.1428571428571428571428571428571f
#define RADIUS 5
#define PARAMETER 2 * RADIUS * PI
#define MAX_INDICES GLint(PARAMETER * PARAMETER)

GLubyte g_ColorArray[ MAX_INDICES ][3];
GLfloat g_VertexArray[ MAX_INDICES ][3];
GLubyte g_IndexArray[ MAX_INDICES ];



GLvoid BuildArrays( )
{

GLfloat converter = 0.0174532925;
GLfloat b_x = 0.0f, b_z = 0.0f;
GLfloat angle = 0.0f;

for( GLint index = 0; index < MAX_INDICES; index++ )
{

angle = GLfloat(index);

b_x = GLfloat( RADIUS * cos(angle * converter) );
b_z = GLfloat( RADIUS * sin(angle * converter) );

g_ColorArray[ index ][0] = 255;
g_ColorArray[ index ][1] = 255;
g_ColorArray[ index ][2] = 255;

g_VertexArray[ index ][0] = b_x;
g_VertexArray[ index ][1] = 5.0f;
g_VertexArray[ index ][2] = b_z;

g_IndexArray[ index ] = index;
}

}

GLvoid RenderPoints( )
{

glEnableClientState( GL_COLOR_ARRAY );
glEnableClientState( GL_VERTEX_ARRAY );

glColorPointer( 3, GL_UNSIGNED_BYTE, 0, g_ColorArray );
glVertexPointer( 3, GL_FLOAT, 0, g_VertexArray );

glEnable( GL_POINT_SMOOTH ); // Anti-aliasing


glPointSize( 20.0f );
glDrawElements( GL_POINT, MAX_INDICES, GL_UNSIGNED_BYTE, g_IndexArray );

glDisable( GL_POINT_SMOOTH );

glDisableClientState( GL_COLOR_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
}



The reason why I squared the circumference is because if I used parameter/circumference rather than its square it''ll plot an incomplete circle.

NOTE : Parameter is the same as circumference.

Jehovah is viewed by Gnostics as fundamentally evil, jealous, rigid, lacking in compassion and prone to genocide.

Share this post


Link to post
Share on other sites
I dont understand why you squared parameter, but now that you're converting to radians, you must leave PARAMETER as 360.

[edited by - cozman on April 14, 2004 3:55:11 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!