| Paste number 66376: | Java OGL code, not rendering properly |
| Pasted by: | blbrown |
| When: | 9 months, 3 weeks ago |
| Share: | Tweet this! | http://paste.lisp.org/+1F7S |
| Channel: | None |
| Paste contents: |
http://img182.imageshack.us/img182/7919/screenshotgameoflifewitvu3.png
Runtime issue, the color should be blue, but it comes up
kind of purple with this jogl code.
I just got the jogl.jar and i586.so files.
/**
* JGameLife.java
*/
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
public class JGameGLLife implements GLEventListener, KeyListener {
private JRenderCanvas render;
public JGameGLLife(final JRenderCanvas rcanvas) {
render = rcanvas;
}
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
render.setQuit(true);
System.exit(0);
}
}
public void init(GLAutoDrawable glDrawable) {
final GL gl = glDrawable.getGL();
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.glLoadIdentity();
glDrawable.addKeyListener(this);
}
public void keyReleased(KeyEvent e) {
}
public void keyTyped(KeyEvent e) {
}
public void displayChanged(GLAutoDrawable arg0, boolean arg1, boolean arg2) {
}
public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3,
int arg4) {
}
private void renderVertLine(final GL gl, final Double x) {
gl.glColor3f(0.0f, 0.0f, 1.0f);
gl.glRectd(x, (-0.8), (x+0.004), 0.8);
}
/**
* Core display method.
*/
public void display(GLAutoDrawable glDrawable) {
final GL gl = glDrawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glColor3f(0.0f, 1.0f, 1.0f);
for (int i = 0; i < 32; i++) {
double pos = (i * 0.05) - 0.8;
renderVertLine (gl, pos);
}
}
} // End of Class
This paste has no annotations.