LWJGL Forum

Programming => OpenGL => Topic started by: polskyman on October 31, 2006, 21:38:13

Title: fullscreen for LWJGL applet ? possible?
Post by: polskyman on October 31, 2006, 21:38:13
Hi everybody,

I am trying to make an applet being able to be fullscreen.
I tried this line of command:
try
      {
      Display.setFullscreen(true);
   }
   catch (Exception fdf){System.out.println(fdf);}

but it doesn't work.
please could you help me.
thanks a lot




here is the full code:



import java.io.*;

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;

import org.lwjgl.opengl.PixelFormat;

import org.lwjgl.opengl.glu.*;



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(new PixelFormat(8, 0, 0, 0));
     
     canvas.setSize(getWidth(), getHeight());
     add(canvas);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
 
 /*
  * @see org.lwjgl.opengl.AWTGLCanvas
  */
 public class AppletCanvas extends AWTGLCanvas {
   
   

   float angle = 0;
   
   
   
   
   public AppletCanvas(PixelFormat pixel_format) throws LWJGLException {
   super(pixel_format);
   
   
     
     
     
     
     Thread t = new Thread() {
       public void run() {
         Display.sync(60);
         
         
         while (true)
         {
           if (isVisible()) {
             repaint();
            }
           
           
           
           
           try
    {
    Display.setFullscreen(true);
}
catch (Exception fdf){System.out.println(fdf);}
           
           
           Display.sync(60);
         }
       }
     };
     t.setDaemon(true);
     t.start();      
   }
   
   
   
   public void initGL()
   {
   
   
   
   
    eng_Scene scene=new eng_Scene(100,100);
   
try{


new eng_3ds_Importer().importFromStream(new FileInputStream("buga.3ds"),scene);
}
catch (Exception ffd){System.out.println(ffd);}

scene.rebuild();

scene.printSceneInfo();

   
   
    GL11.glMatrixMode(GL11.GL_PROJECTION_MATRIX);
     GL11.glLoadIdentity();
     //GL11.glOrtho(0, 640, 0, 480, 1, -1);
     

     GLU.gluPerspective(45.0f,this.getWidth() / (float) this.getHeight(), .1f ,150.0f);
     GL11.glMatrixMode(GL11.GL_MODELVIEW_MATRIX);
   
   
}
   
   
   
   
   
   /*
    * @see org.lwjgl.opengl.AWTGLCanvas#paintGL()
    */
   public void paintGL() {
     
     
     /*
     GL11.glEnable ( GL11.GL_POLYGON_SMOOTH );
GL11.glEnable ( GL11.GL_BLEND );
//GL11.glBlendFunc ( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA );
GL11.glBlendFunc (GL11.GL_SRC_ALPHA_SATURATE,GL11.GL_ONE);
GL11.glHint ( GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST );
*/
     
     
     
     
     GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
     
     

     GL11.glPushMatrix();
     //GL11.glTranslatef(320, 240, 0.0f);
     GL11.glRotatef(angle, 0, 0, 1.0f);
     GL11.glBegin(GL11.GL_QUADS);
     GL11.glVertex3i(-10, -10,-120);
     GL11.glVertex3i(10, -10,-120);
     GL11.glVertex3i(10, 10,-120);
     GL11.glVertex3i(-10, 10,-120);
     GL11.glEnd();
     GL11.glPopMatrix();

     angle += 0.2f;

     try {
       swapBuffers();
     } catch (Exception e) {
     }
   }  
 }
}
Title: fullscreen for LWJGL applet ? possible?
Post by: Matzon on October 31, 2006, 22:48:15
you can't

best bet is to create a new native display and make that go fullscreen - not tested ti tho
Title: fullscreen for LWJGL applet ? possible?
Post by: polskyman on November 01, 2006, 12:43:56
ok,
could you provide a sample code to switch from this applet to a fullscreen context?
I think the first applet context can be destroyed but i have  no idea how to perform it.
thanks