Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (511)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (577)
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  
  Off-screen rendering - help me get started  (Read 4063 times)
0 Members and 1 Guest are viewing this topic.
Offline dolachin

Senior Newbie




Java games rock!


« Posted 2003-09-12 15:31:58 »

Hi,

Can someone point to a "Hello, World" type program for off-screen rendering in jogl? An OpenGL example would be a good start if it carries over into jogl easily.

Many thanks in advance!

Dola
Offline dolachin

Senior Newbie




Java games rock!


« Reply #1 - Posted 2003-09-13 14:50:41 »

Wow, no takers? I though this would be an easy one. Still, I would very much appreciate a response, because I desperately need this functionality.

Dola
Offline GKW

Senior Duke




Revenge is mine!


« Reply #2 - Posted 2003-09-14 04:30:40 »

I can post a simple render to textuer example if you want.  There is a program in the demo section that uses render to texture though.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline dolachin

Senior Newbie




Java games rock!


« Reply #3 - Posted 2003-09-14 15:41:02 »

Yes, please do! If that's the right way to do off-screen rendering, then sure. But the fact that you mentioned textures, doesn't mean that I'm limited to powers of 2 as far as dimensions, does it?

Thank you very much!

Pavel
Offline plc

Senior Newbie




Java games rock!


« Reply #4 - Posted 2003-09-14 15:46:03 »

Hi,

I am also very interested in a simple example (of the "Hello World" class) that demonstrate offscreen rendering using pbuffers. The demo program is complicated and can run only on NVIDIA cards.

I have tried to write a little one myself, but with no success. Are pbuffers supported by ATI drivers ?

I use  ATI RADEON cards (8500 and 9800).

Many thanks in advance,

Phil.
Offline GKW

Senior Duke




Revenge is mine!


« Reply #5 - Posted 2003-09-14 17:46:42 »

A pbuffer is basically a nonvisible framebuffer so you can do what ever you want with it, most likely you will want render to texture.  If you are going to render to texture then you will be limited to power of 2 unless you have a nvidia card, then you can use render to texture rectangle.  The ARB recently approved rectanglular texutres and they should be in ati drivers soon so everyone will be able to use them.  RTT does not support mipmaps yet so beware of that.  I will post the little demo tonight or tomorrow.
Offline dolachin

Senior Newbie




Java games rock!


« Reply #6 - Posted 2003-09-15 04:40:49 »

Thanks in advance for posting that demo!

So just out of curiosity, will I be constrained to the powers of 2 if I have a generic video card. I remember using Mesa in Linux and that was definitely not the case.
Offline GKW

Senior Duke




Revenge is mine!


« Reply #7 - Posted 2003-09-15 14:50:59 »

It is all up to the drivers.  RIght now if you want to use a pbuffer for something other than rendering to a texture you can make it what ever size you want.  If you are going to render to a texture then you have to use powers of two unless you have a nvidia card.  Once your video card supports opengl 1.5 then you will be able to use nonpower of two textures.  I have never used mesa but from what I know of it it is software based so they can pretty much do what ever they want.
Offline dolachin

Senior Newbie




Java games rock!


« Reply #8 - Posted 2003-09-15 17:35:40 »

Thanks for the clarification! So I'll just wait for your demo.
Offline DavidYazel

Junior Duke




Java games rock!


« Reply #9 - Posted 2003-09-15 22:30:02 »

Are pbuffers implmented for linux in the current version of JOGL?

David Yazel
Xith3D Project Founder
http://xith3d.dev.java.net

It may look complicated, but in the end it is just a bunch of triangles
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline GKW

Senior Duke




Revenge is mine!


« Reply #10 - Posted 2003-09-16 01:01:31 »

The demo is here.  It is a demo, not a tutorial but if you basically follow its layout you will probably be able to get your app running.  I have no idea if the linux pbuffers are working yet.  Let me know if there are any problems.  You should be able to run it from the command line with:

java -jar RTTDemo.jar
Offline dolachin

Senior Newbie




Java games rock!


« Reply #11 - Posted 2003-09-17 12:31:54 »

I'm sorry, this is probably a very ignorant question, but where do I find it?
Offline GKW

Senior Duke




Revenge is mine!


« Reply #12 - Posted 2003-09-17 14:13:20 »

Even bigger blue link in the upper left corner.
Offline dolachin

Senior Newbie




Java games rock!


« Reply #13 - Posted 2003-09-18 03:40:32 »

Oh, I must be color blind, I didn't realizer that "here" was a link.

Thanks for posting the demo. I'm afraid that I kind of miss the point. You seem (although I'm not sure that is the case) to draw to an offscreen buffer, but then display that buffer in the gl window. Am I correct? And if so, can you point out the four or five critical lines of code where the connection the offscreen buffer and the onscreen buffer is made. If I'm correct, that this is a very very cool feature.

Actually, I'm afraid that I may have been to vague when I said "off-screen rendering". What I really want to do is to get an image out of the hole thing. I want to do the rendering on a web server which may not even have a video card and output an image. I apologize profusely if I caused you to answer a wrong question or if you answered the right question and I totally missed the answer.

I appreciate your time,


Dola
Offline GKW

Senior Duke




Revenge is mine!


« Reply #14 - Posted 2003-09-18 14:42:48 »

If you just want to draw an image in a pbuffer and save it somewhere then just do your normal drawing and at the end call glReadPixels to save the framebuffer to system memory.  If you don't have a videocard in the server you probably will have to use mesa and I don't know much about mesa so I won't be any help there.  If you look at the source code for GLJPanel there is a display method, I don't remember the name, at the end of the file that you will want to look at for guidance.  It is basically doing exactly what you want to do, drawing with opengl and then saving to a bufferedimage.
Offline dolachin

Senior Newbie




Java games rock!


« Reply #15 - Posted 2003-09-19 00:08:42 »

Thanks for the reply.

But would that let me draw at a resolution different from that of the canvas?

(Is this question appropriate for a new thread? Maybe an example which renders offscreen and saves the result to an image - which can then be converted to java's buffered image - would be very useful and appreciated!)
Offline GKW

Senior Duke




Revenge is mine!


« Reply #16 - Posted 2003-09-19 02:16:23 »

You would be able to draw at what ever resolution mesa or the videocard drivers allow.  I will try to put something together for monday or tuesday.
Offline dolachin

Senior Newbie




Java games rock!


« Reply #17 - Posted 2003-09-19 02:56:11 »

That would be great.

Actually, I'm personally constrained to a Win32 system.

A question about what you said about resolution. I need to produce production quality (600 dpi)  8"x8" images.

I have a thinkpad with a Fire GL 9000 card. Will I be in luck?
Offline GKW

Senior Duke




Revenge is mine!


« Reply #18 - Posted 2003-09-19 03:15:43 »

The easiest way to find out would be to try and create a 4800x4800 pbuffer.  I bet it is too large but give it a try.
Offline GKW

Senior Duke




Revenge is mine!


« Reply #19 - Posted 2003-09-19 15:50:16 »

I think your card will support a 4096x4096 pbuffer.  Combine that with some AA and you should get a pretty damn nice 8x8 image.
Offline plc

Senior Newbie




Java games rock!


« Reply #20 - Posted 2003-09-19 17:04:15 »

Thank you very much GKW for this nice example. It work fine on my pc (W2000, Radeon 8500). I understand my mistakes. I will try it under Linux, but I am not sure that pbuffers are available in the ATI driver under Linux.

Phil.
Offline dolachin

Senior Newbie




Java games rock!


« Reply #21 - Posted 2003-09-19 20:55:51 »

In response to GKW's last message...

Great! I'll wait for your example with baited breath!
Offline GKW

Senior Duke




Revenge is mine!


« Reply #22 - Posted 2003-09-23 22:42:59 »

The demo is up at the same place.  Again just type:

java -jar PBDemo.jar

You can change the max size to 4096, recompile, and it should work.  I don't have your card so I don't know if that will work or not.
Offline dolachin

Senior Newbie




Java games rock!


« Reply #23 - Posted 2003-09-28 07:07:21 »

Wow, thank you very much for the post! I'm sorry I only got to testing it yesterday, got sidetracked by an urgent project.

I tested the code on my system and it works. I was able to save the scene as an image which is precisely what I want!


But a whole lot of new questions arose and I would like to describe one of my applications in some detail so I can my questions in context. I have an application which has live 3d rendering so I have a bona fide canvas in a real window, etc. There are massive vertex list which were constructed with the canvas as the GLDrawable input. Now every once in a while (often!) I have a need to "take a picture" of the scene, usually with identical view and projection settings but with different aspect ration and dramatically different resolutions. So that's the situation and here are my questions:

1. Do I have to regenerate the lists with the pbuffer as the GLDrawable?
2. If yes, can I change the dimensions of the pbuffer without regenerating the lists? It would be a significant drag on the resources  if I had to regenerate the lists every time I change the resolution.
3. Can I have my regular canvas createOffscreenDrawable()?
4. What does it mean that "PBuffers are lazily created"?
5. Finally, do I have to have a GLEventListener? Since I have my GLDrawable (the pbuffer!) can I just give gl commands?

Once again, very many thanks. It's beginning to look like the switch to Jogl will actually work!!!

Dola
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #24 - Posted 2003-09-29 00:42:03 »

Quote
1. Do I have to regenerate the lists with the pbuffer as the GLDrawable?


No, the pbuffer shares display lists with its parent drawable. Presumably there should be some way of disabling this but for now it's hard-wired.

Quote
2. If yes, can I change the dimensions of the pbuffer without regenerating the lists? It would be a significant drag on the resources  if I had to regenerate the lists every time I change the resolution.


Right now JOGL's pbuffers don't support resolution changes; setSize() throws an exception. Unfortunately they also don't get disposed correctly yet so that creating a new one each time you need to change resolution will eventually run out of resources. You can work around this by making one as large as you're going to need at the beginning of your program. Once you run up against these limitations please feel free to file a bug.

Quote
3. Can I have my regular canvas createOffscreenDrawable()?


Yes, that's how it's intended to work.

Quote
4. What does it mean that "PBuffers are lazily created"?


It means that if you call display() immediately after creating the GLPbuffer then it is not guaranteed that your GLPbuffer will call your GLEventListener. Often it takes one or more calls to display(); additionally the parent GLDrawable needs to be visible.

Quote
5. Finally, do I have to have a GLEventListener? Since I have my GLDrawable (the pbuffer!) can I just give gl commands?


You need a GLEventListener as with any other GLDrawable. It is only valid to call OpenGL from within that GLEventListener's display (), init(), and reshape() methods as usual.
Offline dolachin

Senior Newbie




Java games rock!


« Reply #25 - Posted 2003-09-29 17:28:47 »

Thank you so much for addressing each one of the questions. You guys are great!

One more though (since I don't seem to get this to work in the context of my application).

Does the canvas and the pbuffer each need its own GLEventListener you can they share one? Especially in my case where the drawing is presumably the same.

Thanks.
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #26 - Posted 2003-09-30 19:04:43 »

Quote
Does the canvas and the pbuffer each need its own GLEventListener you can they share one? Especially in my case where the drawing is presumably the same.


They can share the same GLEventListener although you need to be careful about thread-safety issues, in particular if your GLEventListener has any state in it. You may want to instantiate two objects of the same class rather than trying to share the same listener object between the drawables.
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 (52 views)
2014-10-17 03:59:02

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

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

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

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

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

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

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

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

BurntPizza (85 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!