Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > opengl & disappearing objects

opengl & disappearing objects
Thread Tools
Fresh-Faced Recruit
Join Date: Jan 2002
Location: chicago
Status: Offline
Reply With Quote
Jan 21, 2002, 05:15 PM
 
I am porting a renderer from windows to mac, and everything works great on the windows machine. The problem I'm running into is on the mac with objects disappearing. Static objects don't disappear, but after a few simple animation, the objects that are animating disappear.

I am using display lists, and my pop/push calls seem to be matched.

Any ideas are greatly appreciated.

thanks,
Shawn
     
Fresh-Faced Recruit
Join Date: May 2001
Status: Offline
Reply With Quote
Jan 21, 2002, 08:00 PM
 
Originally posted by Shawn Lawson:
<STRONG>I am porting a renderer from windows to mac, and everything works great on the windows machine. The problem I'm running into is on the mac with objects disappearing. Static objects don't disappear, but after a few simple animation, the objects that are animating disappear.

I am using display lists, and my pop/push calls seem to be matched.

Any ideas are greatly appreciated.

thanks,
Shawn</STRONG>
Make sure that you are in the proper matrix mode. If you are applying transformations to the projection matrix instead of the model matrix you could get strange results. Also you can always call <BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>glLoadIdentity();</font>[/code] to make sure that you are back at the identity matrix for your matrix mode.

to switch matrix modes you can use

<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>glMatrixMode(GL_MODELVIEW);</font>[/code]

or

<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>glMatrixMode(GL_PROJECTION);</font>[/code]

depending on your needs.

Hope that helps.

If you don't figure it out I'd be happy to look over your source code to see if I can find the problem.
     
Fresh-Faced Recruit
Join Date: Jan 2002
Location: chicago
Status: Offline
Reply With Quote
Jan 21, 2002, 08:41 PM
 
Thanks, I'll check into these things. The main concern that I have right now is that the same animation works perfectly on a win2000 machine. Since the GL calls shouldn't need to change I'm a bit flustered with why I'm not getting the same results. I "think" that I have the appropriate AGL calls set up in the right places, because I'm not getting any errors and everything else seems to be working.

thanks again.
     
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Jan 22, 2002, 10:21 PM
 
The only difference that you could have between the two systems is the API where the OpenGL is embedded in the display. For example, if you are using an NSView subclass to hold the OpenGL, you may have to call [theView display] or [theView setNeedsDisplay:YES]. Other than that, the graphics calls themselves should be identical.

Hope that helps,
Jeff.
Spectral Class
"Shedding Light on Innovation"
     
Fresh-Faced Recruit
Join Date: Jan 2002
Location: chicago
Status: Offline
Reply With Quote
Jan 22, 2002, 11:40 PM
 
we're using JNI to include an opengl renderer into a Java appication onto a sun.awt.MacDrawingSurface, because we couldn't get the awt in the JavaEmbedding framwork to cooperate. Yea I agree that graphics calls shouldn't need to change. That's why I'm wondering what's up.

Lets pretend that I have a chicken rotating in a world and a bunny that doesn't move. After a few spins (12-15 it varies) the chicken disappers and the bunny doesn't. If the bunny then begins to rotate, it instantly disappears like the chicken. I don't receive any gl or agl errors. It's all very strange. We're starting to wonder if there is a osx opengl bug. But since we can't easily track it down, we don't know.

thanks
Shawn
     
Fresh-Faced Recruit
Join Date: May 2001
Status: Offline
Reply With Quote
Jan 23, 2002, 01:37 AM
 
@nally posted by Shawn Lawson:
<STRONG>we're using JNI to include an opengl renderer into a Java appication onto a sun.awt.MacDrawingSurface, because we couldn't get the awt in the JavaEmbedding framwork to cooperate. Yea I agree that graphics calls shouldn't need to change. That's why I'm wondering what's up.

Lets pretend that I have a chicken rotating in a world and a bunny that doesn't move. After a few spins (12-15 it varies) the chicken disappers and the bunny doesn't. If the bunny then begins to rotate, it instantly disappears like the chicken. I don't receive any gl or agl errors. It's all very strange. We're starting to wonder if there is a osx opengl bug. But since we can't easily track it down, we don't know.

thanks
Shawn</STRONG>[/QUOTE]


Well the second case you describe definitely sounds like a transformation matrix problem. Your objects are being transformed out of the view volume.

However the first case you describe is definitely peculiar.

I've experienced similar problems porting from OpenGL apps between Windows and OS X. The most notable being that for some reason glLoadIdentity(); doesn't appear to actually do anything on Windows2000, and in some cases actually corrupts the transformation matrix. However the OpenGL on OS X has thus far always behaved as I expect it to.

For starters is there some reason that you are using AGL? You shouldn't need that framework if you are using OpenGL on OS X. Of course unless you are trying to get access to special AGL features like TrueType-&gt;GL font display tools.

I've noticed that the Windows GLUT and OpenGL let me get away with some sloppy practices at times when I get in a code-and-fix mode, when I move to OS X I have to go back and fix those. This may be what you are experiencing. There may not be a problem at all with the OS X OpenGL, but rather a problem with the original Windows code that just doesn't appear on Windows. If you get a chance you may want to try compiling it on a Linux machine with MESA to see if it breaks.

If you want to get down and dirty I recommend really stepping through the code on the Mac and mapping out everything that ought to happen based on what you find. Make the fixes so that the Mac version works and then go back and add the fixes to the Windows version and see if that works.

-Nathan
     
Dedicated MacNNer
Join Date: Apr 2001
Location: Bethesda, MD
Status: Offline
Reply With Quote
Jan 24, 2002, 09:01 AM
 
When you print out your matrices, do they look ok? Or are they getting munged?

I had this weird problem on a PowerMac with a GeForce 3 that didn't show up on my TiBook, Linux box (with a Quadro) or an SGI Onyx 2. Sometimes my surface mesh would be squished. Flat as a pancake. Unless I loaded other geometry first. As it turns out, I was making calls to glMaterial inside a glBegin/glEnd grouping. None of the other machines seemed to care, but the PowerMac didn't like it.

I'm guessing it's just one of those things where certain behaviors are non quite legal, or whose outcome is ill-defined. So some GL implementations are OK with it, and some not.

dave
     
Fresh-Faced Recruit
Join Date: Jan 2002
Location: chicago
Status: Offline
Reply With Quote
Jan 24, 2002, 12:06 PM
 
update and thanks

So we compiled everything on a linux machine with MESA libraries, and everything worked. Then we compiled with GL libraries, and everything worked. So we know that we're not going completely crazy. We looked back a the macosx version, and decided to print out the 4x4 matrix like dave suggested. And in fact something bad is happening.
The entire last row of the matrix is Zeroing out. It was extremely late last night so today we are going to figure what exactly is causing the problem. We will look into the glMaterial as Dave suggested first, and hope that is it.

nathan- We're using AGL mostly because we don't know any better. Naturally we would prefer CGL, but finding CGL examples that don't run fullscreen are hard to come by. The Project is a 3d authoring environment for creating VR worlds. We want to only render into the canvas placed in a specific place in the window, so that the rest of the window can be used for DnD elements and script. Due to this we found that AGLSetDrawable seemed pretty useful, with no counterpart in the CGL camp.
Since the JNI wrapper is in c++ trying to use cocoa would have been difficult. But there is talk here of changing it to c. Any suggestions or examples of how to use CGL are greatly appreciated, or even documentation would be great.

thanks for the help everyone,
Shawn
     
Fresh-Faced Recruit
Join Date: Jan 2002
Location: chicago
Status: Offline
Reply With Quote
Jan 25, 2002, 01:02 PM
 
Problem resolved!

We found a problem with the JNI calls. Since everything except rendering is handled with java, the java object sends it's transformation changes to the renderer for update. Originally we were sending 16 doubles for the new matrix. Apparently the doubles we were sending from java were not the same values that JNI received. We're not really sure how or why that is happening. When changed all the values to floats, which created a similar effect. Resulting in changing the function entirely so that we send a jobject from java and then parse out the matrix in JNI. That method seems to work.

glad that's over.
Shawn

[ 01-25-2002: Message edited by: Shawn Lawson ]
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:46 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2