Hello again!
How is it possible to draw a simple line using the AWTGLRenderer and its buffer capabilities?
A feasible approach is to draw the line using the canvas' graphics, after signaled to lwjgl that the framebuffer content can be displayed. This approach flickers since the line is not drawn before displayed, so how can I use simple gl draw operations with buffered AWTGLRenderer?
Try to put your gl related code into finishedPainting()-method of an IPaintListener. This thread is related to line drawing in GL btw: http://www.jpct.net/forum2/index.php/topic,1336.0.html (http://www.jpct.net/forum2/index.php/topic,1336.0.html)
Thank you for ur fast reply - much appreciated!
I know nothing about OpenGL, however the code refered to (below) causes vm to crash. Any G11 method (GL11.glMatrixMode+GL11.glColor3f+) makes it crash. What do I leave out?
while (loop) {
// do jPCT things
world.renderScene(buffer);
world.draw(buffer);
buffer.update();
// do lwjgl things
GL11.glBegin(GL11.GL_LINES);
GL11.glVertex2f(10, 10);
GL11.glVertex2f(50, 50);
GL11.glEnd();
buffer.displayGLOnly();
Thread.sleep(10);
}
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glPushMatrix();
GL11.glLoadIdentity();
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glPushMatrix();
GL11.glLoadIdentity();
GL11.glOrtho(0, 1, 1, 0, 0.1, 100);
GL11.glColor3f(255, 255, 255);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glBegin(GL11.GL_LINES);
GL11.glVertex3f(0.0f, 0.0f, -1f);
GL11.glVertex3f(1.0f, 1.0f, -1f);
GL11.glEnd();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glPopMatrix();
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00af098d, pid=2176, tid=2460
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_04-b05 mixed mode)
# Problematic frame:
# j org.lwjgl.opengl.GL11.glMatrixMode(I)V+0
When using the AWTGLRenderer, you can't execute GL related code in the render loop. You have to do it in the IPaintListener's methods or otherwise, you have no valid GL context.