PDA

View Full Version : How to load JPG for textures



jirkamelich
12-05-2002, 05:11 AM
How should i load jpg images for using them as a textures ?

Gavin
12-05-2002, 07:14 AM
1. Go and read about discrete cosine transforms and quantization and huffman encoding
2. Code a jpg decompression algorithm

or

use a jpeg library

jirkamelich
12-05-2002, 11:29 AM
I tried that but it doesn't work :

TJPEGImage *JPEGObrazek = new TJPEGImage();
JPEGObrazek->Performance = jpBestQuality;
JPEGObrazek->PixelFormat = jf24Bit;
JPEGObrazek->Grayscale = false;
JPEGObrazek->LoadFromFile("Data//Suter.jpg");

Graphics::TBitmap *Bitmapa = new Graphics::TBitmap();
Bitmap->HandleType = bmDIB;
Bitmap->PixelFormat = pf32bit;
Bitmapa->Width = JPEGObrazek->Width;
Bitmapa->Height = JPEGObrazek->Height;
Bitmapa->Canvas->Draw(0,0,JPEGObrazek);
free (JPEGObrazek);

glGenTextures(1,&Textures[0]);
glBindTexture(GL_TEXTURE_2D,Textures[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3,Bitmapa->Width, Bitmapa->Height, 0, GL_RGB, GL_UNSIGNED_BYTE, Bitmapa );

Gavin
12-06-2002, 01:55 AM
Is the jpeg being loaded ok, i.e. can you draw the 'bitmapa' to the screen to check it? try gldrawpixels to check you have loaded it as well..
glteximage the last parameter.... is that correct? isn't that 'bitmapa' the structure which holds all the jpeg info, as in width and everything as well? you need a pointer to the actual rgb data. but I work in C so what do I know!...

B_old
12-07-2002, 03:10 PM
Hello.
Take a look at the third tutorial of this page: http://www.gametutorials.com/Tutorials/opengl/OpenGL_Pg2.htm

I hope that helps.

jirkamelich
12-08-2002, 01:26 AM
Thanks