Skip to main content
GameDev.net gamedev.net
🔒 Locked

VBO problem

Started by Solano Apr 8, 2011 at 8:34 AM 1 replies 1.5k views
Original Post
Solano
Solano
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
PFNGLBINDBUFFERARBPROC glBindBufferARB = NULL; // VBO Bind 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.
Brother Bob
Brother Bob
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)?
Solano
Solano
Never mind forgot to call
glGenBuffersARB = (PFNGLGENBUFFERSARBPROC) wglGetProcAddress("glGenBuffersARB");
glBindBufferARB = (PFNGLBINDBUFFERARBPROC) wglGetProcAddress("glBindBufferARB");
glBufferDataARB = (PFNGLBUFFERDATAARBPROC) wglGetProcAddress("glBufferDataARB");
glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) wglGetProcAddress("glDeleteBuffersARB");

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.