Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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  
  problem with jogl  (Read 811 times)
0 Members and 1 Guest are viewing this topic.
Offline grego5

Junior Newbie




Java games rock!


« Posted 2004-07-13 21:38:50 »

I just started playing around with jogl.  And I wrote this example code which ran on my brothers computer, but when I put it on mine, it was giving me this swap buffer error.  How do I fix that?  Now, it runs but doesn't rotate, and then when I try to run it a second time the display is empty.  Also, I inputed this example I got from my professor last semester and his code runs but it is flickering, what causes the flickering?  Here is the code that I wrote if anybody has any suggestions.
****************************************


import javax.swing.*;
import net.java.games.jogl.*;

import java.awt.*;   //contains graphicsdevice info

public class Example1 extends JFrame implements GLEventListener
{
     GLCanvas canvas=null;
     private float m_angle=(float)0.0;
     int width=500;
     int height=500;
     GraphicsEnvironment ge=null;
     GraphicsDevice gd=null;
     GraphicsConfiguration gc=null;
     
     public Example1()  
     {

           
           ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            gd = ge.getDefaultScreenDevice();
             gc = gd.getDefaultConfiguration();

            setTitle("Simple Object");
           setSize(width,height);

           GLCapabilities capabilities = new GLCapabilities();
           canvas=GLDrawableFactory.getFactory().createGLCanvas(capabilities);
           canvas.addGLEventListener(this);

           this.getContentPane().add(canvas);
 
           if( gd.isFullScreenSupported() )
           {  
              gd.setFullScreenWindow(this);
           }

           this.setVisible(true);
     
           setDefaultCloseOperation(EXIT_ON_CLOSE);

           Animator animator=new Animator(canvas);
           animator.start();

     }


     public void init (GLDrawable drawable)
     {

           GL gl = drawable.getGL();
           GLU glu=drawable.getGLU();

            gl.glClearColor((float)0.0,(float)0.0,(float)0.0,(float)0.0);

           
           gl.glViewport(0,0,width,height);
           gl.glMatrixMode(GL.GL_PROJECTION);
           gl.glLoadIdentity();
           glu.gluPerspective((float)52.0,(float)width/(float)height,(float)1.0,(float)1000.0);
           gl.glMatrixMode(GL.GL_MODELVIEW);
           gl.glLoadIdentity();


     }
     public void display (GLDrawable drawable)
      {
 
           GL gl=drawable.getGL();
           
           gl.glClear(GL.GL_COLOR_BUFFER_BIT|GL.GL_DEPTH_BUFFER_BIT);

           
           gl.glLoadIdentity();
           
             
           gl.glTranslatef((float)0.0,(float)0.0,(float)-5.0);
           gl.glRotatef(m_angle,(float)1.0,(float)0.0,(float)0.0);
           gl.glRotatef(m_angle,(float)0.0,(float)1.0,(float)0.0);
           gl.glRotatef(m_angle,(float)0.0,(float)0.0,(float)1.0);

           gl.glColor3f((float)0.7,(float)1.0,(float)0.3);

           gl.glBegin(GL.GL_TRIANGLES);
                 gl.glVertex3f((float)1.0,(float)-1.0,(float)0.0);
                 gl.glVertex3f((float)-1.0,(float)-1.0,(float)0.0);
                 gl.glVertex3f((float)0.0,(float)1.0,(float)0.0);
           gl.glEnd();

           
           gl.glColor3f((float)1.0,(float).7,(float).7);

           gl.glPointSize((float)15.0);

           gl.glBegin(GL.GL_POINTS);
                 gl.glVertex3f((float)0.0,(float)0.0,(float)0.0);
                 gl.glVertex3f((float)0.0,(float)1.0,(float)0.0);
           gl.glEnd();

           

           gl.glEnable(GL.GL_LINE_STIPPLE);
           gl.glLineStipple(2,(short)15);
           gl.glLineWidth(2);
     
           gl.glBegin(GL.GL_LINES);
                 gl.glVertex3f((float)1.0,(float)0.0,(float)3.0);
                 gl.glVertex3f((float)-5.0,(float)1.0,(float)3.0);
           gl.glEnd();
           
            m_angle+=(float).1;

     

     }
     

}


Offline shawnkendall

Senior Member





« Reply #1 - Posted 2004-07-13 23:06:49 »

Please move this to the JOGL forums.
Thanks!

Shawn Kendall
Cosmic Interactive, LLC
http://www.facebook.com/BermudaDash
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

ctomni231 (33 views)
2014-07-18 06:55:21

Zero Volt (29 views)
2014-07-17 23:47:54

danieldean (24 views)
2014-07-17 23:41:23

MustardPeter (26 views)
2014-07-16 23:30:00

Cero (41 views)
2014-07-16 00:42:17

Riven (43 views)
2014-07-14 18:02:53

OpenGLShaders (31 views)
2014-07-14 16:23:47

Riven (30 views)
2014-07-14 11:51:35

quew8 (29 views)
2014-07-13 13:57:52

SHC (65 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!