Hi,
What is the routine of loading a BMP in SDL for OpenGL textures? Is
it going to be like this?
// create the memory block to put the BMP in
SDL_Surface *image;
// load the BMP from “file_name” into the “image” memory area
image = SDL_LoadBMP(file_name);
// many OpenGL image enviroment settings are here
…
…
…
// main function to setup the texture in OpenGL
glTexImage2D(GL_TEXTURE_2D, 0, image->format->BitsPerPixel, image->w,
image->h, 0, [an opengl format], GL_UNSIGNED_BYTE, image->pixels);
// free the memory used for loading the BMP file
free(image);
Thanks in advance for any helpful replies.
Jack______________________________________________________________________
Post your free ad now! http://personals.yahoo.ca
[…code…]
Yeah, for OpenGL 1.2 and up, that might work most of the time. Another
method is to create a surface of a format you know OpenGL supports,
and blit the loaded image into it, to convert it. That’s simple and
safe, but obviously has some load time cost.
//David Olofson - Programmer, Composer, Open Source Advocate
.- The Return of Audiality! --------------------------------.
| Free/Open Source Audio Engine for use in Games or Studio. |
| RT and off-line synth. Scripting. Sample accurate timing. |
`-----------------------------------> http://audiality.org -’
— http://olofson.net — http://www.reologica.se —On Saturday 08 March 2003 20.22, Jack Chen wrote:
Hi,
What is the routine of loading a BMP in SDL for OpenGL
textures? Is it going to be like this?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
What is the routine of loading a BMP in SDL for OpenGL textures? Is
it going to be like this?
[snip]
// free the memory used for loading the BMP file
free(image);
You must use SDL_FreeSurface here instead of plain free(). Also, I’d use
SDL_ConvertSurface to convert your bitmap into a format you know OpenGL
supports. For example, the current code wouldn’t work with palette bitmaps.
cu,
Nicolai
Thanks in advance for any helpful replies.
Jack
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+amEmsxPozBga0lwRAp+qAJ9wgTRcaB3d6bMvglgCtDnSkk55nACg2/Zn
UpA8KHRyNMROLsD/Ka6zSD8=
=TLM3
-----END PGP SIGNATURE-----On Saturday 08 March 2003 20:22, Jack Chen wrote:
Hi,
What is the routine of loading a BMP in SDL for OpenGL textures? Is
it going to be like this?
By the way, in the SDL source archive in the test/testgl.c file there’s a
set of routines for loading and displaying images with OpenGL. The test
programs and all the code in them are in the public domain.
See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment