Exemple #1
0
 createWindow: function(width, height) {
   var attribs=GLFW.WINDOW;
   
   if(width==0 || height==0) {
     attribs = GLFW.FULLSCREEN;
     width=height=0;
   }
   
   var resizeListeners=GLFW.events.listeners('resize');
   GLFW.events.removeAllListeners('resize');
   
   GLFW.OpenWindowHint(GLFW.WINDOW_NO_RESIZE, 0);
   
   // we use OpenGL 2.1, GLSL 1.20. Comment this for now as this is for GLSL 1.50
   //GLFW.OpenWindowHint(GLFW.OPENGL_FORWARD_COMPAT, 1);
   //GLFW.OpenWindowHint(GLFW.OPENGL_VERSION_MAJOR, 3);
   //GLFW.OpenWindowHint(GLFW.OPENGL_VERSION_MINOR, 2);
   //GLFW.OpenWindowHint(GLFW.OPENGL_PROFILE, GLFW.OPENGL_CORE_PROFILE);
   
   if(!GLFW.OpenWindow( width, height, 
       0,0,0,0, // r,g,b,a bits
       24,0, // depth, stencil bits
       attribs ) )
     throw "Can't initialize GL surface";
   
   //GLFW.SwapBuffers();
   
   for(l in resizeListeners)
     GLFW.events.addListener('resize',resizeListeners[l]);
   
   var size=GLFW.GetWindowSize();
   this.width = this.drawingBufferWidth=size.width; 
   this.height = this.drawingBufferHeight=size.height;
 },
Exemple #2
0
        createWindow: function (width, height) {
            var attribs = GLFW.WINDOW;

            if (width == 0 || height == 0) {
                attribs = GLFW.FULLSCREEN;
                width = height = 0;
            }

            var resizeListeners = [], rl = GLFW.events.listeners("framebuffer_resize");
            for (var l = 0, ln = rl.length; l < ln; ++l)
                resizeListeners[l] = rl[l];
            GLFW.events.removeAllListeners("framebuffer_resize");

            GLFW.DefaultWindowHints();

            // we use OpenGL 2.1, GLSL 1.20. Comment this for now as this is for GLSL 1.50
            //GLFW.OpenWindowHint(GLFW.OPENGL_FORWARD_COMPAT, 1);
            //GLFW.OpenWindowHint(GLFW.OPENGL_VERSION_MAJOR, 3);
            //GLFW.OpenWindowHint(GLFW.OPENGL_VERSION_MINOR, 2);
            //GLFW.OpenWindowHint(GLFW.OPENGL_PROFILE, GLFW.OPENGL_CORE_PROFILE);
            GLFW.WindowHint(GLFW.RESIZABLE, 1);
            GLFW.WindowHint(GLFW.VISIBLE, 1);
            GLFW.WindowHint(GLFW.DECORATED, 1);
            GLFW.WindowHint(GLFW.RED_BITS, 8);
            GLFW.WindowHint(GLFW.GREEN_BITS, 8);
            GLFW.WindowHint(GLFW.BLUE_BITS, 8);
            GLFW.WindowHint(GLFW.DEPTH_BITS, 24);
            GLFW.WindowHint(GLFW.REFRESH_RATE, 0);

            if (!(window=GLFW.CreateWindow(width, height))) {
                GLFW.Terminate();
                throw "Can't initialize GL surface";
            }

            GLFW.MakeContextCurrent(window);

            GLFW.SetWindowTitle("WebGL");

            // make sure GLEW is initialized
            WebGL.Init();

            GLFW.SwapBuffers(window);
            GLFW.SwapInterval(0); // Disable VSync (we want to get as high FPS as possible!)

            for (var l = 0, ln = resizeListeners.length; l < ln; ++l)
                GLFW.events.addListener("framebuffer_resize", resizeListeners[l]);

            var sizeWin = GLFW.GetWindowSize(window);
            var sizeFB = GLFW.GetFramebufferSize(window);
            this.ratio=sizeFB.width / sizeWin.width;
            this.width = this.drawingBufferWidth = sizeFB.width;
            this.height = this.drawingBufferHeight = sizeFB.height;
        },
        createWindow: function (width, height) {
            var attribs = GLFW.WINDOW;

            if (width == 0 || height == 0) {
                attribs = GLFW.FULLSCREEN;
                width = height = 0;
            }

            var resizeListeners = [], rl = GLFW.events.listeners('resize');
            for (var l = 0, ln = rl.length; l < ln; ++l)
                resizeListeners[l] = rl[l];
            GLFW.events.removeAllListeners('resize');

            GLFW.OpenWindowHint(GLFW.WINDOW_NO_RESIZE, 0);

            // we use OpenGL 2.1, GLSL 1.20. Comment this for now as this is for GLSL 1.50
            //GLFW.OpenWindowHint(GLFW.OPENGL_FORWARD_COMPAT, 1);
            //GLFW.OpenWindowHint(GLFW.OPENGL_VERSION_MAJOR, 3);
            //GLFW.OpenWindowHint(GLFW.OPENGL_VERSION_MINOR, 2);
            //GLFW.OpenWindowHint(GLFW.OPENGL_PROFILE, GLFW.OPENGL_CORE_PROFILE);

            if (!GLFW.OpenWindow(width, height,
                                  0, 0, 0, 0, // r,g,b,a bits
                                  24, 0, // depth, stencil bits
                                  attribs)) {
                GLFW.Terminate();
                throw "Can't initialize GL surface";
            }

            // make sure GLEW is initialized
            WebGL.Init();

            //GLFW.SwapBuffers();
            GLFW.SwapInterval(0); // Disable VSync (we want to get as high FPS as possible!)

            for (var l = 0, ln = resizeListeners.length; l < ln; ++l)
                GLFW.events.addListener('resize', resizeListeners[l]);

            var size = GLFW.GetWindowSize();
            this.width = this.drawingBufferWidth = size.width;
            this.height = this.drawingBufferHeight = size.height;
        },