gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > [SOLVED] CALL glInit() *BEFORE* USING gl[whatever]() !

#157898 - silent_code - Sun Jun 01, 2008 2:25 pm

hi there!

first of all: i have searched the forum for this and coudln't find anything that helped me. that doesn't mean that it isn't out there, burried in some thread, though! so, if you have a link to a simmilar topic, please post it.

this has already cost me a day worth of coding and it's making me nuts!
it's very important that i get this done very soon, so: *please*, help me.

i've been updating my volume shadow demo and my texture loading code, that worked with older libnds versions (i can't remember which one it was, as it's been a while and i've updated libnds a few times since), will hang the hw on the following lines (although the *free* version for no$gba 2.6 will not show any error, but won't display textures, just colored and lighted geometry):

Code:
   glGenTextures(1, &dolltex); // will definitely hang the hw
   glBindTexture(0, dolltex); // possibly, too, because of the first one
   glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_256 , TEXTURE_SIZE_256, 0, TEXGEN_TEXCOORD | GL_TEXTURE_WRAP_S | GL_TEXTURE_WRAP_T, (uint8 *)pTexData); // well, i really don't know, but chances are, that this screws up, too, due to the others not working

dolltex is a global 'int' and pTexData is a local 'uint16' pointer (to 16bit texture data.)
if i insert infinite loops ( while(true){} ) before each line, the first loop will be entered and the hw will not hang (i can tell that by printing something out to the screen.) as i remove the loop before the first line, the hw will hang.
what is going on?
how can this possibly be?
has anyone else seen this behaviour?

any advise / hint / (constructive) criticism is appreciated. :^D

as the project is open source anyways, i can make the current sources availabe, if needed, but i don't think i am doing anything wrong! :^(

EIDT: i also have to note that i've been and still am loading textures in the main function (adding wait for vblank doesn't help here.)
_________________
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.


Last edited by silent_code on Mon Jun 02, 2008 12:26 am; edited 1 time in total

#157919 - elhobbs - Sun Jun 01, 2008 11:21 pm

make sure you have called glInit before you use any of the gl* functions. there is a global variable "glGlob" that gets initialized during this call and it is referenced by a lot of the gl functions. this is different behaviour then some of the older libnds versions.

#157923 - silent_code - Mon Jun 02, 2008 12:25 am

and the Oscar goes toooo.... elhobbs!
thank you man! i didn't even know of that function! thank you, thank you, thank you, thank *YOU*!

:^)

seriously, that's why i "LOVE" this community! there's always someone around when you're in trouble - collective knowledge rules! :^D

case closed. :^)
(thank you!)
_________________
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.

#157939 - simonjhall - Mon Jun 02, 2008 7:44 am

Yeah that one bit me in the arse months back. This is why we need asserts in libnds!
_________________
Big thanks to everyone who donated for Quake2