• Advertisement

Archived

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

Trouble wrapping Vertex Arrays

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

I think I'm doing everything right but nothing is being rendered. Here is the code : Header File
#ifndef _v_primitive_h
#define _v_primitive_h

#include <gl/glfw.h>



class VEHEMENT_PRIMITIVE
{

     protected :
     
        GLenum colorType;
        GLvoid * colorData;
        
        GLenum vertexType;
        GLvoid * vertexData;

     public :
     
        GLvoid Color(GLenum, GLvoid*);
        GLvoid Vertex(GLenum, GLvoid*);       
       
        GLvoid Render(GLenum, GLubyte, GLubyte);


};



#endif
Source Code
   
#include <gl/glfw.h>
#include "V_Primitive.h"



GLvoid VEHEMENT_PRIMITIVE::Color( GLenum p_Mode, GLvoid * p_Color )
{

     colorType = p_Mode;
     colorData = p_Color;
}

GLvoid VEHEMENT_PRIMITIVE::Vertex( GLenum p_Mode, GLvoid * p_Color )
{

     vertexType = p_Mode;
     vertexData = p_Color;
}

GLvoid VEHEMENT_PRIMITIVE::Render( GLenum p_Mode, GLubyte p_Start, GLubyte p_Finish )
{

     static GLint count = p_Finish - p_Start;
     GLubyte indices[ count ];

     glEnableClientState( GL_COLOR_ARRAY );
     glColorPointer( 3, colorType, 0, colorData );
     
     glEnableClientState( GL_VERTEX_ARRAY );
     glVertexPointer( 3, vertexType, 0, vertexData );
     
     for( GLint counter = p_Start; counter < p_Finish - 1; counter++ )
        indices[ counter ] = (GLubyte)counter;
        
     glDrawElements( p_Mode, count, GL_UNSIGNED_BYTE, indices );
     
     glDisableClientState( GL_VERTEX_ARRAY );
     glDisableClientState( GL_COLOR_ARRAY );
}
Jehovah is viewed by Gnostics as fundamentally evil, jealous, rigid, lacking in compassion and prone to genocide. [edited by - Demiurge666 on May 8, 2004 11:49:09 PM] [edited by - Demiurge666 on May 8, 2004 11:50:04 PM]

Share this post


Link to post
Share on other sites
Advertisement
Are you making sure not to delete the vertex data after you call Color(...) or Vertex(...)?

[edited by - Ostsol on May 8, 2004 12:36:37 AM]

Share this post


Link to post
Share on other sites
Nope. I''m not deleteing the data AT ALL.

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
Anyone has any idea at all?

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
This is how I''m using it :


GLfloat g_Vertices[3][3];
GLubyte g_Color[3][3];



GLvoid BuildArray( )
{

g_Color[0][0] = 255;
g_Color[0][1] = 0;
g_Color[0][2] = 0;

g_Color[1][0] = 255;
g_Color[1][1] = 255;
g_Color[1][2] = 0;

g_Color[2][0] = 255;
g_Color[2][1] = 255;
g_Color[2][2] = 255;

g_Vertices[0][0] = -1.0f;
g_Vertices[0][1] = -1.0f;
g_Vertices[0][2] = 0.0f;

g_Vertices[1][0] = 1.0f;
g_Vertices[1][1] = -1.0f;
g_Vertices[1][2] = 0.0f;

g_Vertices[2][0] = 0.0f;
g_Vertices[2][1] = 1.0f;
g_Vertices[2][2] = 0.0f;
}

GLint main(void)
{

VEHEMENT_PRIMITIVE * VehementDraw;

VehementDraw->Color( GL_UNSIGNED_BYTE, (GLvoid*)g_Color );
VehementDraw->Vertex( GL_FLOAT, (GLvoid*)g_Vertices );

// Begin Main Loop

VehementDraw->Render( GL_TRIANGLES, 0, 3 );
// End Main Loop

}



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
bump

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
Guest Anonymous Poster
make sure you are flipping the buffers

Share this post


Link to post
Share on other sites
I am flipping the buffer and I hardcoded the original data types and still no success. What the heck is wrong?

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 took your code, tested it, and it''s working for me. Here''s what''s in my render loop:

glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity ();

glTranslatef (0.0f, 0.0f, -30.0f);

pVertexArray->Render (GL_TRIANGLES, 0, 3);

SwapBuffers(hDC);

Share this post


Link to post
Share on other sites
*sigh* This is depression. I''ve rewritten the class and now my program crashes. Pointer issues. I''m debugging it as we speak...

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

  • Advertisement