glInterleavedArrays problem

Started by
7 comments, last by rpg_code_master 20 years, 3 months ago
Hello, i''m having a problem with the funciton glInterleavedArrays. When the program runs and it gets to this method, it says someting about not being able to read from location 0x00000000, the call stack says that we are in ONLY in function 00000000(). The code i''m using is here, static float f[] = { 1.0f, 1.0f, -10.0f, 1.0f, -1.0f, -10.0f, -1.0f, -1.0f, -10.0f, -1.0f, 1.0f, -10.0f, }; glInterleavedArrays( GL_V3F, 0, f ); float v[ 4 ] = { 0,1,2,3 }; glDrawElements( GL_QUADS, 0, v ); Ignore the varible names, heh. I have tried the varible f not static, it makes no difference. Is there any thing that I need to enable or something, or is glInterleavedArrays a function pointer that I need to init. I have no idea. Thanks for you help in advance :D
Advertisement
First of all, your draw elements function is missing a parameter, it should look something like this:

glDrawElements(GL_QUADS, 1, GL_UNSIGNED_INT, v);

(1 being the number of quads)

If that is not the problem, than it may be because the array pointers you are giving openGL are local. This has caused me problems in the past. Try using global arrays, and see if that works.

Hope that helps, good luck.
oh yeah, and your v[] is an array of indices, so they should be unsigned integers, not floats.
quote:Original post by odiousangel
First of all, your draw elements function is missing a parameter, it should look something like this:

glDrawElements(GL_QUADS, 1, GL_UNSIGNED_INT, v);

(1 being the number of quads)

The second parameter is the number of indices in the index array, not the number of primitives to draw. So it should be 4, not 1.
doh

-----------------------------
I never chew my cabbage twice
The funciton parameters were all correct and i tried using global arrays but still to no avail. The arrays i''m using work with the other VA funcitons glVertexPointer etc... but not with the glInterleavedArrays method.

With global arrays, i still get the same error.

An ideas...
It kinda sounds to me like your problem is not OpenGL related. Calling member functions from uninitialized or null objects can have strange behavior (such as the code executing with one set of instructions, but excepting with another set).

If this code is inside of a class member function, try setting a breakpoint on glInterleavedArrays, and checking your ''this'' pointer before you call it, and make sure it is not NULL.

If it''s not, step through the commands and find out exactly which call is triggering the error.

It your ''this'' is NULL, then you are not properly initializing whatever object this method is in. And just because the other method worked doesn''t mean this isn''t the case, calling methods of uninitialized objects is undefined behavior, and will sometimes execute without error, and sometimes not.


Also, use the debugger to check the values of your variables that you are passing into a function right before you call it, to make certain the data that is being passed in is what you think is being passed in. With variable names like f and v it''s easy to run into scope conflicts from variables declared in header files that you don''t even know are being used.

Peace
The varible names arn''t f and v, i just used them because it''s easyer to type them then m_pfCoord etc...

I don''t think that it could be the ''this'' pointer due to the fact that other functions are called in the same method.

When i run through the code, the array with the data had all of the data in it upon passing it in.
I think you missed the part about undefined behavior other functions being called don't mean anything, i've had methods from uninitialized objects running for hours before an error occurred. It all depends on what else is going on, and what memory you are accessing at what time.

Anyway, if you haven't checked to be sure, try this:

if (this != NULL && this != 0xcdcdcdcd && this != 0xbaadf00d){   glInterleavedArrays( GL_V3F, 0, f );   int v[4] = { 0,1,2,3 };   glDrawElements( GL_QUADS, 4, 0, v );}


Run it in debug mode and see if it still crashes.

Otherwise, you'll probably need to post your actual code, hard to troubleshoot something when the code you post is so different from what you are actually using. Just cut and paste that method from your editor.

Peace

[edited by - krippy2k on January 19, 2004 9:32:13 AM]

This topic is closed to new replies.

Advertisement