SDL questions

Hullo,
1)Can someone tell me why SDL requires two separate steps to load an
image i.e. load then convert? Why not load and convert in one hit, thus
saving valuble memory.
2) Has anyone got SDL working in fulscreen in Nt4 sp5? Or does
anyone have any plans of doing so?
3)Is there any way to load a surface into pre-allocated memory
instead of freeing the memory I’ve got and re-allocating it? eg.

{
	SDL_Surface * x=SDL_Load("imageName.bmp");
	
	modify surface in some way...

	if(-2 == SDL_SpecialLoad("imageName.bmp", x))
		//buffers don't match

	//surface restored from disk at this point

}-- 

-dv

Hullo,
1)Can someone tell me why SDL requires two separate steps to load an
image i.e. load then convert? Why not load and convert in one hit, thus
saving valuble memory.

Sometimes you may not want to convert the image.

3)Is there any way to load a surface into pre-allocated memory
instead of freeing the memory I’ve got and re-allocating it? eg.

Yes, the new API (1.0) has the function SDL_CreateRGBSurfaceFrom()
which does exactly that.

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

In article <8268ub$lif$1 at news.lokigames.com>, slouken at devolution.com
says…

Hullo,
1)Can someone tell me why SDL requires two separate steps to load an
image i.e. load then convert? Why not load and convert in one hit, thus
saving valuble memory.

Sometimes you may not want to convert the image.

how about a separate function:
SDL_LoadBMPToDisplayFormat(...);

it would be more memory effiecient especially for large images.
3)Is there any way to load a surface into pre-allocated memory 

instead of freeing the memory I’ve got and re-allocating it? eg.

Yes, the new API (1.0) has the function SDL_CreateRGBSurfaceFrom()
which does exactly that.

How does SDL_CreateRGBSurfaceFrom(...) help me do that?

I can't pass SDL_LoadBMP(...) an SDL_Surface pointer to load the BMP 

data into and SDL_CreateRGBSurfaceFrom(…) doesn’t take an fName.

Yes i am confused. :)
Please clarify.

-dv

In article <8268ub$lif$1 at news.lokigames.com>, slouken at devolution.com
says…

Hullo,
1)Can someone tell me why SDL requires two separate steps to load an
image i.e. load then convert? Why not load and convert in one hit, thus
saving valuble memory.

Sometimes you may not want to convert the image.

how about a separate function:
SDL_LoadBMPToDisplayFormat(…);

it would be more memory effiecient especially for large images.

You should free original surface after you convert it, thus not wasting
any memory. If you want something more complex, you can write it yourself
for your application. All the tools are available to you. :slight_smile:

Yes, the new API (1.0) has the function SDL_CreateRGBSurfaceFrom()
which does exactly that.

How does SDL_CreateRGBSurfaceFrom(…) help me do that?

Your question was:

Is there any way to load a surface into pre-allocated memory
instead of freeing the memory I’ve got and re-allocating it?

The answer is yes, you pass the pre-allocated memory to
SDL_CreateRGBSurfaceFrom() to get a surface using that memory.

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec