Hiya,
Im trying to experiment with VBO’s and Ive come a bit unstuck, I found a tutorial and tried to get it to work with glut but i keep getting the error “instruction at “0x00000000” referenced to memory at “0x00000000”. the memory could not read”
ive tried using printf to help me debug it, and I think the error is on this line “glGenBuffersARB(1, &buffer);” as it crashes at this line
can anyone tell me what im doing wrong??
thanks
David
#include <GL/glut.h>
#include <stdlib.h>
#include <stdio.h>
#include <GL/glu.h>
#include "glext.h"
GLfloat data[] = { -1.0f, 1.0f, 0.0f,
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f };
GLuint buffer;
PFNGLBINDBUFFERARBPROC glBindBufferARB = NULL;
PFNGLGENBUFFERSARBPROC glGenBuffersARB = NULL;
PFNGLBUFFERDATAARBPROC glBufferDataARB = NULL;
void init(void)
{
// enable depth testing
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glEnableClientState(GL_VERTEX_ARRAY);
glClearColor(0.5f, 0.5f, 1.0f, 1.0f);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -3);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer);
glVertexPointer(3, GL_FLOAT, 0, 0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
}
void reshape(int w, int h)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, (float) 640 / (float) 480, 1, 512);
}
int main(int argc, char **argv)
{
glBindBufferARB = (PFNGLBINDBUFFERARBPROC)wglGetProcAddress("glBindBufferARB");
printf("1
");
glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)wglGetProcAddress("glGenBuffersARB");
printf("2
");
glBufferDataARB = (PFNGLBUFFERDATAARBPROC)wglGetProcAddress("glBufferDataARB");
printf("3
");
glGenBuffersARB(1, &buffer);
printf("4
");
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer);
printf("5
");
glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(data), data, GL_STATIC_DRAW_ARB);
printf("6
");
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize(640, 480);
glutInitWindowPosition(100, 100);
glutCreateWindow(argv[0]);
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}