How do you know when you run out of texture memory?

slenkar
Posts: 43
Joined: Sun Apr 17, 2011 8:10 pm

How do you know when you run out of texture memory?

Post by slenkar » Mon Aug 08, 2011 5:22 am

When I run my game in the emulator it works but some of the textures look weird,
when I run it on the DS it just shows a blank screen,

Im converting a game from desktop to DS and the textures may take up more graphics memory than the DS has, is there a way of telling if that is the problem?

slenkar
Posts: 43
Joined: Sun Apr 17, 2011 8:10 pm

Re: How do you know when you run out of texture memory?

Post by slenkar » Mon Aug 08, 2011 6:31 am

Im using 3D quads to draw to the screen
so all my images are textures by the way

zeromus
Posts: 212
Joined: Wed Mar 31, 2010 6:05 pm

Re: How do you know when you run out of texture memory?

Post by zeromus » Mon Aug 08, 2011 6:47 am

1. you know how big your textures are
2. you know how much vram you allocated for textures
3. glTexImage2D has a return value

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: How do you know when you run out of texture memory?

Post by elhobbs » Mon Aug 08, 2011 2:25 pm

emulators tend to be very forgiving in regards to exceptions that will hang the hardware. if you have not already, try running:

Code: Select all

defaultExceptionHandler();
at the start of your main function. if an exception occurs at will dump registers and stack to a red screen which you can use to find the source of the problem.

slenkar
Posts: 43
Joined: Sun Apr 17, 2011 8:10 pm

Re: How do you know when you run out of texture memory?

Post by slenkar » Wed Aug 10, 2011 8:39 pm

'defaultExceptionHandler();'

thanks for the BROtip

slenkar
Posts: 43
Joined: Sun Apr 17, 2011 8:10 pm

Re: How do you know when you run out of texture memory?

Post by slenkar » Wed Aug 10, 2011 8:58 pm

when i put that in my main function it says:

error: expected constructor, destructor, or type conversion before ';' token

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: How do you know when you run out of texture memory?

Post by elhobbs » Wed Aug 10, 2011 9:14 pm

slenkar wrote:when i put that in my main function it says:

error: expected constructor, destructor, or type conversion before ';' token
you need to add a header file either
#include <nds.h>
or minimally
#include <nds/arm9/exceptions.h>

slenkar
Posts: 43
Joined: Sun Apr 17, 2011 8:10 pm

Re: How do you know when you run out of texture memory?

Post by slenkar » Wed Aug 10, 2011 9:22 pm

ah yes I put it in the wrong place, it compiles now thanks

slenkar
Posts: 43
Joined: Sun Apr 17, 2011 8:10 pm

Re: How do you know when you run out of texture memory?

Post by slenkar » Wed Aug 10, 2011 9:30 pm

ok now if I run it in the emulator.. the emulator simply closes

If I run it on the hardware (original DS) it turns itself off! :)

Am I supposed to be calling the function every frame , or just once before the game loop?

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: How do you know when you run out of texture memory?

Post by elhobbs » Wed Aug 10, 2011 10:06 pm

no, just call it once like I indicated. if you call "exit" then it will do this. add the following code to your project - systemErrorExit gets called before exit shuts down the DS. this example relies on stdout/printf being setup and wait for the A button to be pressed before shuting down.

Code: Select all

#ifdef __cplusplus
extern "C" {
#endif 
   
void systemErrorExit(int rc) {
    printf("exit with code %d\n",rc);
    while(1) {
        swiWaitForVBlank();
        if (keysCurrent() & KEY_A) break;
    }
}

#ifdef __cplusplus
};
#endif  

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests