#163651 - sarachiel - Tue Oct 07, 2008 9:00 pm
Hi people,
I'm trying to have a nice 3d 'engine' on my ds. I read, understood (I hope so), and practiced every single tutorial and example I could find in the libnds examples.
I managed to draw some nice stuff using classical glBegin() glNormal() glVertex() glTexcoord() glEnd() routines. I am now using 3d models drawn with Blender and exported to a format supported by the 'NDSMeshConverter' provided by PadrinatoR. I fix the model using Antonio's work (every tool provided by his NitroEngine actually). This worked perfectly well for my models (I drew and animated some nice characters etc...), until I tried to apply textures on it.
I don't use any kind of filesystem library, every item is a .bin file compiled with the rest of my NDS file.
My problem is - yeah noobish - that textures don't get drawn when I use display lists :/
My guess is that it is my list that is flawed, since it works just fine with glBegin() etc... But how can I be sure of that ? Is there a tool or method that you suggest me to adopt to continue my work or check that my models are correctly built? My hair will all be gone soon :(
This is the last step for me before I begin the real work on my homebrew !
By the way, a friend of mine asked what was better using display lists instead of simple glVertex sequences. I once saw detailed informations about this that I can't find anymore, any clue ?
Regards
#163655 - silent_code - Tue Oct 07, 2008 9:33 pm
Using displaylists are the way to go, if you get serious.
I managed to half the framerate because of too many "immediate mode" commands in the graphics command fifo, despite the fact, that I didn't even get close to the vertex and primitive limits... which wouldn't cause a frame drop anyway. ;^)
There's a thread about it somewhere on this forum. Please search.
Btw: You don't "draw" meshes and models (at least not in the context you used it), but you "model" them. :^)
_________________
July 5th 08: "Volumetric Shadow Demo" 1.6.0 (final) source released
June 5th 08: "Zombie NDS" WIP released!
It's all on my page, just click WWW below.
#163666 - sarachiel - Wed Oct 08, 2008 12:08 pm
Yeah I don't have any vocabulary about this. I try to learn by myself, which is driving me mad these days. I found what I wanted to know about display lists, but not about textures.
How the hell am I supposed to understand every specificity of the textures and how they work ? I understand 1 word on 2 in other threads. Libnds examples just work fine, but I found that, for example, glInit() has some weird behaviour when global variables aren't in the same file or something. My textures that I used in 'immediate mode' were drawn awkwardly if my texture-loading function was in another .c file (despite the global array being in the .h).
I even can't see what steps I should follow. I just don't get it. I mean, I do the exact same way to load textures as in 'immediate mode' and it stops working when I use my display list instead. I don't even know how I can check if the problem comes from my .bin file or my code ... doh nvm.
#163667 - Dwedit - Wed Oct 08, 2008 1:04 pm
Wait, are you declaring global variables in .h files and not making them extern?
The rule is declare them once in any .c file, then anything else that refers to the same variable should be declared as 'extern'.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."
#163669 - elhobbs - Wed Oct 08, 2008 1:32 pm
Dwedit wrote: |
Wait, are you declaring global variables in .h files and not making them extern?
The rule is declare them once in any .c file, then anything else that refers to the same variable should be declared as 'extern'. |
I think he is referring to the definition of glGlob in videoGL.h which is declared as static. Code: |
// Pointer to global data for videoGL
static gl_hidden_globals* glGlob = 0;
|
so it makes a new instance in each file it is included in - this breaks some of the defines which reference this variable. glClearColor,glClearPolyID,glGetInt, and glTexCoord2f.
sarachiel - if you were using glTexCoord2f or glTexCoord2f32 then keep in mind that these functions are converting your values into ds texture coordinate format for you based on the selected texture. For display lists you will need to convert the coordinates yourself.
#163671 - sarachiel - Wed Oct 08, 2008 1:45 pm
elhobbs wrote: |
if you were using glTexCoord2f or glTexCoord2f32 then keep in mind that these functions are converting your values into ds texture coordinate format for you based on the selected texture. For display lists you will need to convert the coordinates yourself. |
I was indeed referring to glGlob. I had the problem when using glTexCoord2f yes, but not display list at that time.
I don't understand what you mean by "converting the coordinates myself" when using Display lists. What do you call "ds texture coordinate format" ? With fixed points coordinates ?
By the way, about glGlob, what should I do to avoid what I described? More important, what can I do to take advantage of it ?
#163674 - elhobbs - Wed Oct 08, 2008 4:40 pm
sarachiel wrote: |
I was indeed referring to glGlob. I had the problem when using glTexCoord2f yes, but not display list at that time.
I don't understand what you mean by "converting the coordinates myself" when using Display lists. What do you call "ds texture coordinate format" ? With fixed points coordinates ?
By the way, about glGlob, what should I do to avoid what I described? More important, what can I do to take advantage of it ? |
yes, it is a fixed point value. however, unlike opengl the value does not use 0.0 to 1.0 it uses 0 to texture width (in 12.4 fixed point). if you look at the definition of glTexCoord2f in videoGL.h you will see that it extracts the texture dimensions from the texture object and multiplies.
I am not sure what you mean by take advantage, but you either rewrite the macros that need glGlob (the ones I listed previously) or you can initialize glGlob in all of the files that reference it Code: |
glGlob = glGetGlobals();
|
however, this must be done after glInit has been called at least once.