Jpg with OpenGL

  • Follow


I open and use bitmaps in OpenGL as following:


AUX_RGBImageRec *TextureImage[4];
memset(TextureImage,0,sizeof(void*)*1);
TextureImage[0] = auxDIBImageLoad("Data/5.bmp");

glGenTextures(1,&texture[0]);

glBindTexture(GL_TEXTURE_2D,texture[0]);
glTexImage2D(GL_TEXTURE_2D,0,3,
TextureImage[0]->sizeX,TextureImage[0]->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE,Text
ureImage[0]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

My question is:
How I can open, read and use .jpg file?

Thanks for help.



0
Reply wowiii 12/25/2005 1:55:16 PM

wowiii wrote:
> I open and use bitmaps in OpenGL as following:
> 
> 
> AUX_RGBImageRec *TextureImage[4];
> memset(TextureImage,0,sizeof(void*)*1);
> TextureImage[0] = auxDIBImageLoad("Data/5.bmp");
> 
> glGenTextures(1,&texture[0]);
> 
> glBindTexture(GL_TEXTURE_2D,texture[0]);
> glTexImage2D(GL_TEXTURE_2D,0,3,
> TextureImage[0]->sizeX,TextureImage[0]->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE,Text
> ureImage[0]->data);
> glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
> glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
> 
> My question is:
> How I can open, read and use .jpg file?
> 
> Thanks for help.
> 
> 
> 
0) google ;-)
a) use an appropriate lib (libjpeg)
b) use a general lib that allows you to load all kind of file formats 
(devil)
c) program your own library according to the JPEG spec

image loading is not supported by OpenGL.
0
Reply David 12/25/2005 2:13:09 PM


David Zellhoefer wrote:
> wowiii wrote:
> 
>> I open and use bitmaps in OpenGL as following:
>>
>>
>> AUX_RGBImageRec *TextureImage[4];
>> memset(TextureImage,0,sizeof(void*)*1);
>> TextureImage[0] = auxDIBImageLoad("Data/5.bmp");
>>
>> glGenTextures(1,&texture[0]);
>>
>> glBindTexture(GL_TEXTURE_2D,texture[0]);
>> glTexImage2D(GL_TEXTURE_2D,0,3,
>> TextureImage[0]->sizeX,TextureImage[0]->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE,Text 
>>
>> ureImage[0]->data);
>> glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
>> glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
>>
>> My question is:
>> How I can open, read and use .jpg file?
>>
>> Thanks for help.
>>
>>
>>
> 0) google ;-)
> a) use an appropriate lib (libjpeg)
> b) use a general lib that allows you to load all kind of file formats 
> (devil)
> c) program your own library according to the JPEG spec
> 
> image loading is not supported by OpenGL.

i forgot to say that jpgs are not recommended as a texture image format, 
browse the group for details.
0
Reply David 12/25/2005 2:14:22 PM

David Zellhoefer wrote:
> 
> jpgs are not recommended as a texture image format, 
> browse the group for details.

I use them all the time...what's the problem?


-- 
<\___/>
/ O O \
\_____/  FTB.    For email, remove my socks.

In science it often happens that scientists say, 'You know
that's a really good argument; my position is mistaken,'
and then they actually change their minds and you never
hear that old view from them again.  They really do it.
It doesn't happen as often as it should, because scientists
are human and change is sometimes painful.  But it happens
every day.  I cannot recall the last time something like
that happened in politics or religion.

- Carl Sagan, 1987 CSICOP keynote address

0
Reply fungus 12/25/2005 7:22:16 PM

fungus wrote:
> David Zellhoefer wrote:
> 
>>
>> jpgs are not recommended as a texture image format, browse the group 
>> for details.
> 
> 
> I use them all the time...what's the problem?

Presumably the lossy compression, when a texture is magnified so are the 
compression artifacts.  If you can deal with the quality trade-off there 
is no reason not to use jpg...
0
Reply Michael 12/25/2005 9:08:21 PM

fungus wrote:

> David Zellhoefer wrote:
>> 
>> jpgs are not recommended as a texture image format,
>> browse the group for details.
> 
> I use them all the time...what's the problem?

JPEGs are not intended to be tiled. It easily happens that the
compression affects the colour and brightness at the edges
differently depending on the surrounding pixel values. If you
lossy compress a seamless texture w/o using a tilig aware
algorithm you will get noticable edges.

Wolfgang Draxinger
-- 

0
Reply Wolfgang 12/25/2005 9:39:21 PM

5 Replies
289 Views

(page loaded in 0.077 seconds)

Similiar Articles:













7/24/2012 3:58:46 PM


Reply: