Author Topic: glaux - loading an image from memory  (Read 4578 times)

0 Members and 1 Guest are viewing this topic.

Offline energy

  • Amiga 1200
  • ****
  • Posts: 280
  • Karma: 25
    • View Profile
glaux - loading an image from memory
« on: September 06, 2007 »
Hi!
does anybody know how to load a bitmap with glaux from memory??

thank yu in forward...

coding: jwasm,masm
hobby: www.scd2003.de

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: glaux - loading an image from memory
« Reply #1 on: September 06, 2007 »
Nobody really uses glaux any more (since years ago).  It has some problems, and noone will know anything much about it.  Can you use one of our other loaders?
http://dbfinteractive.com/index.php?topic=2334.0
http://dbfinteractive.com/index.php?topic=73.0
http://dbfinteractive.com/index.php?topic=116.0

You didn't say which language you're coding in, or if you can use Windows API.

Jim
Challenge Trophies Won:

Offline energy

  • Amiga 1200
  • ****
  • Posts: 280
  • Karma: 25
    • View Profile
Re: glaux - loading an image from memory
« Reply #2 on: September 07, 2007 »
Hi Jim!

Thanx for answer.... im Coding in Purebasic....
I just tested the OpenGL Engline from here ... http://dbfinteractive.com/index.php?topic=1575.0
In the function there is glaux used for loading bitmap as file from disk....

Im OPENGL Beginner and i just tried to load a bitmap from memory for converting as texture...
I thought OGL has an internal LOader for this....!!

to load a bitmap with purebasic in memory is not the problem, but how to convert it as Texture???

Cheers .....eNeRGy
coding: jwasm,masm
hobby: www.scd2003.de

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: glaux - loading an image from memory
« Reply #3 on: September 07, 2007 »
OpenGL itself doesn't support any file formats, you have to do that bit yourself.  What OpenGL needs is a pointer to the raw picture data, usually an array which is a power of 2 wide and a power of 2 high, eg. 32x128 or 256x256.  The array is best kept as 32 bit unsigned integers which holds the r,g,b and a.  Then you call glTexture2d() with a pointer to that array to set the texture.
The code you linked to is able to load .tga files or .raw files - raw files have no header they're just plain rgb data.

Is it possible in PureBASIC to get a pointer to the raw graphics data once it's loaded an image?  If not, you could always just draw it to the screen in the normal way and read back the pixels in to an array.  Remember to set the alpha to 255.

Keep posting if this doesn't make any sense and we'll try to fix you up :)

Jim
Challenge Trophies Won:

Offline energy

  • Amiga 1200
  • ****
  • Posts: 280
  • Karma: 25
    • View Profile
Re: glaux - loading an image from memory
« Reply #4 on: September 07, 2007 »
Hi Jim!

Now i wrote a routine to get the RGB Data of any file in a Array....
Could yu please explain me now the way to get them into the texture?

thanks and cheers....
energy
coding: jwasm,masm
hobby: www.scd2003.de

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: glaux - loading an image from memory
« Reply #5 on: September 08, 2007 »
Now that you have your RGB data array, to create your texture is simple, first, generate ogl texture:

Code: [Select]
GLuint texture;
glGenTextures(1, &texture);

Bind texture
Code: [Select]
glBindTexture(GL_TEXTURE_2D, texture);
you can add an image filter:
Code: [Select]
//Create Linear Filtered Texture
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);

Now build your data array into ogl texture
Code: [Select]
gluBuild2DMipmaps (GL_TEXTURE_2D, 3, TEX_Width, TEX_Height,  GL_RGB, GL_UNSIGNED_BYTE, your_image_array_buffer);
Challenge Trophies Won:

Offline energy

  • Amiga 1200
  • ****
  • Posts: 280
  • Karma: 25
    • View Profile
Re: glaux - loading an image from memory
« Reply #6 on: September 10, 2007 »
Thanx RBRAZ!!!
Will test tommorow....
 :carrot:
coding: jwasm,masm
hobby: www.scd2003.de