Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (492)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
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  
  gl.texImage2D  (Read 1887 times)
0 Members and 1 Guest are viewing this topic.
Offline bedelf

Junior Member




Are you suggesting coconuts migrate?


« Posted 2003-05-22 05:57:04 »

Ok I have this image data in ARGB format but apparently OpenGL/LWJGL doesn't like that. What's the best way to get this data loaded as a texture? Do I need to just reposition the alpha bytes and just do GL.RGBA?

:/
Offline bedelf

Junior Member




Are you suggesting coconuts migrate?


« Reply #1 - Posted 2003-05-23 09:41:13 »

Now no matter what I change the color values to, it just comes out red.

?
Offline vrm

Junior Member




where I should sign ?


« Reply #2 - Posted 2003-05-23 09:45:50 »

java Bytes is different of Unisgned Bytes, it used to trick me with RGBA images
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline bedelf

Junior Member




Are you suggesting coconuts migrate?


« Reply #3 - Posted 2003-05-23 16:40:27 »

okay.. wanna elaborate on that? How would I pack an int with valid values?
Offline bedelf

Junior Member




Are you suggesting coconuts migrate?


« Reply #4 - Posted 2003-05-24 00:05:02 »

Ok when I rip pixels from an image and give them to opengl it works, aside from the colors being wrong.

but lets say i do this

Edit: note that this isnt acually converting anything yet
     public static final int[] ARGBtoRGBA( int[] temp ) {
           final int n = temp.length;
           int[] pixs = new int[ n ];
           
           for ( int i = 0; i < n; i++ ) {
                 int a = temp[ i ] >> 24 & 0xFF;
                 int r = temp[ i ] >> 16 & 0xFF;
                 int g = temp[ i ] >> 8 & 0xFF;
                 int b = temp[ i ] >> 0 & 0xFF;
                 
                 //System.out.println("before: " + a + " " + r + " " + g + " " + b );
                 
                 pixs[ i ] = ( ( ( byte ) a << 24 ) |
                             ( ( byte ) r << 16 ) |
                             ( ( byte ) g << 8 ) |
                             ( ( byte ) b << 0 ) );
                 
                 a = pixs[ i ] >> 24 & 0xFF;
                 r = pixs[ i ] >> 16 & 0xFF;
                 g = pixs[ i ] >> 8 & 0xFF;
                 b = pixs[ i ] >> 0 & 0xFF;
                 
                 //System.out.println("after: " + a + " " + r + " " + g + " " + b );
           }
           
           return pixs;
     }

all i did was remove the values and place them exactly how they were in a new array and the output for pixels looks like this in one part

before: 255 24 49 45
after: 255 24 49 45
before: 255 49 49 66
after: 255 49 49 66
before: 255 76 88 91
after: 255 76 88 91
before: 255 78 99 111
after: 255 78 99 111
before: 255 79 117 118
after: 255 79 117 118
before: 255 79 117 118
after: 255 79 117 118
before: 255 78 99 111
after: 255 78 99 111
before: 255 49 65 58
after: 255 49 65 58
before: 255 8 16 16
after: 255 8 16 16
before: 255 16 49 57
after: 255 16 49 57
before: 255 12 66 78
after: 255 12 66 78
before: 255 25 84 75
after: 255 25 84 75
before: 255 16 33 24
after: 255 16 33 24
before: 255 33 96 76
after: 255 33 96 76

the same right? well when i have it return pixs instead of temp it LOOKS DIFFERENT. How the hell is that happening if the values are exactly the same?

I've been looking around as various sites today browsing code but I still can't seem to answer my origional question.

Theres obviously something I'm not understanding about how this shit works. Also let's say when i'm just returning the OG array temp, all those "alpha" values are 255 but when I tell opengl I'm using RGBA shouldnt that be the red component? The image displayed is NOT red at all, most of it is black, with some green and yellow.

It's only turned all red when I started mixing those values around.

Is this something stupid? If so, please tell me so I can proceed in killing myself with blunt objects.
Offline AndersDahlberg

Junior Member





« Reply #5 - Posted 2003-05-24 01:09:01 »

Try changing the cast from byte to int (byte is signed: -128 to 127)  Smiley
Offline bedelf

Junior Member




Are you suggesting coconuts migrate?


« Reply #6 - Posted 2003-05-24 01:17:42 »

I thought I had tried that. I prolly had something else messed up at the time though. sigh.
Offline bedelf

Junior Member




Are you suggesting coconuts migrate?


« Reply #7 - Posted 2003-05-24 04:04:12 »

Ok I solved my first problem but what the hell is going on?

I assumed doing GL.RGBA meant the pixel order would be red/green/blue/alpha?

No wonder it looked f**ked up, when I put the values in alpha/blue/green/red order the image looks fine.

Did I miss that day at school? >:|
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #8 - Posted 2003-05-24 17:22:18 »

Sounds like a Little Endian vs. Big Endian thing.  If the pixels are treated as 32 bit ints the interpretation would vary as to which bits go where based on endianness.

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.

Nickropheliac (16 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (33 views)
2014-08-22 19:31:30

atombrot (42 views)
2014-08-19 09:29:53

Tekkerue (41 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (26 views)
2014-08-16 06:20:21

Tekkerue (37 views)
2014-08-16 06:12:11

Rayexar (73 views)
2014-08-11 02:49:23

BurntPizza (49 views)
2014-08-09 21:09:32
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!