Jump to content
  • Advertisement
Sign in to follow this  

OpenGL VBO problem

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

Ok I dont fucking get it.
I have a global variable

unsigned int boxVBO;
//unsigned int boxVBO = 0; //still doesnt work

Then after I have created my window and initialized opengl I call the function buildBoxPrim()

SVertex *vertices = new SVertex[20];

vertices[0].Fill(-1.0f, -1.0f, -1.0f);
vertices[1].Fill( 1.0f, -1.0f, -1.0f);
vertices[2].Fill( 1.0f, -1.0f, 1.0f);
vertices[3].Fill(-1.0f, -1.0f, 1.0f);
vertices[4].Fill(-1.0f, -1.0f, 1.0f);
vertices[5].Fill( 1.0f, -1.0f, 1.0f);
vertices[6].Fill( 1.0f, 1.0f, 1.0f);
vertices[7].Fill(-1.0f, 1.0f, 1.0f);
vertices[8].Fill(-1.0f, -1.0f, -1.0f);
vertices[9].Fill(-1.0f, 1.0f, -1.0f);
vertices[10].Fill( 1.0f, 1.0f, -1.0f);
vertices[11].Fill( 1.0f, -1.0f, -1.0f);
vertices[12].Fill( 1.0f, -1.0f, -1.0f);
vertices[13].Fill( 1.0f, 1.0f, -1.0f);
vertices[14].Fill( 1.0f, 1.0f, 1.0f);
vertices[15].Fill( 1.0f, -1.0f, 1.0f);
vertices[16].Fill(-1.0f, -1.0f, -1.0f);
vertices[17].Fill(-1.0f, -1.0f, 1.0f);
vertices[18].Fill(-1.0f, 1.0f, 1.0f);
vertices[19].Fill(-1.0f, 1.0f, -1.0f);

glGenBuffersARB( 1, &boxVBO );//get VBO name
//glBindBufferARB( GL_ARRAY_BUFFER_ARB, boxVBO ); // Bind The Buffer
//glBufferDataARB( GL_ARRAY_BUFFER_ARB, 20*3*sizeof(float), vertices, GL_STATIC_DRAW_ARB );

delete []vertices;
vertices = NULL;

I have commented the function because I though they were making my program crash but no. It is glGenBuffersARB. I don't know why this happens. No other VBO functions are called.
This is my vertex class.

struct SVertex
GLfloat x, y, z;
void Fill(float _x, float _y, float _z){
x = _x;y = _y;z = _z;

I used a function I found @ opengl's site to check if I supported VBO and I did :(.
Tried including glext.h didn't help. Then I went to nehe's site and added the following to my code

#define GL_ARRAY_BUFFER_ARB 0x8892
#define GL_STATIC_DRAW_ARB 0x88E4
typedef void (APIENTRY * PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer);
typedef void (APIENTRY * PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers);
typedef void (APIENTRY * PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers);
typedef void (APIENTRY * PFNGLBUFFERDATAARBPROC) (GLenum target, int size, const GLvoid *data, GLenum usage);

// VBO Extension Function Pointers
PFNGLGENBUFFERSARBPROC glGenBuffersARB = NULL; // VBO Name Generation Procedure
PFNGLBUFFERDATAARBPROC glBufferDataARB = NULL; // VBO Data Loading Procedure
PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB = NULL; // VBO Deletion Procedure

Still didn't work :S. What am I doing wrong here.

Share this post

Link to post
Share on other sites
How and where do you load your extension functions? Are you loading them after the window is created as well, and do you do it manually or with an external library? Are VBO supported by your implementation? Have you tried the core functions (glGenBuffers) and not the old extensions (glGenBuffersARB)?

Share this post

Link to post
Share on other sites
Never mind forgot to call
glGenBuffersARB = (PFNGLGENBUFFERSARBPROC) wglGetProcAddress("glGenBuffersARB");
glBindBufferARB = (PFNGLBINDBUFFERARBPROC) wglGetProcAddress("glBindBufferARB");
glBufferDataARB = (PFNGLBUFFERDATAARBPROC) wglGetProcAddress("glBufferDataARB");
glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) wglGetProcAddress("glDeleteBuffersARB");


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!