Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (527)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (594)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2
1  Java Game APIs & Engines / JOGL Development / Re: How add a mouse listener on OpenGL primitives? on: 2009-09-20 14:02:56
Yes, I know I can add a listener to the canvas, but is it possible to add a listener on a primitive? Or do I have to get the position of each primitive and match them against the mouse pointer´s X and Y values?
2  Java Game APIs & Engines / JOGL Development / How add a mouse listener on OpenGL primitives? on: 2009-09-20 11:41:11
I would like to add a mouse listener on my OpenGL graphical objects. What is the best way to do this?
3  Java Game APIs & Engines / JOGL Development / Re: How to shade the background? on: 2009-08-23 18:52:06
Just put a textured quad in the background that's big enough to cover it.
Good idea, thanks! Thought there was any built in method for this, but the quad works perfect.

Be sure to make it immune to camera changes.
That was easy made by putting the quad before initiating the camera, then it becomes immune to camera changes. Smiley
4  Java Game APIs & Engines / JOGL Development / How to shade the background? on: 2009-08-23 00:22:17
How do I get the background like this: http://weblogs.java.net/blog/campbell/archive/images/photocube.large.png

Is it some kind of overlay (or "underlay")?
5  Java Game APIs & Engines / JOGL Development / Re: "No OpenGL context current on this thread" - why? on: 2009-08-20 13:33:11
Thanks! I understand the pattern and everything and I have got it working too but I get two uncheckd warnings (compiled with Xlint:unchecked) in the GLQueue class posted in this post http://www.java-gaming.org/topics/loading-shaders-possible-outside-of-gleventlistener-s-init-reshape-display/12475/msg/99927/view.html#msg99927:
1  
2  
3  
4  
5  
6  
7  
8  
9  
GLQueue.java:30: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList



The warning refers to:

public void add(GLAction action) {
        synchronized (queue)  { queue.add(action);  }
}


And the line:
1  
2  
3  
4  
5  
6  
7  
GLQueue.java:43: warning: [unchecked] unchecked call to ArrayList(java.util.Collection<? extends E>) as a member of the raw type java.util.ArrayList



The warning refers to:

temp = new ArrayList(queue);


Why do I get these warning?

Is it possible to correct them?


6  Java Game APIs & Engines / JOGL Development / Re: Make a reflection of a texture on: 2009-08-19 21:20:03
Thanks, that made them upside-down, but I would also like to reverse the images. How is that possible?
7  Java Game APIs & Engines / JOGL Development / Re: Make a reflection of a texture on: 2009-08-19 19:50:57
I have now succeeded in creating a quad below the main quad:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
gl.glBegin(gl.GL_QUADS);
          gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(topLeft, 1.0f, 0.0f);          
          gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(topRight, 1.0f, 0);        
          gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(bottomRight, -1.0f, 0);    
          gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(bottomLeft, -1.0f, 0.0f);    
gl.glEnd();

// Second quad - "the reflection quad"
gl.glBegin(gl.GL_QUADS);
          gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(topLeft, -1.0f, 0.0f);      
          gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(topRight, -1.0f, 0);        
          gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(bottomRight, -3.0f, 0);    
          gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(bottomLeft, -3.0f, 0.0f);    
gl.glEnd();


The problem is that the image on the reflection quads is not upside-down as I want it to be.
If I add
1  
gl.glRotated(180,0,0,0);
everything is messed up since I am creating a lot of quads with binded textures in a loop.

How to I rotate every "reflection quad" 180 degrees without messing up the first quads?
8  Java Game APIs & Engines / JOGL Development / Re: Make a reflection of a texture on: 2009-08-19 19:17:40
Thanks again. I will make a try and return here if I don´t succeed.
9  Java Game APIs & Engines / JOGL Development / Re: Make a reflection of a texture on: 2009-08-19 18:56:36
Thanks,
so in this image: http://weblogs.java.net/blog/campbell/archive/images/ba3d.png, it´s actually using two quads, one for the actuall picture and one for the reflecting picture?
10  Java Game APIs & Engines / JOGL Development / Re: Make a reflection of a texture on: 2009-08-19 18:17:36
I am new to shaders, is there any tutorial that exemplifies a simple reflection from a quad or something?
11  Java Game APIs & Engines / JOGL Development / Make a reflection of a texture on: 2009-08-19 17:38:59
How can I achieve a reflection of a texture like on this image: http://weblogs.java.net/blog/campbell/archive/images/ba3d.png ?
12  Java Game APIs & Engines / JOGL Development / Re: "No OpenGL context current on this thread" - why? on: 2009-08-10 11:01:36
I am making an application that lets the user import new images (that is creating new textures) during runtime so I do have to use some kind of event handler and create new textures in it.

Are there any good practices of how to code when letting a user import new images as textures during runtime?
13  Java Game APIs & Engines / JOGL Development / Overlay object does not work properly on: 2009-08-09 18:11:49
I am trying to put an Overlay over the openGL panel.

I have this in the init() method:
1  
2  
overlay = new Overlay(drawable);
graphics2d = overlay.createGraphics();


And I have this in the display() method:
1  
2  
3  
overlay.drawAll();
graphics2d.setBackground(Color.yellow);
graphics2d.drawString("HELLO WORLD!", 10, 10);


Nothing but all the OpenGL stuff appears on the screen. "Hello world" is not beeing printed.

What am I doing wrong?
14  Java Game APIs & Engines / JOGL Development / Re: Get the left-most quad appear to the right when dissappearing to the left on: 2009-08-09 17:38:28
My goal is to make the space between the quads constant. The only place where it is not constant is between the left-most and the right-most quads. And that is what I am wondering of how to do. I cannot see how I can solve it with only one glTransate (well, I still don´t see how I can solve it with multiple glTranslates either)?
15  Java Game APIs & Engines / JOGL Development / Re: How do I run my opengl application? on: 2009-08-09 17:27:49
Hmm, it works if I start the application using the command line, but not if I doubble click on the jar file.

How come?

Sometimes the problem is because of a failed attempt to "install" jogl manually by copying the jars/dlls to some system or jre folder. If you did so, remove any occurance of jogl/gluegen jars and dlls outside of your project folder and the netbeans profile directory from your system and try again.
I will try that. Thanks!
16  Java Game APIs & Engines / JOGL Development / Re: "No OpenGL context current on this thread" - why? on: 2009-08-09 15:48:18
Thanks for answering!

I found  a way to get around the problem. In the listener I put this line of code:
1  
glContext.makeCurrent();
and then it worked.

Is that an ugly solution or is it OK to do in that way?
17  Java Game APIs & Engines / JOGL Development / How do I run my opengl application? on: 2009-08-09 14:50:31
I´m using NetBeans opengl pack.

I made a simple opengl application that I would like to run without using NetBeans.

In the folder C:\...\NetBeansProjects\myApp\dist-windows-amd64 there is a jar file and some dll files. myApp.jar is not possible to start, no jar file starts in the whole myApp folder. What am I doing wrong?
18  Java Game APIs & Engines / JOGL Development / "No OpenGL context current on this thread" - why? on: 2009-08-09 13:56:10
I have a method that loads a texture called loadTexture().
The method just does this:
1  
 textures = TextureIO.newTexture(new java.io.File("image.jpg"), false);


If I call that method from an actionListener (actionPerformed method) I get this error:
1  
javax.media.opengl.GLException: No OpenGL context current on this thread


If I call loadTexture() from the init() methot, I don´t get the exception.

I want to load the texture by pressing a button, so why do I get that exception when trying to call the method from the action listener?
19  Java Game APIs & Engines / JOGL Development / Re: Get the left-most quad appear to the right when dissappearing to the left on: 2009-08-09 13:04:30
Ok, now I am moving all the quads with glTranslatef(), that means every quad is moving. Do I have to use one glTranslatef() for each quad?
20  Java Game APIs & Engines / JOGL Development / Get the left-most quad appear to the right when dissappearing to the left on: 2009-08-09 11:33:41
Hello!

The method called from the display list draws some quads in a horizontal line. You can make the quads going left or right by pressing the arrow keys, then the X_POS variable is changing. When you press left or right many times, the quads will finally disappear from the view.
1  
2  
gl.glTranslatef(X_POS, 0.0f, -6.0f);
gl.glCallList(quad);        


I would like to make the left-most quad appear on the right side when it dissappears to the left, and the right-most quad appear to the left when it dissappears to the right, so that the quads never disappear from the view even if I press the left left key for a month.  Smiley

How can I achieve this?


21  Java Game APIs & Engines / JOGL Development / Re: How to achieve an animation of a 3D model? on: 2009-07-20 23:25:29
Thanks!

What kind of 3D models are easiest to work with? Are OBJ models easiest?

Is there any tutorial of how to load an OBJ model onto the OpenGL screen?
22  Java Game APIs & Engines / JOGL Development / Re: How to achieve an animation of a 3D model? on: 2009-07-18 16:12:56
Thanks for answering and the example! I will study it when I start learning about shaders (now I am just looking at the subject).

Ah, I see, so the compilation of the OGSL code is done during runtime of the JOGL application by that OpenGL command, glCompileShader. What about compilation errors? How are they presented?

Is it possible to achieve everything about shading just by using OpenGL than using a shader language?

In your file simple.vert linked in your example code, what would be the OpenGL way to do that your vertex shader does:
1  
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex * vec4 (0.7, 0.5, 0.5, 1.0);
?
23  Java Game APIs & Engines / JOGL Development / Re: How to achieve an animation of a 3D model? on: 2009-07-18 11:29:40
Is the "current rendering program" the one providing by OpenGL itself? Which OpenGL commands are used to bind a shader program?
I have found a lot of tutorials of how to write code, but no one showing how to include / bind it in the JOGL code. Any good tutorial on that?
24  Java Game APIs & Engines / JOGL Development / Re: How to achieve an animation of a 3D model? on: 2009-07-17 22:41:20
The .cg files are shader programs used to replace parts of the rendering with a custom written program.  He's probably updating variables in that program so that it dynamically moves the vertices on a grid to appear as waves.

That being said, OpenGL comes with no support for animations.  It is the programmer's responsibility to write code that can read the mesh and animation files created in Blender, etc. and use them.  For animating, this might involve repeatedly computing new vertex positions on the CPU each frame, or you can write custom shaders to move that calculation onto the GPU.

Are those shader programs run by the JOGL application? If they are updating variables, how does the logic look like? It cannot update variables in the running Java application (right?), so it has to update variables and write them to some kind of file that is later read by the Java application. Is that the way of how it works?

Which language is the best one to start with between "OpenGL Shading Language" and "C for Graphics"? Are the .cg files written in "C for Graphics"?
25  Java Game APIs & Engines / JOGL Development / How to achieve an animation of a 3D model? on: 2009-07-17 20:42:11
Have a look at the Ocean Water Demo by Florian Zitzelsberger "ZMaster" here on NeHe: http://nehe.gamedev.net/data/contests/contest.asp?contest=08

Direct link to download: http://nehe.gamedev.net/counter.asp?file=data/contests/2004_creative/demo/florian_zitzelsberger.zip


Look at the water, how do I achieve it moving like that? Is the water hard coded, because I cannot see any models in the ZIP file? In the Shaders folder, there are two files named "Water_vp.cg" and "Water_fp.cg". What kind of files are these?

When someone makes a model in a 3D program, like Blender, SoftImage, 3D Studio Max etc and makes the model animating, is it possible to use that animation of the model in an OpenGL application where the animation is NOT set by OpenGL but by the third part 3D developing software?


26  Java Game APIs & Engines / JOGL Development / Why does my lightning only works when pos. var. declared in display() method? on: 2009-07-17 10:12:35
I have a frustrating problem. I want to light up the sphere, like when the sun lights up the moon.


It works with this code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
public void display(GLAutoDrawable drawable) {
     gl.glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
     gl.glShadeModel (GL.GL_SMOOTH);

     float light_position[] = { -5.0f, 7.0f, sunrise, 0.0f };  // Works if this line is inside the display() method
 
     gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, FloatBuffer.wrap(light0_ambient));
     gl.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, FloatBuffer.wrap(mat_specular));
     gl.glMaterialfv(GL.GL_FRONT, GL.GL_SHININESS, FloatBuffer.wrap(mat_shininess));
     gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, FloatBuffer.wrap(light_position));
     ...
     sunrise += 0.02f;
     ...


If I place the line:
1  
float light_position[] = { -5.0f, 7.0f, sunrise, 0.0f }; 

outside the display() method so it becomes a class member, then the animation doesn´t work and the sun seems to be still. How come?
27  Java Game APIs & Engines / JOGL Development / Re: How to draw a 3D globe? on: 2009-07-15 21:35:05
I am using the NetBeans OpenGL Pack, in which package can I find GLUT? I have search through the API but cannot find it.

EDIT: Sorry, haha, I am totaly blind. Found it just below the GLU class.   Grin
28  Java Game APIs & Engines / JOGL Development / Re: How to draw a 3D globe? on: 2009-07-15 14:43:36
Hey,
you also can put your LINE_LOOP in a DisplaylIst,  then call it in a for next loop 360 times and rotate it around one axis, y-axis for example. Or just use the glut-method GlutWireSphere, glutSolidSphere?!?!
Why not these?
best regards,
normen


But glut-methods are not a part of JOGL?
29  Java Game APIs & Engines / JOGL Development / How to draw a 3D globe? on: 2009-07-14 16:43:10
I´m trying do draw a 3D globe, but don´t succeed.
A circle is beeing drawn, but then I would like to draw circels each with 1 grade angle increase since the last drawn circle. What do I have to modify in my code?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
    final float DEG2RAD = (float)3.14159/180;
    float grade = 0.0f;

    void drawCircle(float radius)
    {
       gl.glBegin(GL.GL_LINE_LOOP);

       for (int i=0; i < 360; i++)
       {
           for(int y=0; y<360; y++)
           {
               float degInRad = y*DEG2RAD;
               gl.glVertex2f(((float)Math.cos(degInRad)*radius)+grade, (float)Math.sin(degInRad)*radius);
               grade++;
           }
       }

       gl.glEnd();
    }
30  Java Game APIs & Engines / JOGL Development / Re: How do I draw the same polygon in two different viewports? on: 2009-07-14 16:10:47
I made a try but couldn´t get it working. Just the circles on the first viewpoint are beeing displayed, but not the one drawn after the second viewpoint has beeing specified.

First I specified the first viewpoint in the reshape() method;
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {

        this.width = width;
        this.height = height;

        gl.glViewport (0, 0,  width/2, height);
        gl.glMatrixMode (GL.GL_PROJECTION);
        gl.glLoadIdentity ();
        glu.gluPerspective(60.0f, 3.0f, 1.0f, 20.0f);
        gl.glMatrixMode (GL.GL_MODELVIEW);
        gl.glMultMatrixf(new float[]{4.1f, 4.1f, 6.1f}, 0);
        gl.glLoadIdentity();
        glu.gluLookAt(0.0f, 0.0f, 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
}

Then I specified the other viewpoint in the display() method;
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
public void display(GLAutoDrawable drawable) {
        gl = drawable.getGL();

        gl.glClear (GL.GL_COLOR_BUFFER_BIT);
        gl.glColor3f (1.0f, 1.0f, 1.0f);
        gl.glPushMatrix();
        drawCircle(2.5f);

        gl.glRotatef (year, 0.0f, 1.0f, 0.0f);
        gl.glTranslatef (2.0f, 0.0f, 0.0f);
        gl.glRotatef (day, 0.0f, 1.0f, 0.0f);
        drawCircle(1.5f);

        gl.glPopMatrix();

        // The second viewpoint
        gl.glViewport (width/2, 0, width/2, height);
        gl.glMatrixMode (GL.GL_PROJECTION);
        gl.glLoadIdentity ();
        glu.gluPerspective(60.0f, 3.0f, 1.5f, 20.0f);
        gl.glMatrixMode (GL.GL_MODELVIEW);

        // A circle in the second viewpoint
        drawCircle(2.5f);

        gl.glFlush ();
}


What have I missed?
Pages: [1] 2
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

PocketCrafter7 (14 views)
2014-11-28 16:25:35

PocketCrafter7 (10 views)
2014-11-28 16:25:09

PocketCrafter7 (11 views)
2014-11-28 16:24:29

toopeicgaming1999 (76 views)
2014-11-26 15:22:04

toopeicgaming1999 (67 views)
2014-11-26 15:20:36

toopeicgaming1999 (17 views)
2014-11-26 15:20:08

SHC (30 views)
2014-11-25 12:00:59

SHC (28 views)
2014-11-25 11:53:45

Norakomi (32 views)
2014-11-25 11:26:43

Gibbo3771 (28 views)
2014-11-24 19:59:16
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!