您的位置:首页 > 其它

JOGL FirstDemo

2016-07-01 17:08 288 查看
package com.xiuye.jogl;

import javax.swing.JFrame;

import com.jogamp.opengl.GL4;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.awt.GLCanvas;

public class Game extends JFrame implements GLEventListener {

/**
*
*/
private static final long serialVersionUID = 8623653810668055175L;

final private int width = 800;
final private int height = 600;

public Game(){
super("Minimal OpenGL");

GLProfile profile = GLProfile.get(GLProfile.GL4);
GLCapabilities capabilities = new GLCapabilities(profile);
GLCanvas canvas = new GLCanvas();
canvas.addGLEventListener(this);

this.setName("Minimal OpenGL");

this.getContentPane().add(canvas);

this.setSize(width,height);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
this.setResizable(false);
canvas.requestFocusInWindow();

}

public void play(){

}

@Override
public void display(GLAutoDrawable drawable) {

GL4 gl =  drawable.getGL().getGL4();
gl.glClear(GL4.GL_COLOR_BUFFER_BIT);

gl.glFlush();

}

@Override
public void dispose(GLAutoDrawable arg0) {

}

@Override
public void init(GLAutoDrawable drawable) {

GL4 gl = drawable.getGL().getGL4();
gl.glClearColor(0.392f, 0.584f, 0.929f, 1.0f);

}

@Override
public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3,
int arg4) {

}

}

package com.xiuye.jogl;

public class FirstJOGL {

public static void main(String[] args) {

Game g = new Game();
g.play();

}

}




内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: