Hi,
I made this applet but it is not resizable.
if i put 100% in width and height in the HMTL tag of the applet when I resize the window frame of my browser the applet is resizing to fit space but the context of opengl does not fit the new dimensions.
and i would like for example that the spining square would be resized up on a window resized up.
thank you for your help
package org.lwjgl.test.applet;
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Canvas;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.AWTGLCanvas;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.applet.LWJGLInstaller;
public class AppletTestComplete extends Applet {
public void init() {
/* Install applet binaries */
try {
LWJGLInstaller.tempInstall();
} catch (Exception le) {
le.printStackTrace();
}
setLayout(new BorderLayout());
try {
Canvas canvas = new AppletCanvas();
canvas.setSize(getWidth(), getHeight());
add(canvas);
} catch (Exception e) {
e.printStackTrace();
}
}
/*
* @see org.lwjgl.opengl.AWTGLCanvas
*/
public class AppletCanvas extends AWTGLCanvas {
float angle = 0;
/*
* @see org.lwjgl.opengl.AWTGLCanvas#AWTGLCanvas()
*/
public AppletCanvas() throws LWJGLException {
// Launch a thread to repaint the canvas 60 fps
Thread t = new Thread() {
public void run() {
while (true) {
if (isVisible()) {
repaint();
}
Display.sync(60);
}
}
};
t.setDaemon(true);
t.start();
}
/*
* @see org.lwjgl.opengl.AWTGLCanvas#paintGL()
*/
public void paintGL() {
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
GL11.glMatrixMode(GL11.GL_PROJECTION_MATRIX);
GL11.glLoadIdentity();
GL11.glOrtho(0, 640, 0, 480, 1, -1);
GL11.glMatrixMode(GL11.GL_MODELVIEW_MATRIX);
GL11.glPushMatrix();
GL11.glTranslatef(320, 240, 0.0f);
GL11.glRotatef(angle, 0, 0, 1.0f);
GL11.glBegin(GL11.GL_QUADS);
GL11.glVertex2i(-50, -50);
GL11.glVertex2i(50, -50);
GL11.glVertex2i(50, 50);
GL11.glVertex2i(-50, 50);
GL11.glEnd();
GL11.glPopMatrix();
angle += 1;
try {
swapBuffers();
} catch (Exception e) {
}
}
}
}
[/code]
GL11.glOrtho(0, 640, 0, 480, 1, -1);
you're specifying 640x480 all the time...
elias added some resizing to our awt test recently:
http://svn.sourceforge.net/viewvc/java-game-lib/trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTGears.java?r1=2584&r2=2587