Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.gmail.bernabe.laurent.jogl.simple_test;
- import javax.media.opengl.GL2;
- import javax.media.opengl.GLAutoDrawable;
- import javax.media.opengl.GLEventListener;
- import javax.media.opengl.glu.GLU;
- public class MyGLEventListener implements GLEventListener {
- @Override
- public void init(GLAutoDrawable drawable) {
- // TODO Auto-generated method stub
- }
- @Override
- public void dispose(GLAutoDrawable drawable) {
- // TODO Auto-generated method stub
- }
- @Override
- public void display(GLAutoDrawable drawable) {
- GL2 gl = drawable.getGL().getGL2();
- gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
- gl.glLoadIdentity();
- glu.gluLookAt(0f, 0f, 5f,
- 0f, 0f, 0f,
- 0f, 1f, 0f);
- gl.glColor3f(1.0f, 0f, 0f);
- gl.glBegin(GL2.GL_TRIANGLES);
- gl.glVertex2f(0f, 1f);
- gl.glVertex2f(-1f, 0f);
- gl.glVertex2f(+1f, 0f);
- gl.glEnd();
- }
- @Override
- public void reshape(GLAutoDrawable drawable, int x, int y, int width,
- int height) {
- GL2 gl = drawable.getGL().getGL2();
- gl.glViewport(x, y, width, height);
- gl.glMatrixMode(GL2.GL_PROJECTION);
- gl.glLoadIdentity();
- glu.gluPerspective(60f, (float) width / height, 0.1f, 10f);
- gl.glMatrixMode(GL2.GL_MODELVIEW);
- }
- private GLU glu = new GLU();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement