AWTGLCanvas problems

Started by CodeBunny, January 28, 2011, 16:52:28

Previous topic - Next topic

broumbroum

It should reshape. Initially, the canvas has a reshape function that 'd be implemented. By now, you could simply force reshape manually :
/** a symetrical Projection is made and the origin is lifted to
  1201      * the Java2D common sense location (i.e. the up-left corner
  1202      * with x and y pointing the the opposite corner), Z-negative is where the camera points
  1203      */
  1204     private static void _GL_reshape(RenderingScene canvas, boolean ortho) {
  1205         GL11.glViewport(0,
  1206                 0,
  1207                 canvas.getWidth(), canvas.getHeight());
  1208         /** set your projection matrix*/GLHandler._GLsetProjMX(ortho, canvas.getSize(), _GL_NEARVAL, _GL_FARVAL);
  1209         GL11.glMatrixMode(GL11.GL_MODELVIEW);
  1210         GL11.glLoadIdentity();
  1211         GL11.glTranslatef(-canvas.getWidth() / 2f, -canvas.getHeight() / 2f, 0);
  1212         GL11.glFlush();
  1213         if (debug) {
  1214             System.err.println("GL reshaped " + canvas.getWidth() + " x " + canvas.getHeight());
  1215         }
  1216     }
  1217
This works well for me : I reshape on every paintGL.
protected void paintGL() {
  1238         try {
  ...
  1242             screenThreadId = Thread.currentThread().getId();
  1243             super.paintGL();
  1244             GL11.glClearColor(_GLclearColor.get(0), _GLclearColor.get(1), _GLclearColor.get(2), _GLclearColor.get(3));
/** reshape before to clear the background ?! :)*/
  1245             _GL_reshape(this, ....);
  ...
  1249             /* clear screen*/
  1250             GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
  1251             ....
}


my source code : http://sf3jswing.hg.sourceforge.net/hgweb/sf3jswing/sf3jswing/file/6b338a55c9db/sf3jswing-jigaxtended/src/all/net/sf/jiga/xtended/impl/game/RenderingScene.java