Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Java 3D / November 2003

Tip: Looking for answers? Try searching our database.

problems with display lists using openGL

Thread view: 
Jim H - 19 Nov 2003 21:49 GMT
I'm having problems with openGL display lists using gl4java. I'm not sure
if this is a java/gl4java specific question, or if it applies to openGL in
general.

I'm trying to create display lists lazily, ie only compiled as needed. This
is because I have a few things to draw that are unlikely to be needed, but
if they are needed are going to have to be drawn many times. I realise that
once a display list has been created it may not be changed, but thought I
could create them anytime.

so in display() I have:

private static final int LIST_NO = 1;

if( gl.glIsList( LIST_NO ) )
{   gl.glCallList( LIST_NO );
}else
{   System.out.println( "defining new list for " + LIST_NO );
   gl.glNewList( LIST_NO , GLEnum.GL_COMPILE_AND_EXCECUTE )
       gl.glBegin( //... yada yada
       //... yadda yadda
       gl.glEnd();
   gl.endList();
   if( gl.glIsList( LIST_NO ) )
       System.out.println( "confirmed list created" );   
}

Now then, I get "defining new list for 1" and "confirmed list created"
printed to standard out on EACH repaint, not just once, so OGL it is
creating the list each time and then discarding it before the next call to
display()

If I create a display list in init() I don't have this problem - they are
held until I delete or replace them; But I can't declare all my lists there
- my program doesn't know how every object will look at initialization.

Please could somebody help me out here, I'm sure I'm missing somthing
simple!

Signature

Jim H    jh           
        @333
        .org

Andy V - 20 Nov 2003 03:56 GMT
> I'm having problems with openGL display lists using gl4java. I'm not sure
> if this is a java/gl4java specific question, or if it applies to openGL in
[quoted text clipped - 5 lines]
> once a display list has been created it may not be changed, but thought I
> could create them anytime.

Yes, you certainly can do this.

> so in display() I have:
>
[quoted text clipped - 17 lines]
> creating the list each time and then discarding it before the next call to
> display()

Curious. You don't create new OpenGL contexts every time, do you? Other
than that, someone is deleting the list.

Two suggestions:

I wouldn't use GL_COMPILE_AND_EXECUTE -- I'd compile and then call it.

Use glGenLists() instead of LIST_NO.
--
Andy V
Jim H - 20 Nov 2003 14:27 GMT
more from the 'Andy V school' of comp.graphics.api.opengl-ism:

>> I'm having problems with openGL display lists using gl4java. I'm not
>> sure if this is a java/gl4java specific question, or if it applies to
[quoted text clipped - 32 lines]
> Curious. You don't create new OpenGL contexts every time, do you?
> Other than that, someone is deleting the list.

Interesting point... I think I'm getting to the bottom of it now...

I put a call to System.out.println( gld.getGLContext() ); in the
display() method, and the context IS different each time!

I'm new to open GL, so I'm not so well up on contexts, but I had been
resizing the window to get it to refresh, and it seems this creates a new
context - is this the usual behavoir?

So the reson it was working when I made the diplay list in init() is
because init was being called each time too - when the new context was
made!

If I refresh the window by dragging somthing in front of it my display
lists persist correctly.

Is there a way to keep the state if the window is refreshed, or must
everything be loaded in again? I suppose  this is why openGL games like
q3a reload the level when you just change the resolution?

Thanks for the help so far!

> Two suggestions:
>
> I wouldn't use GL_COMPILE_AND_EXECUTE -- I'd compile and then call it.
>
> Use glGenLists() instead of LIST_NO.

Tried these, made no difference.

Signature

Jim H    jh           
        @333
        .org

Andy V - 21 Nov 2003 00:44 GMT
>>Curious. You don't create new OpenGL contexts every time, do you?
>>Other than that, someone is deleting the list.
[quoted text clipped - 3 lines]
> I put a call to System.out.println( gld.getGLContext() ); in the
> display() method, and the context IS different each time!

I was just grasping at straws -- I didn't really think you were doing that.

> I'm new to open GL, so I'm not so well up on contexts, but I had been
> resizing the window to get it to refresh, and it seems this creates a new
> context - is this the usual behavoir?

Nobody creates a new OpenGL context but you, so you should change your
code to create the OpenGL context in an initialization routine, not the
resize routine.

>>Two suggestions:
>>
[quoted text clipped - 3 lines]
>
> Tried these, made no difference.

These were side suggestions not related to the problem at hand.

--
Andy V
Jim H - 22 Nov 2003 23:40 GMT
> Nobody creates a new OpenGL context but you, so you should change your
> code to create the OpenGL context in an initialization routine, not
> the resize routine.

Except, it seems, when using GL4Java! It creates a new one whenever the
GLDrawable is resized. I've got it sorted now, thanks for the help!

Signature

Jim H    jh           
        @333
        .org



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.