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 > Can't get clear colour to work for some reason.

#138153 - Dark Knight ez - Mon Aug 20, 2007 10:37 am

Hey all.

I've been working a small bit on getting AmplituDS up and running in the latest devkitpro setup and succeeded except for clear colour.
For some reason the clear colour shown remains black instead of the white I set it to.
I must have forgotten something, somewhere... going through the 3D examples of the current devkitpro setup, I fail to see what it is though, so I was hoping you guys could point me to what I'm missing.

My 3D initialization code (run only once):
Code:
    // initializing 3D is part of initializing scene
    glInit();
    glEnable(GL_ANTIALIAS);
    glEnable(GL_TEXTURE_2D);
   
    glViewPort(0,0,255,191);
   
    GFX_CLEAR_COLOR = 0; // some flashcards mess up and need this set to 0 before using
   
    glClearColor(255,255,255, 31);
    glClearPolyID(63);
    glClearDepth(0x7FFF);
   
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.0f, 256.0f / 192.0f, 0.1f, 100.0f);
   
    // ds specific, several attributes can be set here
    glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK);
   
    glPushMatrix();
   
    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();
   
    // Set the current matrix to be the model matrix
    glMatrixMode(GL_MODELVIEW);


The above doesn't mention the setting of the video mode and the setting of vram banks to textures, but that's all done too. Everything 3D works for me now, except for the clear colour...

Thanks in advance for any help.
_________________
AmplituDS website

#138157 - Lick - Mon Aug 20, 2007 11:39 am

Maybe silent_code's tip is of u se here.

http://forum.gbadev.org/viewtopic.php?p=121850#121850
_________________
http://licklick.wordpress.com

#138158 - Dark Knight ez - Mon Aug 20, 2007 11:59 am

Using
Code:
    GFX_CLEAR_COLOR = RGB15(255, 255, 255) | (31 << 16);

instead of
Code:
    glClearColor(255,255,255, 31);

didn't work for me.

I really doubt the alpha value in the glClearColor isn't set in GFX_CLEAR_COLOR, btw. The code in the CVS repository does it as suggested by silent_code, and although that could have changed since release 20, it makes no sense for release 20 to also have the alpha value as argument of glClearColor and not do anything with it.

Thanks for the suggestion though. I appreciate the effort.
_________________
AmplituDS website

#138160 - silent_code - Mon Aug 20, 2007 12:39 pm

well, i had the problem, too (with aa), but after examining libnds, that was the solution i came up with. ;)

EDIT: try setting the clear poly id to 0.
Code:
GFX_CLEAR_COLOR = RGB15(31, 31, 31) | (31 << 16) | (0 << 24);

ps: why would you use 255 in RGB15? isn't that supposed to work with 5 bit values between 0 and 31? always worked that way for me, though... <confused>

from libnds:
Code:
// macro creates a 15 bit color from 3x5 bit components
#define RGB15(r,g,b)  ((r)|((g)<<5)|((b)<<10))


Last edited by silent_code on Mon Aug 20, 2007 1:45 pm; edited 1 time in total

#138161 - Dark Knight ez - Mon Aug 20, 2007 1:27 pm

Err... yes, you're absolutely right... should be 31.
I gave that (and setting polyId to 0) a try, but still no luck.
(The former mentioned makes sense, as it has all the bits set anyway, so it ends up as the same value as the flawed use of 255, really.)

I checked out your shadow pencil demo code, but... don't see anything that catches my attention.
_________________
AmplituDS website

#138162 - silent_code - Mon Aug 20, 2007 1:41 pm

i guessed that. well, i really don't see anything else that could be wrong with this code. maybe you're resetting it somewhere else? dunno. sounds strange.
does the "shadow pencil" (<giggle>, should be stencil shadow ;D ) demo compile and work (e.g. in no$)? there should be a colored background (0, 25, 25), if you walk through a wall.

well, good luck!

#138169 - Dark Knight ez - Mon Aug 20, 2007 3:42 pm

I got stencil shadow (my eyes are failing me, I swear! xD) to compile... had like two outdated mentions: glIdentity() -> glLoadIdentity() and REG_EXEMEMCNT -> REG_EXMEMCNT.
When I tried it out on my hardware setup it didn't work at all for me though. Nada.
I'm tempted to just make a big white square in the back of the 3D scene instead of using the nice glClearColor. If I haven't fixed this in a couple of days, I probably will.
Anyway, a big thanks for the suggestions, silent_code. Was nice of you.
_________________
AmplituDS website

#138225 - Dark Knight ez - Tue Aug 21, 2007 11:49 am

Sooooo.... the reason... quite embarassing...
I didn't do a glFlush right after setting all that stuff. At least one was needed for the screen to turn white of course.
*quickly runs away*
_________________
AmplituDS website

#138320 - silent_code - Wed Aug 22, 2007 11:03 pm

nice to see you finally got it! :)

so, you couldn't run stencils... you're sure using a slot1 device. the demo won't run due to gbfs (afaik). but no$ should run it. well, with some weird graphics and stencil shadows without the stencil... means simple blending.

man, it's really been a while since the last time i ran that demo. couldn't get libfat or anything simmilar to work, so i froze any further development. plus my laptop is being repaired... <sigh>