Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
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  
  jogl 2d newbie  (Read 3316 times)
0 Members and 1 Guest are viewing this topic.
Offline tortoise

Junior Devvie




<3 Shmups


« Posted 2003-07-10 11:47:42 »

Hi, I'm very new to gl and jogl (and debated posting this here or newless cluebies). I want to use jogl for my 2D game so it will run well on more than just Windows. But in my research I've come up with some questions...

I'm a little stumped as to where the GL class resides? I have downloaded the jogl source out of cvs. There's no GL.java in jogl, and searching for things like "class GL" or "interface GL" turns up nothing. I assume all gl* functions from the standard C implementation of openGL would be found in the GL class? Searching for things like glBegin show a lot of other classes using the method, but not where it's originating from.

What about glDrawPixels, glBitmap, etc? I also was unable to find those as well. I am curious how much of the 2D side of openGl is implemented, or if I'm even on the right track at all.

In doing some small toy programs with jogl, I can't get the color to change no matter what I do. For example I stripped the Gears demo down and replaced drawing the gears with just drawing a few polys, I have something like:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
public void display(GLDrawable drawable)
{
       // glClearColor set to black
      gl.glclear( GL.GL_COLOR_BUFFER_BIT );
     
      gl.glColor3f( 0.0f, 1.0f, 0.0f );
      gl.glBegin( GL.GL_POLYGON );
          gl.glVertex2f( 0.0f, 0.0f );
          gl.glVertex2f( 1.0f, 0.0f );
          gl.glVertex2f( 0.0f, 1.0f );
      gl.glEnd();
      gl.glFlush();
}


but no matter what the triangle is always a dark red. Weird that's dark red, I'd think if anything it'd be (1.0, 0.0, 0.0) red, I've experimented with specifying the color at other times and such with no luck.

My game currently has a render class that all sprites register themselves with. When it comes time to draw the frame the renderer's Graphic object is passed around to everyone and they all do their thing. Is this a feasable approach with jogl? Obviously not a Graphics object, but perhaps a small inner class of my renderer that accepts an image and coordinates and draws it to the GLCanvas with I assume glDrawPixels or something like it?

I'm also curious on the whole pasting sprites onto polygons as textures vs just blitting the sprites as is. In searching (not just these forums but the internet for openGL stuff in general) I've found it split about 50/50. It seems that generally the more game oriented people seem to prefer the polygon/texture route. Should that be the way I head? I have a feeling that'd drastically change my game's structure.
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #1 - Posted 2003-07-10 16:13:10 »

I think the source to that class is generated by the build process from the openGL C header files.  That's what all the fuss is about with respect to GlueGen and antlr

Offline gregorypierce

Senior Devvie




I come upon thee like the blue screen of death....


« Reply #2 - Posted 2003-07-10 17:04:08 »

Yep.. it is automagically created by GLEmitter.java.

http://www.gregorypierce.com

She builds, she builds oh man
When she links, she links I go crazy
Cause she looks like good code but she's really a hack
I think I'll run upstairs and grab a snack!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
8: Undefined index: online
File: /home/jgo/public_html/Themes/default/Display.template.php (main sub template - eval?)
Line: 161