From: Jan F. <jan...@st...> - 2001-04-04 14:59:13
|
Hi! Why is my reshape method never called for this GLJPanel, even if the window is resized? I'm using GL4Java 2.5.0. --------------------------------------------------- class GLScreen extends GLJPanel { public void init() { gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.glDisableClientState(GL_CULL_FACE); gl.glDisable(GL_DEPTH_TEST); } public void display() { gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); gl.glMatrixMode(GL_MODELVIEW); gl.glLoadIdentity(); gl.glBegin(GL_POLYGON); gl.glColor3d(1.0, 1.0, 1.0); gl.glVertex3d(-0.5, -0.5, 0.0); gl.glColor3d(0.0, 1.0, 1.0); gl.glVertex3d( 0.5, -0.5, 0.0); gl.glColor3d(1.0, 0.0, 0.0); gl.glVertex3d(0.0, 0.5, 0.0); gl.glEnd(); } public void reshape(int width, int height) { gl.glViewport(0, 0, width - 1, height - 1); gl.glMatrixMode(GL_PROJECTION); gl.glLoadIdentity(); if(width > height) { glu.gluOrtho2D(-(double)width/height, (double)width/height, -1.0, 1.0); } else { glu.gluOrtho2D(-1.0, 1.0, -(double)height/width, (double)height/width); } } public GLScreen() { super(); } } public class MainWindow extends JFrame implements ActionListener { public MainWindow() { Container content = getContentPane(); GLScreen myGLScreen = new GLScreen(); content.add("Center", myGLScreen); setSize(600, 500); setTitle("Simple Java OpenGL Application"); setVisible(true); } public void actionPerformed(ActionEvent event) { } protected void processWindowEvent(WindowEvent event) { super.processWindowEvent(event); if (event.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } public static void main(String[] args) { MainWindow theWindow = new MainWindow(); } } --------------------------------------------------- Jan |