glDrawElements and Face indices - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: glDrawElements and Face indices (/thread-619.html)
glDrawElements and Face indices - Ashford - Nov 7, 2009 12:03 PM
i was working on a program that dynamically allocates a multidimensional array in the form of a pointer-to-pointer (**) to store the face indices for glDrawElements(), however when I try to use the pointer -to-pointer for the fourth parameter in glDrawElements() nothing shows up on the screen. I have also tried statically allocating a multidimensional array (not a pointer-to-pointer) to store the face indices and it works, and both the dynamically allocated array and the statically allocated array are the exactly same, so i'm very confused as to what to do.
So can someone please help me?
here is a sample of the code that doesn't work:
Quote:/*Model is the name of a class which reads the mesh file and allocates the
Here is a sample of the code that does work:
Quote:here is a sample of the code that does work:
And also I am quite aware of the fact that arrays start counting at 0 and that the array of face indices start counting from 1
glDrawElements and Face indices - wyrmmage - Nov 7, 2009 04:14 PM
I have a feeling I may be getting mixed up here, but....
That's probably not it, but sticking a a call to glGetError() and seeing what you get might hint at what's wrong
glDrawElements and Face indices - OneSadCookie - Nov 7, 2009 08:46 PM
You can't use pointer-to-pointer multidimensional arrays for glDrawElements, it needs to a flat block of memory. Statically allocated multidimensional arrays in C are nothing like pointer-to-pointer arrays and far more like unidimensional arrays.
glDrawElements and Face indices - PowerMacX - Nov 8, 2009 07:21 AM
If you do end up using a flat array, and if all your faces are indeed composed of 4 vertices as in the sample code, you could do something like this:
glDrawElements and Face indices - Ashford - Nov 9, 2009 05:57 PM
I tried all three suggestions and I inched a little closer to getting it to work but I am still having one small problem. I decided to use integers instead of unsigned characters (since I would probably be using more than 11 vertices in my program and unsigned characters can't store values greater than 10) and I tried using glGetError() to shed some light on the situation, but instead of helping me, it actually crashes the program.
As for my problem, nothing shows up on screen when I try to use GL_INT for the type parameter of glDrawElements() and I dont quite know why this happens and its not just with glDrawElements(). I also noticed that anytime I try using integers with any OpenGL routine, it doesn't seem to work. For example, when I try changing the color with glColor3i() it doesn't work, so I was wondering if anyone can help me with this problem or at least offer some suggestions
So this is what the code looks like currently:
glDrawElements and Face indices - OneSadCookie - Nov 10, 2009 09:05 AM
You can't make OpenGL calls without an OpenGL context.
GL_INT is not a valid type for indices.
glDrawElements and Face indices - Ashford - Nov 10, 2009 03:04 PM
so is there any way to call glDrawElements() with integer values?
And by the way I actually tried using unsigned characters instead of integers with the new piece of code and it still doesn't work , so actually I am still lost.
glDrawElements and Face indices - AnotherJake - Nov 10, 2009 04:39 PM
GL_UNSIGNED_SHORT works, but it sounds like you have some other issue going on here.
glDrawElements and Face indices - Ashford - Nov 11, 2009 03:03 PM
I actually got to work with GL_UNSIGNED_INT yesterday and the mesh actually showed up on the screen, so everythings fine now.