Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: 1 [2]
31  Java Game APIs & Engines / JOGL Development / Re: glGetTexImage on: 2005-09-23 12:14:04
Please ignore the previous post, it was sent accidentally to this forum.

Sorry about that!  Undecided
32  Java Game APIs & Engines / JOGL Development / Re: glGetTexImage on: 2005-09-23 12:00:51
You were right,  but now I get another strange behavior. Here is my code:
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  
           
 //First, read already existing texture data, and put it to an image.
            int id = parent.model.textureRegistry.getFirstAvailableTexture(bounds);
            Texture t = parent.model.textureRegistry.getTexture(id);
            //System.out.println("Will use texture: "+id);
            BufferedImage image = new BufferedImage(t.width,t.height, BufferedImage.TYPE_INT_ARGB);
            DataBufferInt buffer = (DataBufferInt) image.getRaster().getDataBuffer();
            gl.glGetTexImage(GL.GL_TEXTURE_2D,0,GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV,buffer.getData());

           
 
            BufferedImage backgroundArea = null;
            if (t.bounds.equals(bounds)){
                System.out.println("Hey, using our own texture!");
            }


            JLabel l = new JLabel(new ImageIcon(image));
            JFrame f = new JFrame("Input");
            f.setLayout(null);
            l.setBounds(0,0,256,256);
            l.setBorder(BorderFactory.createLineBorder(Color.yellow));
            f.add(l);
                     
            f.setSize(300,300);
            f.setVisible(true);
           
            BufferedImage i = Mosaicker.mosaic2(image, new GeographicFeatureArray(),
                    bounds,
                    new Dimension(128,128),
                    BufferedImage.TYPE_INT_ARGB,
                    Mosaicker.INTERPOLATION_NEAREST_NEIGHBOUR);
            image.flush();
            image = null;
            imageGeoObjects.clear();
           
            if (i != null){
                DataBufferInt buffer2 = (DataBufferInt) i.getData().getDataBuffer();
                int[] arr = new int[buffer2.getData().length];
                System.arraycopy(arr,0,buffer2.getData(),0,arr.length);
                gl.glShadeModel(GL.GL_FLAT);
                gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1);
               
                gl.glBindTexture(GL.GL_TEXTURE_2D, textureID);
                /*
                gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_DECAL);
                gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
                gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);
                gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
                gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
/*                
                gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, 4, i.getWidth(), i.getHeight(), 0,
                                GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, arr);
               
                gl.glBindTexture(GL.GL_TEXTURE_2D, textureID);
*/
               
//                parent.model.textureRegistry.add(texture = new Texture(textureID, key,
//                        bounds, i.getWidth(), i.getHeight()));    
               
                //i.flush();        
               
            }
           
            dirtyData = false;
33  Java Game APIs & Engines / Java 2D / drawImage alters source image on: 2005-09-23 09:49:57
Hi all,

I'm trying to draw a BufferedImage (image1) on another BufferedImage (image2) , using drawImage(Image i, int x, int y, ImageObserver o). Before and after calling the drawImage on the graphics of the second image, I show a JFrame containing a debug Jlabel, which has an icon with the image1. The problem is that if drawImage is called, the image1, is shown corrupted in both the frames although the one of them is constructed before calling the drawImage. drawImage always returns true, so this is not a "not ready image" problem.

What is causing the corruption of the source image? Any ideas?

TIA
N
34  Java Game APIs & Engines / JOGL Development / Re: glGetTexImage on: 2005-09-21 13:29:54
I've done some testing, and it seems that for some reason the image.getRaster().setSamples() has no result. Instead, when I used  the image.setRGB(), everyting works fine.

However, the problem related to "non INT" formats and types in images and textures remains. Also, if anyone has any idea about creating textures from other alteady existing textures, or mosaicking images at the GPU, please let me know.
35  Java Game APIs & Engines / JOGL Development / glGetTexImage on: 2005-09-21 12:02:42
Hi all

I'm trying to get a texture image from the GPU back into a BufferedImage, but I can't get it right. This is the code:
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  
            BufferedImage bkgImage = new BufferedImage(256,256, BufferedImage.TYPE_INT_ARGB);

            //load image data...
           
            DataBufferInt buffer = (DataBufferInt) bkgImage.getRaster().getDataBuffer();
            gl.glShadeModel(GL.GL_FLAT);
            gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1);
            gl.glBindTexture(GL.GL_TEXTURE_2D, backgroundTexturePointerID);
            gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_DECAL);
            gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
            gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);
            gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
            gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
           
            gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, 4, bkgImage.getWidth(), bkgImage.getHeight(), 0,
                            GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, buffer.getData());


            gl.glBindTexture(GL.GL_TEXTURE_2D, backgroundTexturePointerID);
            bkgImage.flush();
            bkgImage = null;

           
            int[] pixels = new int[256*256];
            gl.glGetTexImage(GL.GL_TEXTURE_2D,0,GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV,pixels);
            BufferedImage image = new BufferedImage(256,256, BufferedImage.TYPE_INT_ARGB);
            image.getRaster().setSamples(0,0,256,256,0,pixels);
           
            JLabel l = new JLabel(new ImageIcon(image));
            JFrame f = new JFrame();
            f.setLayout(null);
            l.setBounds(0,0,256,256);
            l.setBorder(BorderFactory.createLineBorder(Color.yellow));
            f.add(l);
           
            f.setSize(300,300);
            f.setVisible(true);


The above code should show the same image that was loaded in the first place and was used for the texture. Instead, I get  all kinds of strange results, depending on the pixel format and type I use when calling glGetTexImage.

a) Should pixel format and type when calling the glGetTexImage be the same with the ones used when specifying the texture with glTexImage, or there is an auto conversion between different formats?

b) What happens when other pixel formats are used? For example, if the pixel format for the texture is BGR, and type is GL_UNSIGNED BYTE, how can one set the byte[] of pixels to a bufferedImage? setSamples can't use byte arrays, so does an int array have to be created from the byte array?

c) is it possible to create a texture from other existing texture data, without getting all the texture images back to CPU/memory, combine them and then put them in a new texture?

(Sorry about the too many questions)

TIA
N
36  Java Game APIs & Engines / JOGL Development / Re: Single thread workaround and ATI cards on: 2005-09-16 07:59:15
I installed the DebugGL pipeline and it actually found an error which in at least one case caused the context current problem. There was a wrong glPolygonMode call (gl.glPolygonMode(GL.GL_POLYGON_MODE,GL.GL_FILL))  instead of the correct one (gl.glPolygonMode(GL.GL_FRONT,GL.GL_FILL)). Up until now, the problem has not appeared again, so it must have been the cause for the entire situation. However, i'll keep testing it, just in case...(with the DebugGL pipeline on).

Thanks again Ken! With your hints, not only the problem is (possibly  Wink ) resolved, but my graphics card has a new driver (since 2003). Maybe I'll send an e-mail to acer, to finally update the driver at their site...
37  Java Game APIs & Engines / JOGL Development / Re: Single thread workaround and ATI cards on: 2005-09-15 19:54:11
Unlucky me! It just reappeared. So I guess driver and jogl version are out of the suspects....
38  Java Game APIs & Engines / JOGL Development / Re: Single thread workaround and ATI cards on: 2005-09-15 19:50:27
I'm running the las jogl version, but I wasn't aware of guru3d.com (thanks!). I downloaded a new driver and installed it on the laptop. (At last, new driver!). So far, it seems to work without problems, but the problem I mentioned in my previous post, is not a consistent one, it appears occasionally. So much more testing is needed.

In the beginning I thought that the problem was caused because of calling synchronoysly  wait() or notify() for a thread inside the display method, and that thread also invoked display() again. However that didn't seem to be the issue, because the same problem occured when I used just a timer which called display() every 30 ms.

Ken, considering your experience, do you think that this is a driver problem or does it have to do with the application itself?
39  Java Game APIs & Engines / JOGL Development / Single thread workaround and ATI cards on: 2005-09-15 15:26:38
Hi all

I'm building an app using jogl that uses multithreading, and I'm using a laptop with an ATI Mobility Radeon 9000. I'm familiar with problems concerning ATI cards and multithreading in jogl, and I know that this problem is solved by using the single thread workaround when making a context current. However, from time to time I get the famous "Error making context current" exception, with a WGL error code, and the program crashes. I had posted to this forum a topic relative to this some time ago, but at that time I thought that it was a thread scheduling problem...

Has anyone using an ATI card gets the same, even rarely? Also, does this "ATI workaround solution" fix a problem that occurs when calling display() from different threads,  or does it fix a problem that occurs when other threads are running (even if they don't call display())? I notice that in my case the problem is caused by using more than one threads in the app, and it's doesn't depend on different threads calling display().

Could this be related to driver issues? The laptop is an ACER Travelmate, and the drivers for the graphics card have not been updated since 2003....

If anyone can give a hint, I'd be grateful. I've run out of ideas with this one...
40  Java Game APIs & Engines / JOGL Development / Re: Threads and JOGL on: 2005-08-15 08:03:03
I've done some debugging, and the results "agree" with your suggestions. Because of scheduled rendering calls,  I can't immediately "block" my thread, when render occurs.

Thank you for your time and suggestions!
41  Java Game APIs & Engines / JOGL Development / Re: Threads and JOGL on: 2005-08-15 05:54:44
I've tried yield() in the background thread and so far this seems to work, but I'm not certain it's 100% correct. I'll also tried lowering the priority of the thread. I 'm not sure I understand what you exactly mean when you say that "The operating system should handle scheduling of your work". My thread should somehow cause display to run() because some data have been loaded...I don't think its a subject of arranging rendering calls. I'm trying to find the right way to provide hints to my background thread, as you suggested so as not to interfere with the rendering process. What exactly do you mean by saying that I must do this at a coarse-grained level?

My card is a Mobility Radeon 9000 on an Acer Travelmate, so it uses custom vendor drivers. Its drivers have not been updated since 2003 and some of the jogl demos (render to texture example and others) are not running. I'll try to see what happens when using threads in the jogl demos, and check out the result of PrintExt.
42  Java Game APIs & Engines / JOGL Development / Re: Threads and JOGL on: 2005-08-14 22:28:11
Yes, I'm using the last version, but I get the same problem using older versions too.

What I'm trying to do is not a scheduling mechanism. I'm trying to load data from disk when no rendering occurs (or when the camera's position and orientation doesn't change), so as to keep a high frame rate that is not stalled by loading data. So, data loading is done in a thread, and the thread runs only when no rendering occurs. When some data are loaded, the view must be updated, so my thread must somehow cause a rendering to happen. That exact point seems to cause the whole problem.

Using an Animator might help with the refreshing, but it would leave minimum render idle time to use for loading data (not to mention that the CPU load is significantly higher).
43  Java Game APIs & Engines / JOGL Development / Re: Threads and JOGL on: 2005-08-14 08:22:02
I came across the 2004 JavaOne presentation for jogl, and in slide 20 the following guidelines were provided for multithreading:

Multithreading

AWT events like mouse and keyboard events
are delivered on AWT event queue thread
• Not allowed / possible to make OpenGL calls
directly inside these listeners
─ Though you can schedule or force a redraw
• Instead, pass information between these
threads and any animation threads via
member data
─ Use appropriate synchronization
─ Read data exactly once in your display() method


So, the key to the problem must be to avoid accidental GL calls by two different threads. I thought I was blocking such cases in my application, but when I avoid using mutiple threads, there is no problem.. I suppose I must check it thoroughly.
44  Java Game APIs & Engines / JOGL Development / Threads and JOGL on: 2005-08-12 15:16:32
Hi all,

I'm trying to make an app, where a thread can perform various tasks when no rendering occurs. When render occurs (i.e display() is called), a flag in the thread is set to true, and the thread waits until the flag is set to false. That flag is set true at the begining of the display(), and is set to false when display ends. The thread's run can call an update method, which calls display(), but only if display isn't running at that time.

The problem is that is some occasions I get the "Error making context current" GLException message, accompanied by a number: -1073282975, and the whole thing freezes.. Does anyone know what does this number mean? What would be an efficient way to use threads that can cause repaint whithout getting the above exception?

TIA
N
45  Java Game APIs & Engines / JOGL Development / Re: ATI and lightweight acceleration? on: 2005-02-15 04:57:54
Good job Ken! Hope the 1.1b09 release isn't far....
46  Java Game APIs & Engines / JOGL Development / ATI and lightweight acceleration? on: 2005-02-14 08:53:46
Hi all,

I'm trying to figure out if the lightweight acceleration provided   by the last JOGL version works on ATI cards. I've tried the JRefract demo with Nvidia cards and everything works like a charm, but in two ATI cards, performance results are the same with previous JOGL versions.

Does anyone, with any ATI configuration managed to see improved lightweight performance? Does anyone know if  this is a general driver problem for ATI cards?

N
47  Java Game APIs & Engines / JOGL Development / Re: gluPerspective on: 2005-02-11 19:48:47
You're absolutely right! Thanks for your tip!
48  Java Game APIs & Engines / JOGL Development / gluPerspective on: 2005-02-11 07:32:20
Hi all,

I've downloaded 1.1.08b and I'm trying to test it with my current code. However, I get the following exception:

java.lang.UnsatisfiedLinkError: dispatch_gluPerspective
     at net.java.games.jogl.impl.GLUImpl.dispatch_gluPerspective(Native Method)
     at net.java.games.jogl.impl.GLUImpl.gluPerspective(GLUImpl.java:409)

I also get errors like:

java.lang.NoSuchMethodError: net.java.games.jogl.GLU.gluUnProject(DDD[D[D[I[D[D[D)Z

Any ideas why this is happening in this JOGL version? The previous one worked OK with my current code.

N
49  Java Game APIs & Engines / JOGL Development / Re: Problem with GLJPanel on: 2005-01-12 05:53:29
Try turning double buffering off in GLCapabilities (default is on), before constructing GLJPanel. It worked for me...

I hope that hardware accelerated GLJPanel will be available soon...
50  Java Game APIs & Engines / JOGL Development / glDrawArrays on: 2004-04-23 19:21:42
Can anyone point me to a working demo using glDrawArrays()? I can't make it work...
Here is my code :

           gl.glEnableClientState(GL.GL_COLOR_ARRAY);
           gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
           float[] color = new float[]{0,1,0,0,1,0,0,1,0,0,1,0};
           FloatBuffer fbuf = ByteBuffer.allocateDirect(0).asFloatBuffer();

           fbuf.wrap(color);
           gl.glColorPointer(3,GL.GL_FLOAT,0,fbuf);
           float[] mypoint = new float[]{300,300,200,200,300,100,100,200};
           FloatBuffer ibuf = ByteBuffer.allocateDirect(0).asFloatBuffer();
           ibuf.wrap(mypoint);
           gl.glVertexPointer(2,GL.GL_FLOAT,0,ibuf);
           gl.glDrawArrays(GL.GL_LINE_LOOP,0,4);
51  Java Game APIs & Engines / JOGL Development / Re: pbuffers and ATI on: 2004-03-19 04:26:20
!!!! I haven't noticed that texture coords had changed! (How stupid of me, that's what happens when someone uses replaceAll when editing code...)

Thanks GKW, it now works fine!
52  Java Game APIs & Engines / JOGL Development / Re: pbuffers and ATI on: 2004-03-18 15:51:58
OK, here (http://students.ceid.upatras.gr/~mantesat/RTTDemo.java) is the modified code of GKW's RTTDemo. Note that I don't want to use rectangular textures with ATI cards, but only square, power of two textures.
53  Java Game APIs & Engines / JOGL Development / Re: pbuffers and ATI on: 2004-03-18 09:15:44
Clearing the color for the framebuffer with a specific color does work but when using GL_TEXTURE_2D mode

a) on ATI cards, if I use a red clear color, I see a red cube. On nVidia cards, I see a white cube

b) when using setOffscreenRenderToTextureRectangle and GL_TEXTURE_2D, ATI card throws the wglChoosePixelFormatARB() failed exception, and nVidia displays a white cube (again)

so, the code only seems to work when GL_TEXTURE_RECTANGLE_NV mode is used and offscreenRenderToTextureRectangle  is enabled. The only thing I did was changing texture modes, and using(or not) offscreenRenderToTextureRectangle capabilities. Since I use square, power of two textures, and the behavior of the two cards for the same code and GL_TEXTURE_MODE is totally different, I'm starting to think that pbuffer  rendering with jogl DOESN'T work on ATI cards. GKW, if it is not too much trouble, would you like me to send you the modified RTTDemo code so as to check it yourself?

N
54  Java Game APIs & Engines / JOGL Development / Re: pbuffers and ATI on: 2004-03-17 18:46:04
GKW, you were right, I had not set GL_TEXTURE_2D mode. But still, the problem partially remains : I now see a black cube (instead of a white one), but there is nothing drawn on the texture. The same thing happens when testing it with nVIDIA. My pbuffer is a power of two and it is not double buffered...
55  Java Game APIs & Engines / JOGL Development / pbuffers and ATI on: 2004-03-17 11:44:59
Hi all,

I have a problem related with pbuffer rendering and ATI cards.....I was trying to make GKW's RTTDemo work with ATI cards so as to see how rendering to texture works. Although the same demo works flawlessly with NVIDIA cards, when I'm trying to use an ATI card I get the following exception :

net.java.games.jogl.GLException: pbuffer creation error: wglChoosePixelFormatARB() failed...

Although I changed the texture_rectangle parameters so as the demo to use only square power of two drawable contexts, the problem remains (in ATI cards).  Searching a little more I found out that if
GLCapabilities.setOffscreenRenderToTextureRectangle( true );
wasn't used, then the demo executed normally, but without rendering anything to texture! The same code executed perfectly on an NVIDIA card, so there must be something about ATI cards, or I might be missing something obvious.

Any clues? GKW?

TIA

N
56  Java Game APIs & Engines / JOGL Development / Re: Render to Texture? on: 2004-03-16 11:58:42
Thank you all for your answers! GKW, I've tried the demos, and they work as you said, so I'll try to learn from them. Mithrantir, I can't find your e-mail address (where should I look?)
57  Java Game APIs & Engines / JOGL Development / Render to Texture? on: 2004-03-15 12:54:08
Hi all,

anyone used pbuffers to render to texture with jogl? I'm trying to follow the examples of pure OpenGL, concerning pbuffers, but when I use JoGL, I can't find methods such as wglGetCurrentContext. Does anybody know where i can find some sample jogl code for pbuffer rendering?

TIA
N
Pages: 1 [2]
 
xxMrPHDxx (12 views)
2017-11-21 16:21:00

xxMrPHDxx (10 views)
2017-11-21 16:14:31

xxMrPHDxx (10 views)
2017-11-21 16:10:57

Ecumene (113 views)
2017-09-30 02:57:34

theagentd (148 views)
2017-09-26 18:23:31

cybrmynd (246 views)
2017-08-02 12:28:51

cybrmynd (242 views)
2017-08-02 12:19:43

cybrmynd (242 views)
2017-08-02 12:18:09

Sralse (257 views)
2017-07-25 17:13:48

Archive (875 views)
2017-04-27 17:45:51
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!