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
[CODE]
#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\n");
glGenBuffersARB =
(PFNGLGENBUFFERSARBPROC)wglGetProcAddress("glGenBuffersARB");
printf("2\n");
glBufferDataARB =
(PFNGLBUFFERDATAARBPROC)wglGetProcAddress("glBufferDataARB");
printf("3\n");
glGenBuffersARB(1, &buffer);
printf("4\n");
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer);
printf("5\n");
glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(data), data,
GL_STATIC_DRAW_ARB);
printf("6\n");
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;
}
[/CODE]
|
|
0
|
|
|
|
Reply
|
googlinggoogler (44)
|
3/28/2005 7:18:39 PM |
|
googlinggoogler@hotmail.com wrote:
> 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??
You're not checking the function pointer returned by
wglGetProcAdress for being not NULL. Additionally you need a
valid context which is _after_ a GLUT Window has been created
with glutCreateWindow. The best is to do such stuff immediately
before calling glutMainLoop();
--
Wolfgang Draxinger
|
|
0
|
|
|
|
Reply
|
Wolfgang
|
3/28/2005 7:29:54 PM
|
|
<googlinggoogler@hotmail.com> wrote in message
news:1112037518.964258.239230@z14g2000cwz.googlegroups.com...
> 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
>
>
> [CODE]
>
> #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");
You are not checking for errors here.
> printf("1\n");
> glGenBuffersARB =
> (PFNGLGENBUFFERSARBPROC)wglGetProcAddress("glGenBuffersARB");
> printf("2\n");
> glBufferDataARB =
> (PFNGLBUFFERDATAARBPROC)wglGetProcAddress("glBufferDataARB");
> printf("3\n");
>
> glGenBuffersARB(1, &buffer);
what is 'buffer'?
Allan
|
|
0
|
|
|
|
Reply
|
Allan
|
3/28/2005 7:30:50 PM
|
|
Allan Bruce wrote:
> ...
>> GLuint buffer;
>>
>> PFNGLBINDBUFFERARBPROC glBindBufferARB = NULL;
>> PFNGLGENBUFFERSARBPROC glGenBuffersARB = NULL;
>> PFNGLBUFFERDATAARBPROC glBufferDataARB = NULL;
>>
>> void init(void)
> [...]
>>> glGenBuffersARB(1, &buffer);
>
> what is 'buffer'?
It's the variable defined a few lines above init(). No problem
there. The real problem is, that the call to wglGetProcAddress
happens at a point, where no context has been created yet.
--
Wolfgang Draxinger
|
|
0
|
|
|
|
Reply
|
Wolfgang
|
3/28/2005 7:53:40 PM
|
|
Thank you! thats great ive moved a step further...
im having a new problem now though....
basically ive moved the "wglGetProcAddress" commands into my init()
function and ive dropped the "glGenBuffersARB, glBindBufferARB,
glBufferDataARB" to above the call to glutMainLoop()
Now im presented with a window that doesnt display anything and
basically crashes grabbing the screen from behind and holding this
within the frame and not displaying anything useful
Sorry to pesters I can't see the error thats all :-)
cheers!
David
|
|
0
|
|
|
|
Reply
|
googlinggoogler
|
3/28/2005 10:42:50 PM
|
|
googlinggoogler@hotmail.com wrote:
> Thank you! thats great ive moved a step further...
>
> im having a new problem now though....
>
> basically ive moved the "wglGetProcAddress" commands into my
> init() function and ive dropped the "glGenBuffersARB,
> glBindBufferARB, glBufferDataARB" to above the call to
> glutMainLoop()
>
> Now im presented with a window that doesnt display anything and
> basically crashes grabbing the screen from behind and holding
> this within the frame and not displaying anything useful
How about a glutSwapBuffers() at the end of display()? Also I'd
create a window with a depth buffer, since depth test is quite
useless without it, so
glutInitDisplayMode(GLUT_RGB|GLUT_DEPTH|GLUT_DOUBLE).
Also I suspect you want a lot model (because without you will
just see a "flat" silouhette). Then remember, that ligting
ignores glColor and expects the use of glMaterial, however for
conveniece you can link the call of glColor to one of the
glMaterial parameters, which can be quite usefull in combination
with glColorPointer.
I also recommend to set glViewport to the dimensions of the
window in reshape(). I very complex rendering situations you
normally do nothing else as this in reshape() and set the proper
projection, the depth test and other stuff in the display()
function. The reason is, that you might render different layers
with different rendering settings.
--
Wolfgang Draxinger
|
|
0
|
|
|
|
Reply
|
Wolfgang
|
3/29/2005 11:03:04 AM
|
|
> Now im presented with a window that doesnt display anything and
> basically crashes grabbing the screen from behind and holding this
> within the frame and not displaying anything useful
>
> David
Try Swapping the buffers ;-)
#include <GL/glut.h>
#include <stdlib.h>
#include <stdio.h>
#include <GL/glu.h>
#include <GL/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)
{
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glClearColor(0.5f, 0.5f, 1.0f, 1.0f);
glBindBufferARB = (PFNGLBINDBUFFERARBPROC)wglGetProcAddress("glBindBufferARB");
glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)wglGetProcAddress("glGenBuffersARB");
glBufferDataARB = (PFNGLBUFFERDATAARBPROC)wglGetProcAddress("glBufferDataARB");
if ((glBindBufferARB == NULL) || (glGenBuffersARB == NULL) ||
(glBufferDataARB == NULL)) {
printf("Does not support!");
exit(1);
}
glGenBuffersARB(1, &buffer);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(data), data,
GL_STATIC_DRAW_ARB);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, NULL);
}
void display(void)
{
glDrawBuffer(GL_BACK);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glTranslatef(0, 0, -3);
glColor3ub(0, 0, 0);
glEnableClientState(GL_VERTEX_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer);
glVertexPointer(3, GL_FLOAT, 0, 0);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, NULL);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableClientState(GL_VERTEX_ARRAY);
glutSwapBuffers(); // <----------------------
}
void reshape(int w, int h)
{
glViewport(0,0,w,h); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
gluPerspective(45, (float) 640 / (float) 480, 1, 512);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize(640, 480);
glutInitWindowPosition(100, 100);
glutCreateWindow("Test");
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
glutPostRedisplay();
return 0;
}
|
|
0
|
|
|
|
Reply
|
mlopes_filho
|
3/29/2005 1:10:03 PM
|
|
Cheers! im very gratefull :-) thats helped me no end, now I can do what
ive been wanting to do!
thank you!
David
|
|
0
|
|
|
|
Reply
|
googlinggoogler
|
3/29/2005 6:41:46 PM
|
|
|
7 Replies
326 Views
(page loaded in 0.088 seconds)
Similiar Articles: VBO help - comp.graphics.api.openglHiya, 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 ... single/multiple VBOs - comp.graphics.api.openglVBO help - comp.graphics.api.opengl... field in current record - comp.databases.ms ... help-how to merge multiple records into 1 ... VBOs vs Display Lists - lets test it ... GL_ARRAY_BUFFER_ARB vs. GL_ARRAY_BUFFER - comp.graphics.api.opengl ...VBO help - comp.graphics.api.opengl... glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer); glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(data), data, GL_STATIC_DRAW_ARB ... VBA and FileMaker - comp.databases.filemakerI beleive the VBA "equivalent" support for Filemaker Pro on the > Mac would be ... Word documents using Visual Basic for Applications (VBA ... ... VBA and FileMaker ... how to send special keyboard key (Alt_R,Shift_R,...) by C or Shell ...VBO help - comp.graphics.api.opengl 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 ... VBA create multiple fiield indexes - comp.databases.ms-access ...VBO help - comp.graphics.api.opengl VBA create multiple fiield indexes - comp.databases.ms-access ... Word documents using Visual Basic for Applications (VBA ... ... Macro Help? I think.... - comp.databases.ms-accessI think.... - comp.databases.ms-access FREE Excel VBA Code & Excel Macro Help Excel VBA: Excel VBA Macros. Free help ... VBO help - comp.graphics.api.opengl ... OpenGL extensions in VB - comp.graphics.api.openglI know only enough VB to find my way around the ... it's not quite correct - I mostly use C++): Part.Extension ... VBO help - comp.graphics.api.opengl... come a bit ... API:Get custom prop from referenced model - comp.cad.solidworks ...VBO help - comp.graphics.api.opengl... come a bit unstuck, I found a tutorial and tried to get ... Also I suspect you want a lot model (because without you ... Empty keyboard buffer - comp.lang.java.guiEmpty keyboard buffer - comp.lang.java.gui VBO help - comp.graphics.api.opengl ... How to Flush the Keyboard Typeahead Buffer - Microsoft Support The buffer implemented ... vba - Support - Office.com - Microsoft Corporation: Software ...Article Macros can help you automate repetitive tasks and save time. You can use the macro recorder to record the macro or write your own macro script in VBA. Bob's Excel VBA HelpSimple tips on creating VBA code for beginners. ... Introduction. This website is for those who are new to VBA programming and is designed to give some simple ... 7/24/2012 4:07:59 PM
|