Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (116)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  graphics, black box  (Read 7461 times)
0 Members and 1 Guest are viewing this topic.
Offline h3ckboy

JGO Coder


Medals: 5



« Posted 2009-02-09 15:31:37 »

ok for starters sorry I have been making tons of threads lately.

I try this tut out http://lwjgl.org/wiki/doku.php/lwjgl/tutorials/opengl/basicopengl

I get a black window that is full screen(still with menu though). I cant seem to get it to shrink. also is this supposed to be black. cause if so ok but otherwaise that is a problem.
Offline princec

JGO Kernel


Medals: 380
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #1 - Posted 2009-02-09 18:40:21 »

Ah that tutorial is just out of date as of LWJGL 2.0... LWJGL 1.x used to set up the display such that it had normal "pixel " coordinates orthographically projected onto the entire display - a bit like Java2D - but LWJGL 2.0 doesn't do that any more, you need to stick in another line of initialisation to do it:
1  
2  
3  
4  
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(0, displaywidth, 0, displayheight, -1.0f, 1.0f);
GL11.glMatrixMode(GL11.GL_MODELVIEW);

Do that once only, before the main loop starts but after initing the display.

Cas Smiley

Offline h3ckboy

JGO Coder


Medals: 5



« Reply #2 - Posted 2009-02-09 19:03:12 »

that did not change anything. or was it supposed to?

here is a screen shot of what happens for me.

could yo post one of what ahppens for you?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Bonbon-Chan

JGO Coder


Medals: 12



« Reply #3 - Posted 2009-02-10 08:03:19 »

This example is 2D drawing. You have to specify the 2D space, I use GLU for that :

1  
2  
3  
4  
5  
6  
GL11.glViewport(0,0,Display.getDisplayMode().getWidth(),Display.getDisplayMode().getHeight());
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight());
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();


When you draw your quads, you didn't specify the color (before the glBegin) :
1  
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #4 - Posted 2009-02-10 12:13:39 »

what is the import for GLU? also can someone pls jsut post what it is supposed to look like. cause there may be nothing wrong with the way it is right now,=.
Offline bobjob

JGO Knight


Medals: 10
Projects: 4


David Aaron Muhar


« Reply #5 - Posted 2009-02-10 12:20:02 »

i think GLU in a new packate location

import org.lwjgl.util.glu.GLU;

My Projects
Games, Webcam chat, Video screencast, PDF tools.

Javagaming.org with chat room
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #6 - Posted 2009-02-10 12:21:02 »

ok so i dont think that I have glu. cause I got the nehe tutorials. It looks at org.lwjgl.opengl.glu.GLU;

it cant find it :/.
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 77
Projects: 15


★★★★★


« Reply #7 - Posted 2009-02-10 12:21:22 »

yup thats correct in addition to the lwjgl.jar you'll have to add lwjgl_util.jar to your build path to use GLU
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #8 - Posted 2009-02-10 12:29:17 »

I have though. that is the problem. I have added all of them. here is a list of the stuff I got ont here.

jinput.jar
lwjgl.jar
lwjgl_util.jar
lwjgl_util_apllet.jar
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 77
Projects: 15


★★★★★


« Reply #9 - Posted 2009-02-10 12:31:44 »

are you using an IDE like Eclipse?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #10 - Posted 2009-02-10 12:32:36 »

yes I use and IDE but I use BLUEJ
Offline Bonbon-Chan

JGO Coder


Medals: 12



« Reply #11 - Posted 2009-02-10 13:12:04 »

What version of lwjgl are you using ?

I confirm that GLU in lwjgl 2 is in lwjgl_util.jar with the import org.lwjgl.util.glu.GLU.
I was using it with lwjgl 1 but with a different import (I don't remember it).
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #12 - Posted 2009-02-10 13:29:43 »

I have LWJGL 2.0. I got it like alst week. what is the import cause maybe it is wrong in the tutorail.
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #13 - Posted 2009-02-10 15:22:01 »

HAHAHA I found the class hierarchy fo glu. it is actually at org.lwjgl.util.glu.GLU. WOOOT. It all works now. YES! I love google.

ok enough me ranting. thank you allf or your help, I am very thankful.
Offline cylab

JGO Ninja


Medals: 49



« Reply #14 - Posted 2009-02-10 16:55:44 »

That was harder than it ought to be...

i think GLU in a new packate location

import org.lwjgl.util.glu.GLU;

 Roll Eyes

Mathias - I Know What [you] Did Last Summer!
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #15 - Posted 2009-02-10 17:14:19 »

WWWHHHHYYYYYY!!!!! GRRRR. COMON I WENT THROUGH SO MUCH TROUBLE.

oh yeah btw lwjgl  is easy once youg et eh hang of it. i am already at 3d objects.  also where is the devil thing, I will google it.
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 77
Projects: 15


★★★★★


« Reply #16 - Posted 2009-02-10 17:32:10 »

Devil has been removed from lwjgl and is no longer part for lwjgl 2.0+ as a replacement you can use Slick-Util's it can be found at http://slick.cokeandcode.com/downloads/util/ with javadoc at http://slick.cokeandcode.com/javadoc-util/ the download contains working examples on how to use it.
Offline bobjob

JGO Knight


Medals: 10
Projects: 4


David Aaron Muhar


« Reply #17 - Posted 2009-02-10 18:10:03 »

HAHAHA I found the class hierarchy fo glu. it is actually at org.lwjgl.util.glu.GLU. WOOOT. It all works now. YES! I love google.

ok enough me ranting. thank you allf or your help, I am very thankful.
oops, didnt relise you found it.

My Projects
Games, Webcam chat, Video screencast, PDF tools.

Javagaming.org with chat room
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #18 - Posted 2009-02-10 18:47:43 »

you found it before me. How am Is upposed to do texture wrapping. cause the library doesnt include Devil, wich is what Nehe uses.
Offline Bonbon-Chan

JGO Coder


Medals: 12



« Reply #19 - Posted 2009-02-10 20:43:11 »

What I use, it's not perfect but it work for what I do (you can have problem in the conversion of the BufferedImage to bytes data) :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212  
213  
214  
215  
216  
217  
218  
219  
220  
221  
222  
223  
224  
225  
226  
227  
228  
229  
230  
231  
232  
233  
234  
235  
236  
237  
238  
239  
240  
241  
242  
243  
244  
245  
246  
247  
248  
249  
250  
251  
252  
253  
254  
255  
256  
257  
258  
259  
260  
261  
262  
263  
264  
265  
266  
267  
268  
269  
270  
271  
272  
273  
274  
275  
276  
277  
278  
279  
280  
281  
282  
283  
284  
285  
286  
287  
288  
289  
290  
291  
292  
293  
294  
295  
296  
297  
298  
299  
300  
301  
302  
303  
304  
305  
306  
307  
308  
309  
310  
311  
312  
313  
314  
315  
316  
317  
318  
319  
320  
321  
322  
323  
324  
package net.bonbonchan.basegame.raster;

import java.awt.Graphics;
import java.awt.Transparency;
import java.awt.image.BufferedImage;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;

/**
 *
 * @author Bonbon-Chan
 */

public class Texture
{
    static  protected int lastBind = -1;
   
    private String  name;
    private int width;
    private int height;
       
    private float ratioU;
    private float ratioV;
   
    private boolean hasAlpha;
    private int     handle;
   
    /** Creates a new instance of Texture */
    public Texture()
    {
      ratioU = 1;
      ratioV = 1;
    }

    /**
     *
     */

    public void destroy()
    {
      if (handle != -1)
      {
        IntBuffer scratch = BufferUtils.createIntBuffer(1);
        scratch.put(handle);
        scratch.flip();
        GL11.glDeleteTextures( scratch );
        handle = -1;
      }
    }
   
    /**
     *
     * @param u
     */

    public void setRatioU(float u)
    {
      ratioU = u;
    }
   
    /**
     *
     * @return
     */

    public float getRatioU()
    {
      return ratioU;
    }
   
    /**
     *
     * @param v
     */

    public void setRatioV(float v)
    {
      ratioV = v;
    }
   
    /**
     *
     * @return
     */

    public float getRatioV()
    {
      return ratioV;
    }
   
    /**
     *
     */

    public void create()
    {
      IntBuffer scratch = BufferUtils.createIntBuffer(1);
      GL11.glGenTextures(scratch);
   
      int error = GL11.glGetError();
      if( error != GL11.GL_NO_ERROR)
      {
        System.out.println("Texture.create : error OpenGL ("+error+")");
      }
     
      handle = scratch.get(0);
    }
   
    /**
     *
     * @param minFilter
     * @param magFilter
     */

    public void setFilter(int minFilter,int magFilter)
    {
      bind();
     
      GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, minFilter);
      GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, magFilter);
     
      unbind();
    }
           
    /**
     *
     * @param width
     * @param height
     * @param type
     * @param imageData
     */

    public void setImage(int width,int height,int type,ByteBuffer imageData)
    {
      bind();
   
      GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height,
                        0, type, GL11.GL_UNSIGNED_BYTE, imageData);
 
      int error = GL11.glGetError();
      if( error != GL11.GL_NO_ERROR)
      {
        System.out.println("Texture.setImage : error OpenGL ("+error+")");
      }
 
      unbind();
    }
   
    /**
     *
     * @param width
     * @param height
     * @param type
     * @param imageData
     */

    public void setImage(int width,int height,int type,IntBuffer imageData)
    {
      bind();
   
      GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height,
                        0, type, GL11.GL_UNSIGNED_BYTE, imageData);
 
      int error = GL11.glGetError();
      if( error != GL11.GL_NO_ERROR)
      {
        System.out.println("Texture.setImage : error OpenGL ("+error+")");
      }
 
      unbind();
    }
   
    /**
     *
     * @param img
     */

    public void setImage(BufferedImage img)
    {
      // System.out.println("IMAGE : opaque("+img.getTransparency()+") type("+img.getType()+")");
       
      if(img.getTransparency() == Transparency.OPAQUE)
      {
        if (img.getType() == BufferedImage.TYPE_BYTE_INDEXED)
        {
          BufferedImage img2 = new BufferedImage(img.getWidth(),img.getHeight(),BufferedImage.TYPE_3BYTE_BGR);
          Graphics g = img2.getGraphics();
          g.drawImage(img, 0, 0, null);
          g.dispose();
          setImage(img2);
        }
        else
        {
          ByteBuffer imageData = ByteBuffer.allocateDirect(3 * img.getWidth() * img.getHeight());
          byte data[] = (byte[]) img.getRaster().getDataElements(0, 0, img.getWidth(), img.getHeight(), null);
          imageData.put(data);
          imageData.flip();
       
          setImage(img.getWidth(),img.getHeight(),GL11.GL_RGB,imageData);
        }
      }
      else
      {
        if (img.getType() == BufferedImage.TYPE_INT_ARGB )
        {
          IntBuffer imageData = BufferUtils.createIntBuffer(img.getWidth() * img.getHeight());
          int data[] = (int[]) img.getRaster().getDataElements(0, 0, img.getWidth(), img.getHeight(), null);
          imageData.put(data);
          imageData.flip();
       
          setImage(img.getWidth(),img.getHeight(),GL11.GL_RGBA,imageData);
        }
        else
        {
          ByteBuffer imageData = ByteBuffer.allocateDirect(4 * img.getWidth() * img.getHeight());
          byte data[] = (byte[]) img.getRaster().getDataElements(0, 0, img.getWidth(), img.getHeight(), null);
          imageData.put(data);
          imageData.flip();
       
          setImage(img.getWidth(),img.getHeight(),GL11.GL_RGBA,imageData);
        }
      }
    }
   
    /**
     *
     * @param warpS
     * @param warpT
     */

    public void setWarp(int warpS,int warpT)
    {
      bind();
       
      GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, warpS);
      GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, warpT);
     
      unbind();
    }
   
    /**
     *
     * @return
     */

    public String getName() {
        return name;
    }

    /**
     *
     * @param name
     */

    public void setName(String name) {
        this.name = name;
    }

    /**
     *
     * @return
     */

    public int getWidth() {
        return width;
    }

    /**
     *
     * @param width
     */

    public void setWidth(int width) {
        this.width = width;
    }

    /**
     *
     * @return
     */

    public int getHeight() {
        return height;
    }

    /**
     *
     * @param height
     */

    public void setHeight(int height) {
        this.height = height;
    }

    /**
     *
     * @return
     */

    public boolean isHasAlpha() {
        return hasAlpha;
    }

    /**
     *
     * @param hasAlpha
     */

    public void setHasAlpha(boolean hasAlpha) {
        this.hasAlpha = hasAlpha;
    }

    /**
     *
     * @return
     */

    public int getHandle() {
        return handle;
    }

    /**
     * Bind texture (LWJGL)
     */

    public void bind()
    {
      if (lastBind != handle)
      {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, handle);
        lastBind = handle;
      }
    }
   
    /**
     *
     */

    public void unbind()
    {
      GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
      lastBind = -1;
    }
   
}



To use it :
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
  // Create texture
 Texture texture = new Texture();
  texture.create();

  // Load image
 BufferedImage image = ImageIO.read("...");

  // Set image to the texture
 texture.setImage(image);
  texture.setFilter(GL11.GL_LINEAR,GL11.GL_LINEAR);

  // now you can use the texture
 texture.bind();
  GL11.glBegin(...
 
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #20 - Posted 2009-02-16 16:05:31 »

I tried your idea and I get this exception:

java.lang.IllegalArgumentException: Number of remaining buffer elements is 1024, must be at least 4096
   at org.lwjgl.BufferChecks.throwBufferSizeException(BufferChecks.java:125)
   at org.lwjgl.BufferChecks.checkBufferSize(BufferChecks.java:140)
   at org.lwjgl.NondirectBufferWrapper.wrapBuffer(NondirectBufferWrapper.java:101)
   at org.lwjgl.opengl.GL11.glTexImage2D(GL11.java:2703)
   at Texture.setImage(Texture.java:128)
   at Texture.setImage(Texture.java:209)
   at Game.init(Game.java:74)
   at Game.main(Game.java:41)
   at __SHELL0.run(__SHELL0.java:7)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at bluej.runtime.ExecServer$3.run(ExecServer.java:792)


I did have to make the Image IO read a url though
ImageIO.read(url);
Offline princec

JGO Kernel


Medals: 380
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #21 - Posted 2009-02-16 18:14:33 »

4 bytes per pixel... so need 4x the bytes in your buffer.

Cas Smiley

Offline h3ckboy

JGO Coder


Medals: 5



« Reply #22 - Posted 2009-02-16 18:21:40 »

how do I control that?
Offline Bonbon-Chan

JGO Coder


Medals: 12



« Reply #23 - Posted 2009-02-16 19:30:07 »

In "setImage(BufferedImage img)", I transform the BufferedImage in a intBuffer or a ByteBuffer.

The image that you try to load fall in a case that I didn't accounter before (it's treaky for me to make a general rules... if someone can help me).

So basicly, you need to add in "setImage(BufferedImage img)" your image type :
1  
2  
3  
4  
5  
6  
7  
8  
9  
if ( ???? )
{
   ByteBuffer imageData = ByteBuffer.allocateDirect(4 * img.getWidth() * img.getHeight());
   byte data[] = (byte[]) img.getRaster().getDataElements(0, 0, img.getWidth(), img.getHeight(), null);
   imageData.put(data);
   imageData.flip();
       
   setImage(img.getWidth(),img.getHeight(),GL11.GL_RGBA,imageData);
}



hmmmm, may be there is an error too (GL11.GL_UNSIGNED_INT). I can't test it right now :
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
{
      bind();
   
      GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height,
                        0, type, GL11.GL_UNSIGNED_INT, imageData);
 
      int error = GL11.glGetError();
      if( error != GL11.GL_NO_ERROR)
      {
        System.out.println("Texture.setImage : error OpenGL ("+error+")");
      }
 
      unbind();
    }
Offline Bonbon-Chan

JGO Coder


Medals: 12



« Reply #24 - Posted 2009-02-17 15:26:57 »

What type of image are you loading ? Can you give me a link to your image ?
I'm interresting to complet my own library  Grin
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #25 - Posted 2009-02-17 15:31:24 »

it is a simple gif. here is the link: http://www.planetalia.com/cursos/Java-Invaders/res/nave.gif


I am trying out slick. and I get this error.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
java.lang.NoClassDefFoundError: org/newdawn/slick/util/LogSystem
   at TestUtils.init(TestUtils.java:104)
   at TestUtils.start(TestUtils.java:47)
   at TestUtils.main(TestUtils.java:220)
Caused by: java.lang.ClassNotFoundException: org.newdawn.slick.util.LogSystem
   at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
   at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
   at TestUtils.init(TestUtils.java:104)
   at TestUtils.start(TestUtils.java:47)
   at TestUtils.main(TestUtils.java:220)
   at __SHELL8.run(__SHELL8.java:7)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at bluej.runtime.ExecServer$3.run(ExecServer.java:792)



thx for you guys's help Smiley
Offline bobjob

JGO Knight


Medals: 10
Projects: 4


David Aaron Muhar


« Reply #26 - Posted 2009-02-18 00:55:17 »

heckboy can you just post a link to your source code, ill go through it and take a look.

I noticed your using blueJ, maybe try get into eclipse its honestly alot better.

another good resource for LWJGL help is: www.lwjgl.org/forum

My Projects
Games, Webcam chat, Video screencast, PDF tools.

Javagaming.org with chat room
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #27 - Posted 2009-02-18 06:37:42 »

it was for this tut:

https://bob.newdawnsoftware.com/repos/slick/trunk/Slick/src/org/newdawn/slick/tests/TestUtils.java

I have tried moving to netbeans b4, I just am way to used to blueJ. I iwll look into eclipse though.
Offline bobjob

JGO Knight


Medals: 10
Projects: 4


David Aaron Muhar


« Reply #28 - Posted 2009-02-18 08:05:35 »

i used to use blueJ, but its no good for organising big projects.

My Projects
Games, Webcam chat, Video screencast, PDF tools.

Javagaming.org with chat room
Offline Bonbon-Chan

JGO Coder


Medals: 12



« Reply #29 - Posted 2009-02-18 08:16:52 »

Pssss, I forgot to put gif with transparency.... new code  Wink

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
public void setImage(BufferedImage img)
    {
      // System.out.println("IMAGE : opaque("+img.getTransparency()+") type("+img.getType()+")");
       
      if(img.getTransparency() == Transparency.OPAQUE)
      {
        if ((img.getType() == BufferedImage.TYPE_BYTE_BINARY)||(img.getType() == BufferedImage.TYPE_BYTE_INDEXED))
        {
          BufferedImage img2 = new BufferedImage(img.getWidth(),img.getHeight(),BufferedImage.TYPE_3BYTE_BGR);
          Graphics g = img2.getGraphics();
          g.drawImage(img, 0, 0, null);
          g.dispose();
          setImage(img2);
        }
        else
        {
          ByteBuffer imageData = ByteBuffer.allocateDirect(3 * img.getWidth() * img.getHeight());
          byte data[] = (byte[]) img.getRaster().getDataElements(0, 0, img.getWidth(), img.getHeight(), null);
          imageData.put(data);
          imageData.flip();
       
          setImage(img.getWidth(),img.getHeight(),GL11.GL_RGB,imageData);
        }
      }
      else
      {
        if ((img.getType() == BufferedImage.TYPE_BYTE_BINARY)||(img.getType() == BufferedImage.TYPE_BYTE_INDEXED))
        {
          BufferedImage img2 = new BufferedImage(img.getWidth(),img.getHeight(),BufferedImage.TYPE_INT_ARGB);
          Graphics g = img2.getGraphics();
          g.drawImage(img, 0, 0, null);
          g.dispose();
          setImage(img2);
        }
        else if (img.getType() == BufferedImage.TYPE_INT_ARGB )
        {
          IntBuffer imageData = BufferUtils.createIntBuffer(img.getWidth() * img.getHeight());
          int data[] = (int[]) img.getRaster().getDataElements(0, 0, img.getWidth(), img.getHeight(), null);
          imageData.put(data);
          imageData.flip();
       
          setImage(img.getWidth(),img.getHeight(),GL11.GL_RGBA,imageData);
        }
        else
        {
          ByteBuffer imageData = ByteBuffer.allocateDirect(4 * img.getWidth() * img.getHeight());
          byte data[] = (byte[]) img.getRaster().getDataElements(0, 0, img.getWidth(), img.getHeight(), null);
          imageData.put(data);
          imageData.flip();
       
          setImage(img.getWidth(),img.getHeight(),GL11.GL_RGBA,imageData);
        }
      }
    }
Pages: [1] 2
  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.

radar3301 (12 views)
2014-09-21 23:33:17

BurntPizza (30 views)
2014-09-21 02:42:18

BurntPizza (20 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (28 views)
2014-09-20 20:14:06

BurntPizza (32 views)
2014-09-19 03:14:18

Dwinin (48 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (102 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24:56
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!