JPG LOADING PROBLEM =(
Can anyone tell me how to load a jpg texture (with source)?
i tryed this but it dosent work:
AUX_RGBImageRec *LoadJPG(char *Filename) // Loads A Bitmap Image
{
FILE *File=NULL; // File Handle
if (!Filename) // Make Sure A Filename Was Given
{
return NULL; // If Not Return NULL
}
File=fopen(Filename,"r"); // Check To See If The File Exists
if (File) // Does The File Exist?
{
fclose(File); // Close The Handle
return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer
}
return NULL; // If Load Failed Return NULL
}
int LoadGLTextures() // Load Bitmaps And Convert To Textures
{
int Status=FALSE; // Status Indicator
AUX_RGBImageRec *TextureImage[8]; // Create Storage Space For The Texture
memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL
// Load The Bitmap, Check For Errors, If Bitmap''s Not Found Quit
// textur 1 mipmap
if (TextureImage[0]=LoadJPG("Data/matrix.jpg"))
{
Status=TRUE; // Set The Status To TRUE
glGenTextures(1, &texture[0]); // Create The Texture
// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, texture[0]);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
}
Looks like you just took the bitmap loading code out of nehe''s tutorial and replaced some of the BMP''s with JPG''s :-)
Not that easy I''m afraid. You need to find the jpg file format spec and then learn to read binary files etc... You might want to try something easier first. Look at the TGA loader in nehe''s tutorial.
-DeVore
Not that easy I''m afraid. You need to find the jpg file format spec and then learn to read binary files etc... You might want to try something easier first. Look at the TGA loader in nehe''s tutorial.
-DeVore
i now know that this was wrong =)
i want to use the code from http://www.ijg.org/
can anyone give me a NeHe based source that uses this libary to load JPGs and place them on a qube?
i want to use the code from http://www.ijg.org/
can anyone give me a NeHe based source that uses this libary to load JPGs and place them on a qube?
FYI - I have heard that JPEGSs look like crap in OpenGL as textures due to the way JPEGs are compressed. (I have not tried using them, so I am not positive on this).
You can read the article on them at http://web2.airmail.net/sjbaker1/jpegs_are_evil_too.html
Hope this helps
Roach
You can read the article on them at http://web2.airmail.net/sjbaker1/jpegs_are_evil_too.html
Hope this helps
Roach
Did you know Quake III Arena? This textures are JPGs and they are looking great!!!
So dont say that Jpgs look bad in OpenGL !
=)
So dont say that Jpgs look bad in OpenGL !
=)
May 01, 2001 05:06 PM
Depends on the type of textures you are using: hand drawn or synthetic textures don''t look so good (lots of blocking artifacts), or you have to use a rather low compression ratio. This is because of large unicolored or smooth gradient parts on them, jpeg doesn''t like this. Photorealistic textures, on the other hand, look great wth jpeg, even highly compressed.
May 01, 2001 07:36 PM
no offense bro, but did you seriously think by just renaming the fucntions to have JPG in them that it would work? hehe
HAHA, sorry, i just have to laugh.
HAHA, sorry, i just have to laugh.
Hey what a coincidence, that question come just one month after april fool''s day.
(you can find me on IRC : #opengl on undernet)
here is some source from my raycast engine which uses jpeblib-6b to read a JPEG image
into a buffer...
NOTE: the rc_fopen.. etc are my custom functions to handle IO, but mimic fopen, etc exactly... _rcBITMAP is a custom struct which holds the final bitmap data
you need both the jpeglib and header files to compile this.
|
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement