Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (576)
games submitted by our members
Games in WIP (497)
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]
1  Java Game APIs & Engines / JOGL Development / Re: Color Rendering Probem on: 2012-04-23 21:25:25
I have added JOGL-2.0b633 and GLUEGEN-2.0b480 to my project. After all there cannot be a major problem with my system: both LWJGL and another tutorial on JOGL2.0 work absolutely fine.

I have discovered just one real difference in the code working properly and the code posted above:
1  
GLProfile glp = GLProfile.getDefault();

instead of
1  
GLProfile profile = GLProfile.get(GLProfile.GL2);


Well, my assignment is to wirte a method receiving a drawable and pushing some GL2-commands to it. As this works now, I am fine.

Thanks for your offered help, guys!  Grin
2  Java Game APIs & Engines / JOGL Development / Re: Color Rendering Probem on: 2012-04-22 09:52:50
I have installed JOGL 2 and imported
1  
import javax.media.opengl.GL2;

Thought that would be enough to make sure it's JOGL 2.
3  Java Game APIs & Engines / JOGL Development / Color Rendering Probem on: 2012-04-21 22:22:49
Hi, I am trying the NeHe lessons and get to No 5. But here an error occurs: The triangle is shown in blue (last color set), the quad is shown correctly:

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  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
package testJOGL; 

import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;
 
class Renderer implements GLEventListener
{
    private GLU glu = new GLU();
 
    public void display(GLAutoDrawable gLDrawable)
    {
        final GL2 gl = gLDrawable.getGL().getGL2();
        gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
        gl.glLoadIdentity();
        gl.glTranslatef(-1.5f, 0.0f, -6.0f);
        gl.glBegin(GL2.GL_TRIANGLES);          // Drawing Using Triangles        
         gl.glColor3f(1.0f, 0.0f, 0.0f);   // Set the current drawing color to red
         gl.glVertex3f( 0.0f, 1.0f, 0.0f);   // Top          
         gl.glColor3f(0.0f, 1.0f, 0.0f);   // Set the current drawing color to green
         gl.glVertex3f(-1.0f,-1.0f, 0.0f);   // Bottom Left          
         gl.glColor3f(0.0f, 0.0f, 1.0f);   // Set the current drawing color to blue
         gl.glVertex3f( 1.0f,-1.0f, 0.0f);   // Bottom Right          
       gl.glEnd();            // Finished Drawing The Triangle
       gl.glTranslatef(3.0f, 0.0f, 0.0f);
        gl.glBegin(GL2.GL_QUADS);              // Draw A Quad
         gl.glColor3f(0.5f, 0.5f, 1.0f);   // Set the current drawing color to light blue
         gl.glVertex3f(-1.0f, 1.0f, 0.0f);   // Top Left
         gl.glVertex3f( 1.0f, 1.0f, 0.0f);   // Top Right
         gl.glVertex3f( 1.0f,-1.0f, 0.0f);   // Bottom Right
         gl.glVertex3f(-1.0f,-1.0f, 0.0f);   // Bottom Left
       gl.glEnd();            // Done Drawing The Quad
       gl.glFlush();
    }
 
 
    public void displayChanged(GLAutoDrawable gLDrawable, boolean modeChanged, boolean deviceChanged)
    {
       System.out.println("displayChanged called");
    }
 
    public void init(GLAutoDrawable gLDrawable)
    {
       System.out.println("init() called");
        GL2 gl = gLDrawable.getGL().getGL2();
        gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        gl.glShadeModel(GL2.GL_FLAT);
        gl.glClearDepth(1.0f);
        gl.glEnable(GL2.GL_DEPTH_TEST);
        gl.glDepthFunc(GL2.GL_LEQUAL);
        gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST);  
    }
 
    public void reshape(GLAutoDrawable gLDrawable, int x, int y, int width, int height)
    {
       System.out.println("reshape() called: x = "+x+", y = "+y+", width = "+width+", height = "+height);
        final GL2 gl = gLDrawable.getGL().getGL2();
 
        if (height <= 0) // avoid a divide by zero error!
       {
            height = 1;
        }
 
        final float h = (float) width / (float) height;
 
        gl.glViewport(0, 0, width, height);
        gl.glMatrixMode(GL2.GL_PROJECTION);
        gl.glLoadIdentity();
        glu.gluPerspective(45.0f, h, 1.0, 20.0);
        gl.glMatrixMode(GL2.GL_MODELVIEW);
        gl.glLoadIdentity();
    }
 
 
   public void dispose(GLAutoDrawable arg0)
   {
      System.out.println("dispose() called");
   }
}
package testJOGL;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
 
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
import javax.swing.JFrame;
 
public class JOGL_Test1
{
    public static void main(String[] args)
    {
       // setup OpenGL Version 2
      GLProfile profile = GLProfile.get(GLProfile.GL2);
       GLCapabilities capabilities = new GLCapabilities(profile);
 
       // The canvas is the widget that's drawn in the JFrame
      GLCanvas glcanvas = new GLCanvas(capabilities);
       glcanvas.addGLEventListener(new Renderer());
       glcanvas.setSize( 640, 480 );
 
        JFrame frame = new JFrame( "Hello World" );
        frame.getContentPane().add( glcanvas);
 
        // shutdown the program on windows close event
       frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent ev) {
                System.exit(0);
            }
        });
 
        frame.setSize( frame.getContentPane().getPreferredSize() );
        frame.setVisible( true );
    }
}


The code is taken from a tutorial from http://schabby.de and other sources as I've tried to fix the problem myself.

Maybe someone could help me? Thx!
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (11 views)
2014-04-15 18:08:23

BurntPizza (10 views)
2014-04-15 03:46:01

UprightPath (23 views)
2014-04-14 17:39:50

UprightPath (10 views)
2014-04-14 17:35:47

Porlus (27 views)
2014-04-14 15:48:38

tom_mai78101 (49 views)
2014-04-10 04:04:31

BurntPizza (107 views)
2014-04-08 23:06:04

tom_mai78101 (207 views)
2014-04-05 13:34:39

trollwarrior1 (176 views)
2014-04-04 12:06:45

CJLetsGame (182 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
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!