Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (604)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (654)
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  
  RenderToTexture Question  (Read 2766 times)
0 Members and 1 Guest are viewing this topic.
Offline Therion_

Senior Newbie

« Posted 2010-05-26 06:56:46 »

hello @all,

i got an strange problem with the fbo's since a short time,
it was working a long time but yesterday the code stops with an out_of_memory.
the only thing that changed was an update of java.

i dont know if my code was unstable or is there any other method?

much greetings and thanks for any help Smiley


import com.sun.opengl.util.FBObject;

   static IntBuffer fbo         = BufferUtil.newIntBuffer(1);
   static IntBuffer depth       = BufferUtil.newIntBuffer(1);
   static IntBuffer fbo_texture = BufferUtil.newIntBuffer(1);

static void initializeFBO(GLAutoDrawable drawable,int width, int height)
                GL2 gl = drawable.getGL().getGL2();

                gl.glGenFramebuffers(1, FSO_ENGINE.fbo);
!->>           gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, FSO_ENGINE.fbo.get(0));  << -at this point the app gets memory error!
           gl.glGenRenderbuffers(1, FSO_ENGINE.depth);

           gl.glBindRenderbuffer(GL2.GL_RENDERBUFFER, FSO_ENGINE.depth.get(0));
           gl.glRenderbufferStorage(GL2.GL_RENDERBUFFER, GL2.GL_DEPTH_COMPONENT24, width, height);
           gl.glBindRenderbuffer(GL2.GL_RENDERBUFFER, 0);
           gl.glFramebufferRenderbuffer(GL2.GL_FRAMEBUFFER, GL2.GL_DEPTH_ATTACHMENT, GL2.GL_RENDERBUFFER, FSO_ENGINE.depth.get(0));
           gl.glGenTextures(1, FSO_ENGINE.fbo_texture);
           gl.glBindTexture(GL.GL_TEXTURE_2D, FSO_ENGINE.fbo_texture.get(0));
           gl.glTexParameteri(GL.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);
           gl.glTexParameteri(GL.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR);
                gl.glTexParameterf(GL.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S    , GL2.GL_CLAMP);
        gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T     , GL2.GL_CLAMP);

                gl.glTexParameterf(GL.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S    , GL2.GL_CLAMP_TO_EDGE);
        gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T     , GL2.GL_CLAMP_TO_EDGE);

           gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, wid,hei, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, null);
Offline lhkbob

JGO Knight

Medals: 32

« Reply #1 - Posted 2010-05-26 15:37:16 »

Question: Is it a Java OutOfMemory exception or OpenGL returning an out of memory error? I don't see how the code you've posted could have out of memory errors in Java.  Have you tried experimenting with changing the heap size to see if that solves the problem, or measuring how much of the heap is used up?

Offline Therion_

Senior Newbie

« Reply #2 - Posted 2010-05-26 19:43:27 »

here some infos:
-Djava.library.path="lib" -Xmx1024m -Xms1024m

the application break after the
gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, FSO_ENGINE.fbo.get(0));
line and return with error (see below)

i am not very experienced with such error messages in java
and didnt know what to do.
i take a look at some examples,but all i found was written in c++/opengl
and that could net help me ( my code was working , but monday...)

maybe the IntBuffer could be a problem, is there anything to take care?

Exception in thread "AWT-EventQueue-0" Thread[AWT-EventQueue-0,6,main] glGetError() returned the following error codes after a call to glBindFramebuffer(<int> 0x8D40, <int> 0x1): GL_OUT_OF_MEMORY ( 1285 0x505),
        at org.unterhaltungsuniversum.OPEN_GL.initializeFBO(
        at org.unterhaltungsuniversum.FSO_ENGINE.init(
        at com.sun.opengl.impl.GLDrawableHelper.init(
        at com.sun.opengl.impl.GLDrawableHelper.invokeGL(
        at sun.awt.RepaintArea.paintComponent(
        at sun.awt.RepaintArea.paint(
        at java.awt.Component.dispatchEventImpl(
        at java.awt.Component.dispatchEvent(
        at java.awt.EventQueue.dispatchEvent(
        at java.awt.EventDispatchThread.pumpOneEventForFilters(
        at java.awt.EventDispatchThread.pumpEventsForFilter(
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(
        at java.awt.EventDispatchThread.pumpEvents(
        at java.awt.EventDispatchThread.pumpEvents(
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online Riven
« League of Dukes »

« JGO Overlord »

Medals: 1021
Projects: 4
Exp: 16 years

Hand over your head.

« Reply #3 - Posted 2010-05-26 21:17:12 »

What happens if you prepend this line:
           FSO_ENGINE.fbo.rewind(); // <---
           gl.glGenFramebuffers(1, FSO_ENGINE.fbo);
           gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, FSO_ENGINE.fbo.get(0));

is the position of your buffer is non-zero, JOGL might (or might not?) use that offset, to write the handle.

if you bind the handle at index zero (fbo.get(0)) it might refer to another handle, or some random region in CPU-memory where it tries to read the width/height, and at a random memory location, that might contain any (bogus) value, tripping your driver.

just guessing...

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline Therion_

Senior Newbie

« Reply #4 - Posted 2010-05-27 05:46:16 »

the rewind sounds good, but didnt work..same error stays.  Cry

i also try to use ...  fbo.reset();  , nothing happend

memory is more that enough...i reduce the number of used textures to
minimum(2 x 256*256) ..nothing happend.

and i got no memory killer arrays in the engine...all very simple

but i am very sure that the
    static IntBuffer fbo              = BufferUtil.newIntBuffer(1);
    static IntBuffer depth          = BufferUtil.newIntBuffer(1);
    static IntBuffer fbo_texture = BufferUtil.newIntBuffer(1);
must be the problem...

Online Riven
« League of Dukes »

« JGO Overlord »

Medals: 1021
Projects: 4
Exp: 16 years

Hand over your head.

« Reply #5 - Posted 2010-05-27 05:57:57 »

You aren't running out of Java memory, then you'd have a OutOfMemoryError, but you're seeing the driver reporting a GL_OUT_OF_MEMORY state, which indicates a lack of vRAM.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline Therion_

Senior Newbie

« Reply #6 - Posted 2010-05-27 06:42:10 »


i found what the app disturbed.
-the nvidia desktop manager software eats all vram!
(after deaktivating this program all works fine again
(i use 2 screen ,and got no need of any extra screen manager... must be activated in any way)

thanks for all answers!  Cheesy

(i program on older geforce go7300 notebook... on other hardware the problem didnt exist)
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

SHC (28 views)
2015-08-01 03:58:20

Jesse (20 views)
2015-07-29 04:35:27

Riven (40 views)
2015-07-27 16:38:00

Riven (22 views)
2015-07-27 15:35:20

Riven (25 views)
2015-07-27 12:26:13

Riven (15 views)
2015-07-27 12:23:39

BurntPizza (37 views)
2015-07-25 00:14:37

BurntPizza (46 views)
2015-07-24 22:06:39

BurntPizza (31 views)
2015-07-24 06:06:53

NoxInc (37 views)
2015-07-22 22:16:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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‑
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!