Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  How to use compressed textures with OpenGL  (Read 1382 times)
0 Members and 1 Guest are viewing this topic.
Offline Bombadil

Senior Duke





« Posted 2004-05-11 10:35:57 »

.. in Java of course. Jogl to be more precise. I guess my question is pretty similar to Lwjgl so I'm posting this here, not into the Jogl forum.

A
Quote
gl.isExtensionAvailable("GL_ARB_texture_compression")
gives true for my card so I thought it's safe to call this (in order to bind my RGB texture):
Quote
gl.glCompressedTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_COMPRESSED_RGB,
xdim, ydim, 0,  GL.GL_UNSIGNED_BYTE size, bytearray);

but I'm prompted with an error.
(Using glTexImage2D(..) with GL_RGB as internalformat and format works, but not compressed of course.)

http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_compression.txt doesn't help me either. Googling brings references to the above URL.


{Edit: Use compressed ! size}
Offline overnhet

Junior Duke




Java games rock!


« Reply #1 - Posted 2004-05-11 11:22:33 »

This is how I display DXT compressed textures with my DDS loader :
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
      if(pixelFormat.isDXT())
      {
            boolean supported = true;
            int compressedFormat = 0;
                 
            switch(pixelFormat.getDXTVersion())
            {
                  case 1 :
                        compressedFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; break;
                  case 3 :
                        compressedFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; break;
                  case 5 :
                        compressedFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; break;
                  default :
                        supported = false; break;
            }
                 
            if(supported)
            {
                  int size = image.getSize(); //return the total size of the compressed texture
                  gl.glCompressedTexImage2D(GL_TEXTURE_2D, 0, compressedFormat, width, height, 0, size, pixels);
            }
      }


Your problem is that the 'size' argument should be the total compressed size of the texture, not its storage type. At least that's how it works with DXT  Smiley
Offline Bombadil

Senior Duke





« Reply #2 - Posted 2004-05-11 11:39:16 »

Thanks for the hints...
So it's not really as simple to implement as I thought (but then, it's never when you do raw OpenGL...).

So actually you use the GL_EXT_texture_compression_s3tc extension then?
What's with the GL_ARB_texture_compression? How can I compress a texture so that it can be used with this extension? {Edit} Use one of those tools at Ati/Nvidia/blabla to lossy compress it.

Extensions - an alien world to me. :)
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline overnhet

Junior Duke




Java games rock!


« Reply #3 - Posted 2004-05-11 11:54:22 »

Well there is only one parameter to change.  Smiley

However I don't know how it works with GL_COMPRESSED_{RGB, RGBA, ALPHA, ...} : I only used it with DXT and I don't plan to support any other method at the moment. DXT compressed DDS textures are definitely great : having all mipmap levels and/or cubemap faces stored in a single file with high compression ratio is invaluable.

Though I wish Nvidia had respected MS specs with their DDS exporter : now a lot of DDS files have wrong header and size, which makes it difficult to write a stable loader.  Angry
Offline overnhet

Junior Duke




Java games rock!


« Reply #4 - Posted 2004-05-11 11:59:55 »

Quote
So actually you use the GL_EXT_texture_compression_s3tc extension then?
What's with the GL_ARB_texture_compression? How can I compress a texture so that it can be used with this extension? {Edit} Use one of those tools at Ati/Nvidia/blabla to lossy compress it.

Yes you should use Nvidia plugin (either with photoshop or  command-line). It is safe for DXT. Since I mostly played with Far Cry textures so far, I haven't created my own DDS files yet.

Quote
Extensions - an alien world to me. :)

Me too. I got part of the code from CodeSampler's DDS loader and added some missing stuff. ;D
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (38 views)
2014-10-17 03:59:02

Norakomi (29 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (56 views)
2014-10-14 00:39:48

TehJavaDev (55 views)
2014-10-14 00:35:47

TehJavaDev (46 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!