Couple of questions...

Good day,

I have a couple of JOGL/OpenGL related questions.

Here is a screenshot of what I have so far.

http://www.radford.edu/~cbratton/test.PNG

It is basically a real time strategy interface. I have setup a 64x64 grid of tiles randomly colored and a third person camera hovering above the surface. Moving the mouse to the edges of the screen will pan the view appropriately. Then I have an overlay at the bottom as the user interface.

My questions are:

  1. How do I not render something that is not currently visible? I know that with the Graphics class you could set a clip and even if you draw outside of that region the operation would not be performed. After making a 256x256 grid of tiles I could tell by the loss of FPS that I was rendering GL_QUADS offscreen.

  2. How do I translate coordinates from my screen into points of intersection in the GLCanvas? In other words, in the attached file my mouse is at the point 847.0, 186.0. I want to know the coordinates of that quad.

I appreciate your time reading this. I have read many of the tutorials and comments on this site. My apologies if I skipped a lesson or if a solution/example has already been posted.

Thank you!

Answered question #1 myself… I found out that what I was trying to accomplish is called “picking.” It didn’t help that I couldn’t find a single current API example out there, but reading javadocs isn’t that bad. :slight_smile:

I still have yet to find and answer about viewport culling… :slight_smile:

Just google viewport culling, the first few results worked for me when I needed help with it.

Couldn’t find anything about it in relation to JOGL. Found a bunch of C examples, but I’m not too sure how I would port those over. I even downloaded Jake2 and read through the source to see if I could find anything.

I don’t want to do a scissor test, do I? I think it would be the inverse of what I need.

http://www.lighthouse3d.com/opengl/viewfrustum/
I found this incredibly useful to use and to understand. It does use c/c++ for any openGL related things but to port between c gl and jogl is incredibly easy. All of those gl calls can be found in the GL interface and they behave identically to the c versions.