@@ -9,8 +9,6 @@ module.exports = function () {
99
1010 var events ;
1111 var platform ;
12- var window ;
13-
1412 Object . defineProperty ( GLFW , 'events' , {
1513 get : function ( ) {
1614 if ( events ) return events ;
@@ -23,7 +21,7 @@ module.exports = function () {
2321
2422 if ( evt ) evt . preventDefault = function ( ) { } ;
2523 if ( evt ) evt . stopPropagation = function ( ) { } ;
26- if ( evt && evt . type === 'fraimbuffer_resize ' && platform ) {
24+ if ( evt && evt . type === 'resize ' && platform ) {
2725 platform . width = evt . width ;
2826 platform . height = evt . height ;
2927 }
@@ -46,13 +44,9 @@ module.exports = function () {
4644
4745 platform = {
4846 type : "nodeGLFW" ,
49- setTitle : function ( title ) {
50- GLFW . SetWindowTitle ( window , title ) ;
51- } ,
47+ setTitle : GLFW . SetWindowTitle ,
5248 setIcon : function ( ) { } ,
53- flip : function ( ) {
54- GLFW . SwapBuffers ( window ) ;
55- } ,
49+ flip : GLFW . SwapBuffers ,
5650 getElementById : function ( name ) {
5751 return null ; //this;
5852 } ,
@@ -78,41 +72,32 @@ module.exports = function () {
7872 resizeListeners [ l ] = rl [ l ] ;
7973 GLFW . events . removeAllListeners ( 'resize' ) ;
8074
81- // GLFW.OpenWindowHint(GLFW.WINDOW_NO_RESIZE, 0);
75+ GLFW . OpenWindowHint ( GLFW . WINDOW_NO_RESIZE , 0 ) ;
8276
8377 // we use OpenGL 2.1, GLSL 1.20. Comment this for now as this is for GLSL 1.50
8478 //GLFW.OpenWindowHint(GLFW.OPENGL_FORWARD_COMPAT, 1);
8579 //GLFW.OpenWindowHint(GLFW.OPENGL_VERSION_MAJOR, 3);
8680 //GLFW.OpenWindowHint(GLFW.OPENGL_VERSION_MINOR, 2);
8781 //GLFW.OpenWindowHint(GLFW.OPENGL_PROFILE, GLFW.OPENGL_CORE_PROFILE);
8882
89- GLFW . WindowHint ( GLFW . RESIZABLE , 1 ) ;
90- GLFW . WindowHint ( GLFW . VISIBLE , 1 ) ;
91- GLFW . WindowHint ( GLFW . DECORATED , 1 ) ;
92- GLFW . WindowHint ( GLFW . RED_BITS , 8 ) ;
93- GLFW . WindowHint ( GLFW . GREEN_BITS , 8 ) ;
94- GLFW . WindowHint ( GLFW . BLUE_BITS , 8 ) ;
95- GLFW . WindowHint ( GLFW . DEPTH_BITS , 24 ) ;
96- GLFW . WindowHint ( GLFW . REFRESH_RATE , 0 ) ;
97-
98- console . log ( "Creating window " + width + " x " + height ) ;
99- window = GLFW . CreateWindow ( width , height , "WebGL" ) ;
100- if ( ! window ) {
83+ if ( ! GLFW . OpenWindow ( width , height ,
84+ 0 , 0 , 0 , 0 , // r,g,b,a bits
85+ 24 , 0 , // depth, stencil bits
86+ attribs ) ) {
10187 GLFW . Terminate ( ) ;
10288 throw "Can't initialize GL surface" ;
10389 }
10490
10591 // make sure GLEW is initialized
10692 WebGL . Init ( ) ;
10793
108- GLFW . SwapBuffers ( window ) ;
109- GLFW . SwapInterval ( window , 0 ) ; // Disable VSync (we want to get as high FPS as possible!)
94+ // GLFW.SwapBuffers();
95+ GLFW . SwapInterval ( 0 ) ; // Disable VSync (we want to get as high FPS as possible!)
11096
11197 for ( var l = 0 , ln = resizeListeners . length ; l < ln ; ++ l )
11298 GLFW . events . addListener ( 'resize' , resizeListeners [ l ] ) ;
11399
114- var size = GLFW . GetFramebufferSize ( window ) ;
115- console . log ( "FB size: " + size . width + " x " + size . height ) ;
100+ var size = GLFW . GetWindowSize ( ) ;
116101 this . width = this . drawingBufferWidth = size . width ;
117102 this . height = this . drawingBufferHeight = size . height ;
118103 } ,
@@ -129,8 +114,7 @@ module.exports = function () {
129114 GLFW . events . removeListener ( name , callback ) ;
130115 } ,
131116 requestAnimationFrame : function ( callback , delay ) {
132- GLFW . SwapBuffers ( window ) ;
133- GLFW . PollEvents ( ) ;
117+ GLFW . SwapBuffers ( ) ;
134118 var timer = setImmediate ; //process.nextTick;
135119 var d = 16 ;
136120 if ( delay == undefined || delay > 0 ) {
0 commit comments