Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class GLRenderer implements GLEventListener
- {
- public void init(GLAutoDrawable drawable)
- {
- GL gl = drawable.getGL();
- gl.glClearColor(0f,0f,1f,1f);
- }
- public void display(GLAutoDrawable drawable)
- {
- GL gl = drawable.getGL();
- gl.glClear(GL.GL_COLOR_BUFFER_BIT);
- gl.glColor3f(1f, 0f, 0f);
- gl.glRectf(-25f,25f,25f,-25f);
- gl.glFlush();
- }
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
- {
- GL gl = drawable.getGL();
- float aspectRatio;
- if(height == 0)
- height = 1;
- gl.glViewport(0,0,width,height);
- gl.glMatrixMode(GL.GL_PROJECTION);
- gl.glLoadIdentity();
- aspectRatio=(float) width/ (float) height;
- if(width<height)
- gl.glOrtho(-100,100,-100/aspectRatio,100/aspectRatio,1,-1);
- else
- gl.glOrtho(-100*aspectRatio,100*aspectRatio,-100,100,1,-1);
- gl.glMatrixMode(GL.GL_MODELVIEW);
- gl.glLoadIdentity();
- }
- public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
- {
- }
- }
Add Comment
Please, Sign In to add comment