SDL_GammaRamp Access Violation

Hello,

I am trying to utilize SDL_GetGammaRamp, my progamm compiles and linkes
fine, but I am getting lots of errors like:

First-chance exception at 0x681264a4 in sdl_test.exe: 0xC0000005: Access
violation reading location 0x0000013c.
Unhandled exception at 0x681264a4 in sdl_test.exe: 0xC0000005: Access
violation reading location 0x0000013c.

The error occures when calling the GetGammaRamp function. I am using the
prebuild win32 vc 8 package from the SDL Homepage with windows xp 32bit
pro, vs 2005 express. The VS project is setup according to the html help
file and the test programs I tried worked great. Here is some test code
(It should also be working because it was pulled from pygame’s display.c
file)

#include "SDL.h"
int main(int argc, char *argv[])
{
Uint16 *r, *g, *b;
int result;

 r = (Uint16 *) malloc (256 * sizeof (Uint16));
 if (!r)
{
     return 1;
}

 g = (Uint16 *) malloc (256 * sizeof (Uint16));
 if (!g)
 {
     free (r);
     return 1;
 }

 b = (Uint16 *) malloc (256 * sizeof (Uint16));
 if (!b)
 {
     free (r);
     free (g);
     return 1;
 }

 SDL_GetGammaRamp (r, g, b);

 free ((char*)r);
 free ((char*)g);
 free ((char*)b);

return 0;

}

Any ideas appreciated.

Thanks

Sebastian

Try calling SDL_Init(). You can remove the dynamic allocations and use
arrays. The following works for me:

int main(int, char **)
{
Uint16 red[256], blue[256], green[256];

if( SDL_Init(SDL_INIT_VIDEO) < 0)
{
	return 1;
}

if( SDL_GetGammaRamp (red, green, blue) < 0)
{
	return 2;
}

// use red, green and blue

SDL_Quit();

return 0;

}On Sun, Sep 13, 2009 at 12:10 PM, Sebastian Elsner wrote:

Hello,

I am trying to utilize SDL_GetGammaRamp, my progamm compiles and linkes
fine, but I am getting lots of errors like:

Thank you Brian. I should have read the tutorials. :)Am 13.09.2009, 15:44 Uhr, schrieb Brian <brian.ripoff at gmail.com>:

Try calling SDL_Init(). You can remove the dynamic allocations and use
arrays. The following works for me:

int main(int, char **)
{
Uint16 red[256], blue[256], green[256];

if( SDL_Init(SDL_INIT_VIDEO) < 0)
{
return 1;
}

if( SDL_GetGammaRamp (red, green, blue) < 0)
{
return 2;
}

// use red, green and blue

SDL_Quit();

return 0;
}
On Sun, Sep 13, 2009 at 12:10 PM, Sebastian Elsner <@Sebastian_Elsner> wrote:

Hello,

I am trying to utilize SDL_GetGammaRamp, my progamm compiles and linkes
fine, but I am getting lots of errors like:


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Yeah, you probably should have. Then again, this should still be treated
as a bug report. The library shouldn’t be causing AVs no matter what
happens. If an SDL call is made before the appropriate subsystem
has been initialized, the call should fail gracefully.>----- Original Message ----

From: Sebastian Elsner
Subject: Re: [SDL] SDL_GammaRamp Access Violation

Thank you Brian. I should have read the tutorials. :slight_smile:

Am 13.09.2009, 15:44 Uhr, schrieb Brian <brian.ripoff at gmail.com>:

Try calling SDL_Init(). You can remove the dynamic allocations and use
arrays. The following works for me:

Yeah, you probably should have.

On the other hand, perhaps one should change the VisualC.html, because the
"SDL Lesson 101" implies that you are good to go with just including
SDL.h…

Then again, this should still be treated
as a bug report. The library shouldn’t be causing AVs no matter what
happens. If an SDL call is made before the appropriate subsystem
has been initialized, the call should fail gracefully.

Not being much of a programmer, I’d agree to this.On Sun, 13 Sep 2009 22:45:10 +0200, Mason Wheeler wrote:

----- Original Message ----
From: Sebastian Elsner <@Sebastian_Elsner>
Subject: Re: [SDL] SDL_GammaRamp Access Violation

Thank you Brian. I should have read the tutorials. :slight_smile:

Am 13.09.2009, 15:44 Uhr, schrieb Brian <brian.ripoff at gmail.com>:

Try calling SDL_Init(). You can remove the dynamic allocations and use
arrays. The following works for me:


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Using Opera’s revolutionary e-mail client: http://www.opera.com/mail/