Update of /cvsroot/jake2/jake2/src/jake2/render/opengl
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv12304/src/jake2/render/opengl
Modified Files:
Jsr231Driver.java
Log Message:
changes to handle resizable screens.
GridBagLayout is used to resize the GL canvas together with the frame
Index: Jsr231Driver.java
===================================================================
RCS file: /cvsroot/jake2/jake2/src/jake2/render/opengl/Jsr231Driver.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** Jsr231Driver.java 3 Nov 2007 13:04:23 -0000 1.25
--- Jsr231Driver.java 2 Mar 2008 14:58:22 -0000 1.26
***************
*** 137,141 ****
/*
! * fullscreen handling
*/
if (device == null) {
--- 137,141 ----
/*
! * full screen handling
*/
if (device == null) {
***************
*** 161,164 ****
--- 161,165 ----
ImageIcon icon = new ImageIcon(getClass().getResource("/icon-small.png"));
window.setIconImage(icon.getImage());
+ window.setLayout(new GridBagLayout());
Display canvas = new Display(new GLCapabilities());
***************
*** 166,170 ****
canvas.setFocusTraversalKeysEnabled(false);
! window.add(canvas);
canvas.setSize(newDim.width, newDim.height);
--- 167,176 ----
canvas.setFocusTraversalKeysEnabled(false);
! // the OpenGL canvas grows and shrinks with the window
! GridBagConstraints gbc = new GridBagConstraints();
! gbc.fill = GridBagConstraints.BOTH;
! gbc.weightx = gbc.weighty = 1;
! window.add(canvas, gbc);
!
canvas.setSize(newDim.width, newDim.height);
***************
*** 210,214 ****
//f2.setLocation(window_xpos, window_ypos);
f2.pack();
! f2.setResizable(false);
f2.setVisible(true);
}
--- 216,220 ----
//f2.setLocation(window_xpos, window_ypos);
f2.pack();
! f2.setResizable(true);
f2.setVisible(true);
}
***************
*** 228,235 ****
this.display = canvas;
- Base.setVid(newDim.width, newDim.height);
-
- // let the sound and input subsystems know about the new window
- VID.NewWindow(newDim.width, newDim.height);
setGL(display.getGL());
init(0, 0);
--- 234,237 ----
***************
*** 285,289 ****
// first buffer
beginFrame(0.0f);
! glViewport(0, 0, window.getWidth(), window.getHeight());
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
--- 287,291 ----
// first buffer
beginFrame(0.0f);
! glViewport(0, 0, display.getWidth(), display.getHeight());
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
***************
*** 291,295 ****
// second buffer
beginFrame(0.0f);
! glViewport(0, 0, window.getWidth(), window.getHeight());
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
--- 293,297 ----
// second buffer
beginFrame(0.0f);
! glViewport(0, 0, display.getWidth(), display.getHeight());
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
***************
*** 348,352 ****
return context.getGL();
}
! /** <B>Overrides:</B>
<DL><DD><CODE>paint</CODE> in class <CODE>java.awt.Component</CODE></DD></DL> */
// Overridden from Canvas to prevent the AWT's clearing of the
--- 350,373 ----
return context.getGL();
}
!
!
! /**
! * @see java.awt.Component#setBounds(int, int, int, int)
! */
! public void setBounds(int x, int y, int width, int height) {
! final int mask = ~0x03;
! if ((width & 0x03) != 0) {
! width &= mask;
! width += 4;
! }
!
! // System.out.println("display bounds: " + x + ", " + y + ", " + width + ", " + height);
! super.setBounds(x, y, width, height);
! Base.setVid(width, height);
! // let the sound and input subsystems know about the new window
! VID.NewWindow(width, height);
! }
!
! /** <B>Overrides:</B>
<DL><DD><CODE>paint</CODE> in class <CODE>java.awt.Component</CODE></DD></DL> */
// Overridden from Canvas to prevent the AWT's clearing of the
|