ruby-glfw 0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -0
- data/README.API +73 -0
- data/Rakefile +120 -0
- data/examples/boing.rb +519 -0
- data/examples/gears.rb +327 -0
- data/examples/keytest.rb +117 -0
- data/examples/listmodes.rb +20 -0
- data/examples/mipmaps.rb +104 -0
- data/examples/mipmaps.tga +0 -0
- data/examples/particles.rb +837 -0
- data/examples/pong3d.rb +741 -0
- data/examples/pong3d_field.tga +0 -0
- data/examples/pong3d_instr.tga +0 -0
- data/examples/pong3d_menu.tga +0 -0
- data/examples/pong3d_title.tga +0 -0
- data/examples/pong3d_winner1.tga +0 -0
- data/examples/pong3d_winner2.tga +0 -0
- data/examples/splitview.rb +432 -0
- data/examples/triangle.rb +89 -0
- data/examples/wave.rb +294 -0
- data/ext/glfw/glfw.c +1094 -0
- data/ext/glfw/mkrf_conf.rb +70 -0
- data/glfw-src/Makefile +220 -0
- data/glfw-src/compile.ami +61 -0
- data/glfw-src/compile.bat +217 -0
- data/glfw-src/compile.sh +607 -0
- data/glfw-src/docs/Makefile +57 -0
- data/glfw-src/docs/Reference.pdf +0 -0
- data/glfw-src/docs/UsersGuide.pdf +0 -0
- data/glfw-src/docs/cleanup.bat +22 -0
- data/glfw-src/docs/glfwdoc.sty +80 -0
- data/glfw-src/docs/glfwrm.tex +3034 -0
- data/glfw-src/docs/glfwug.tex +2024 -0
- data/glfw-src/docs/readme.txt +80 -0
- data/glfw-src/examples/Makefile.amigaos.gcc +70 -0
- data/glfw-src/examples/Makefile.amigaos.vbcc +70 -0
- data/glfw-src/examples/Makefile.dos.djgpp +71 -0
- data/glfw-src/examples/Makefile.macosx.gcc +96 -0
- data/glfw-src/examples/Makefile.win32.bcc +75 -0
- data/glfw-src/examples/Makefile.win32.cross-mgw +79 -0
- data/glfw-src/examples/Makefile.win32.cygwin +79 -0
- data/glfw-src/examples/Makefile.win32.lcc +74 -0
- data/glfw-src/examples/Makefile.win32.mgw +75 -0
- data/glfw-src/examples/Makefile.win32.msvc +74 -0
- data/glfw-src/examples/Makefile.win32.ow +74 -0
- data/glfw-src/examples/Makefile.win32.pellesc +74 -0
- data/glfw-src/examples/Makefile.x11.in +54 -0
- data/glfw-src/examples/boing.c +606 -0
- data/glfw-src/examples/bundle.sh +46 -0
- data/glfw-src/examples/gears.c +382 -0
- data/glfw-src/examples/keytest.c +264 -0
- data/glfw-src/examples/listmodes.c +48 -0
- data/glfw-src/examples/mipmaps.c +126 -0
- data/glfw-src/examples/mipmaps.tga +0 -0
- data/glfw-src/examples/mtbench.c +301 -0
- data/glfw-src/examples/mthello.c +48 -0
- data/glfw-src/examples/particles.c +1148 -0
- data/glfw-src/examples/pong3d.c +839 -0
- data/glfw-src/examples/pong3d_field.tga +0 -0
- data/glfw-src/examples/pong3d_instr.tga +0 -0
- data/glfw-src/examples/pong3d_menu.tga +0 -0
- data/glfw-src/examples/pong3d_title.tga +0 -0
- data/glfw-src/examples/pong3d_winner1.tga +0 -0
- data/glfw-src/examples/pong3d_winner2.tga +0 -0
- data/glfw-src/examples/splitview.c +506 -0
- data/glfw-src/examples/triangle.c +108 -0
- data/glfw-src/examples/wave.c +397 -0
- data/glfw-src/images/opengl.gif +0 -0
- data/glfw-src/images/osicert.gif +0 -0
- data/glfw-src/include/GL/glfw.h +486 -0
- data/glfw-src/lib/amigaos/Makefile.amigaos.gcc +128 -0
- data/glfw-src/lib/amigaos/Makefile.amigaos.vbcc +128 -0
- data/glfw-src/lib/amigaos/SDI_compiler.h +94 -0
- data/glfw-src/lib/amigaos/amigaos_enable.c +51 -0
- data/glfw-src/lib/amigaos/amigaos_fullscreen.c +319 -0
- data/glfw-src/lib/amigaos/amigaos_glext.c +61 -0
- data/glfw-src/lib/amigaos/amigaos_init.c +284 -0
- data/glfw-src/lib/amigaos/amigaos_joystick.c +359 -0
- data/glfw-src/lib/amigaos/amigaos_thread.c +494 -0
- data/glfw-src/lib/amigaos/amigaos_time.c +206 -0
- data/glfw-src/lib/amigaos/amigaos_window.c +830 -0
- data/glfw-src/lib/amigaos/platform.h +337 -0
- data/glfw-src/lib/dos/Makefile.dos.djgpp +146 -0
- data/glfw-src/lib/dos/dos_enable.c +51 -0
- data/glfw-src/lib/dos/dos_events.c +173 -0
- data/glfw-src/lib/dos/dos_fullscreen.c +101 -0
- data/glfw-src/lib/dos/dos_glext.c +59 -0
- data/glfw-src/lib/dos/dos_init.c +105 -0
- data/glfw-src/lib/dos/dos_irq.s +246 -0
- data/glfw-src/lib/dos/dos_joystick.c +94 -0
- data/glfw-src/lib/dos/dos_keyboard.c +694 -0
- data/glfw-src/lib/dos/dos_mouse.c +337 -0
- data/glfw-src/lib/dos/dos_thread.c +267 -0
- data/glfw-src/lib/dos/dos_time.c +309 -0
- data/glfw-src/lib/dos/dos_window.c +563 -0
- data/glfw-src/lib/dos/platform.h +341 -0
- data/glfw-src/lib/enable.c +295 -0
- data/glfw-src/lib/fullscreen.c +95 -0
- data/glfw-src/lib/glext.c +201 -0
- data/glfw-src/lib/image.c +629 -0
- data/glfw-src/lib/init.c +108 -0
- data/glfw-src/lib/input.c +280 -0
- data/glfw-src/lib/internal.h +210 -0
- data/glfw-src/lib/joystick.c +101 -0
- data/glfw-src/lib/macosx/Makefile.macosx.gcc +172 -0
- data/glfw-src/lib/macosx/Makefile.macosx.gcc.universal +166 -0
- data/glfw-src/lib/macosx/libglfw.pc.in +11 -0
- data/glfw-src/lib/macosx/macosx_enable.c +42 -0
- data/glfw-src/lib/macosx/macosx_fullscreen.c +126 -0
- data/glfw-src/lib/macosx/macosx_glext.c +52 -0
- data/glfw-src/lib/macosx/macosx_init.c +194 -0
- data/glfw-src/lib/macosx/macosx_joystick.c +50 -0
- data/glfw-src/lib/macosx/macosx_thread.c +414 -0
- data/glfw-src/lib/macosx/macosx_time.c +112 -0
- data/glfw-src/lib/macosx/macosx_window.c +1279 -0
- data/glfw-src/lib/macosx/platform.h +349 -0
- data/glfw-src/lib/stream.c +194 -0
- data/glfw-src/lib/tga.c +405 -0
- data/glfw-src/lib/thread.c +340 -0
- data/glfw-src/lib/time.c +83 -0
- data/glfw-src/lib/win32/Makefile.win32.bcc +265 -0
- data/glfw-src/lib/win32/Makefile.win32.cross-mgw +274 -0
- data/glfw-src/lib/win32/Makefile.win32.cygwin +279 -0
- data/glfw-src/lib/win32/Makefile.win32.lcc +246 -0
- data/glfw-src/lib/win32/Makefile.win32.mgw +243 -0
- data/glfw-src/lib/win32/Makefile.win32.msvc +242 -0
- data/glfw-src/lib/win32/Makefile.win32.ow +242 -0
- data/glfw-src/lib/win32/Makefile.win32.pellesc +242 -0
- data/glfw-src/lib/win32/glfwdll.def +67 -0
- data/glfw-src/lib/win32/glfwdll_mgw1.def +67 -0
- data/glfw-src/lib/win32/glfwdll_mgw2.def +67 -0
- data/glfw-src/lib/win32/glfwdll_pellesc.def +65 -0
- data/glfw-src/lib/win32/libglfw.pc.in +11 -0
- data/glfw-src/lib/win32/platform.h +474 -0
- data/glfw-src/lib/win32/win32_dllmain.c +60 -0
- data/glfw-src/lib/win32/win32_enable.c +155 -0
- data/glfw-src/lib/win32/win32_fullscreen.c +317 -0
- data/glfw-src/lib/win32/win32_glext.c +85 -0
- data/glfw-src/lib/win32/win32_init.c +356 -0
- data/glfw-src/lib/win32/win32_joystick.c +234 -0
- data/glfw-src/lib/win32/win32_thread.c +511 -0
- data/glfw-src/lib/win32/win32_time.c +146 -0
- data/glfw-src/lib/win32/win32_window.c +1714 -0
- data/glfw-src/lib/window.c +727 -0
- data/glfw-src/lib/x11/Makefile.x11.in +243 -0
- data/glfw-src/lib/x11/platform.h +415 -0
- data/glfw-src/lib/x11/x11_enable.c +51 -0
- data/glfw-src/lib/x11/x11_fullscreen.c +524 -0
- data/glfw-src/lib/x11/x11_glext.c +69 -0
- data/glfw-src/lib/x11/x11_init.c +275 -0
- data/glfw-src/lib/x11/x11_joystick.c +371 -0
- data/glfw-src/lib/x11/x11_keysym2unicode.c +902 -0
- data/glfw-src/lib/x11/x11_thread.c +507 -0
- data/glfw-src/lib/x11/x11_time.c +154 -0
- data/glfw-src/lib/x11/x11_window.c +1746 -0
- data/glfw-src/license.txt +21 -0
- data/glfw-src/readme.html +927 -0
- data/glfw-src/support/d/examples/Makefile +59 -0
- data/glfw-src/support/d/examples/boing.d +610 -0
- data/glfw-src/support/d/examples/gears.d +379 -0
- data/glfw-src/support/d/examples/keytest.d +272 -0
- data/glfw-src/support/d/examples/listmodes.d +48 -0
- data/glfw-src/support/d/examples/mipmaps.d +126 -0
- data/glfw-src/support/d/examples/mtbench.d +304 -0
- data/glfw-src/support/d/examples/mthello.d +54 -0
- data/glfw-src/support/d/examples/particles.d +1150 -0
- data/glfw-src/support/d/examples/pong3d.d +840 -0
- data/glfw-src/support/d/examples/splitview.d +486 -0
- data/glfw-src/support/d/examples/triangle.d +108 -0
- data/glfw-src/support/d/examples/wave.d +400 -0
- data/glfw-src/support/d/imports/gl.d +4539 -0
- data/glfw-src/support/d/imports/glfw.d +349 -0
- data/glfw-src/support/d/imports/glu.d +328 -0
- data/glfw-src/support/d/lib/glfwdll.def +64 -0
- data/glfw-src/support/d/lib/glu32.def +56 -0
- data/glfw-src/support/d/lib/makefile +12 -0
- data/glfw-src/support/d/lib/opengl32.def +372 -0
- data/glfw-src/support/d/readme.html +83 -0
- data/glfw-src/support/delphi/examples/Triangle.dpr +105 -0
- data/glfw-src/support/delphi/lib/glfw.pas +437 -0
- data/glfw-src/support/delphi/readme.html +97 -0
- data/glfw-src/support/lua/examples/gears.lua +383 -0
- data/glfw-src/support/lua/examples/test1.lua +68 -0
- data/glfw-src/support/lua/readme.html +128 -0
- data/glfw-src/support/lua/src/luaglfw.c +1179 -0
- data/glfw-src/support/lua/src/luaglfw.h +48 -0
- data/glfw-src/support/lua/src/runlua.c +82 -0
- data/glfw-src/support/masm/examples/fpc.mac +47 -0
- data/glfw-src/support/masm/examples/makeit.bat +66 -0
- data/glfw-src/support/masm/examples/triangle.asm +232 -0
- data/glfw-src/support/masm/include/glfw.inc +326 -0
- data/glfw-src/support/masm/include/glu32.inc +55 -0
- data/glfw-src/support/masm/include/opengl32.inc +372 -0
- data/glfw-src/support/masm/lib/glfwdll.lib +0 -0
- data/glfw-src/support/masm/readme.html +170 -0
- data/glfw-src/support/msvc80/GLFW.sln +26 -0
- data/glfw-src/support/msvc80/GLFW.vcproj +257 -0
- data/glfw-src/support/msvc80/GLFWDLL.vcproj +287 -0
- data/glfw-src/support/visualbasic/bindings/glfw.bas +320 -0
- data/glfw-src/support/visualbasic/bindings/glu32.bas +284 -0
- data/glfw-src/support/visualbasic/bindings/opengl32.bas +999 -0
- data/glfw-src/support/visualbasic/examples/Triangle.bas +101 -0
- data/glfw-src/support/visualbasic/readme.html +164 -0
- data/website/index.html +84 -0
- data/website/style.css +110 -0
- metadata +301 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
//========================================================================
|
2
|
+
// GLFW - An OpenGL framework
|
3
|
+
// File: luaglfw.h
|
4
|
+
// Platform: Lua 5.0
|
5
|
+
// API version: 2.5
|
6
|
+
// WWW: http://glfw.sourceforge.net
|
7
|
+
//------------------------------------------------------------------------
|
8
|
+
// Copyright (c) 2002-2005 Camilla Berglund
|
9
|
+
//
|
10
|
+
// This software is provided 'as-is', without any express or implied
|
11
|
+
// warranty. In no event will the authors be held liable for any damages
|
12
|
+
// arising from the use of this software.
|
13
|
+
//
|
14
|
+
// Permission is granted to anyone to use this software for any purpose,
|
15
|
+
// including commercial applications, and to alter it and redistribute it
|
16
|
+
// freely, subject to the following restrictions:
|
17
|
+
//
|
18
|
+
// 1. The origin of this software must not be misrepresented; you must not
|
19
|
+
// claim that you wrote the original software. If you use this software
|
20
|
+
// in a product, an acknowledgment in the product documentation would
|
21
|
+
// be appreciated but is not required.
|
22
|
+
//
|
23
|
+
// 2. Altered source versions must be plainly marked as such, and must not
|
24
|
+
// be misrepresented as being the original software.
|
25
|
+
//
|
26
|
+
// 3. This notice may not be removed or altered from any source
|
27
|
+
// distribution.
|
28
|
+
//
|
29
|
+
//========================================================================
|
30
|
+
|
31
|
+
#ifndef __luaglfw_h_
|
32
|
+
#define __luaglfw_h_
|
33
|
+
|
34
|
+
#ifdef __cplusplus
|
35
|
+
extern "C" {
|
36
|
+
#endif
|
37
|
+
|
38
|
+
|
39
|
+
#include <lua.h>
|
40
|
+
|
41
|
+
int luaopen_glfw( lua_State * L );
|
42
|
+
|
43
|
+
|
44
|
+
#ifdef __cplusplus
|
45
|
+
}
|
46
|
+
#endif
|
47
|
+
|
48
|
+
#endif // __luaglfw_h_
|
@@ -0,0 +1,82 @@
|
|
1
|
+
//========================================================================
|
2
|
+
// A simple Lua interpreter with support for GLFW and OpenGL
|
3
|
+
// File: runlua.c
|
4
|
+
// Platform: Lua 5.0 + LuaGL + luaglfw
|
5
|
+
// WWW: http://glfw.sourceforge.net
|
6
|
+
//------------------------------------------------------------------------
|
7
|
+
// Copyright (c) 2002-2005 Camilla Berglund
|
8
|
+
//
|
9
|
+
// This software is provided 'as-is', without any express or implied
|
10
|
+
// warranty. In no event will the authors be held liable for any damages
|
11
|
+
// arising from the use of this software.
|
12
|
+
//
|
13
|
+
// Permission is granted to anyone to use this software for any purpose,
|
14
|
+
// including commercial applications, and to alter it and redistribute it
|
15
|
+
// freely, subject to the following restrictions:
|
16
|
+
//
|
17
|
+
// 1. The origin of this software must not be misrepresented; you must not
|
18
|
+
// claim that you wrote the original software. If you use this software
|
19
|
+
// in a product, an acknowledgment in the product documentation would
|
20
|
+
// be appreciated but is not required.
|
21
|
+
//
|
22
|
+
// 2. Altered source versions must be plainly marked as such, and must not
|
23
|
+
// be misrepresented as being the original software.
|
24
|
+
//
|
25
|
+
// 3. This notice may not be removed or altered from any source
|
26
|
+
// distribution.
|
27
|
+
//
|
28
|
+
//========================================================================
|
29
|
+
|
30
|
+
#include <stdio.h>
|
31
|
+
#include <lua.h>
|
32
|
+
#include <lauxlib.h>
|
33
|
+
#include <lualib.h>
|
34
|
+
|
35
|
+
#include <LuaGL.h>
|
36
|
+
#include "luaglfw.h"
|
37
|
+
|
38
|
+
|
39
|
+
//========================================================================
|
40
|
+
// main() - Program entry point
|
41
|
+
//========================================================================
|
42
|
+
|
43
|
+
int main( int argc, char **argv )
|
44
|
+
{
|
45
|
+
lua_State *L;
|
46
|
+
|
47
|
+
// Check arguments
|
48
|
+
if( argc != 2 )
|
49
|
+
{
|
50
|
+
printf( "Usage: %s filename.lua\n", argv[0] );
|
51
|
+
return -1;
|
52
|
+
}
|
53
|
+
|
54
|
+
// Init Lua
|
55
|
+
L = lua_open();
|
56
|
+
if( !L )
|
57
|
+
{
|
58
|
+
printf("Unable to start Lua\n");
|
59
|
+
return -1;
|
60
|
+
}
|
61
|
+
|
62
|
+
// Open all Lua standard libraries
|
63
|
+
luaopen_base( L );
|
64
|
+
luaopen_table( L );
|
65
|
+
luaopen_io( L );
|
66
|
+
luaopen_string( L );
|
67
|
+
luaopen_math( L );
|
68
|
+
|
69
|
+
// Open LuaGL and luaglfw libraries
|
70
|
+
luaopen_opengl( L );
|
71
|
+
luaopen_glfw( L );
|
72
|
+
|
73
|
+
// Load and run the selected Lua program
|
74
|
+
if( luaL_loadfile( L, argv[1] ) || lua_pcall( L, 0, 0, 0 ) )
|
75
|
+
{
|
76
|
+
printf("Error running Lua program: %s\n", lua_tostring( L, -1 ) );
|
77
|
+
lua_pop( L, 1 );
|
78
|
+
return -1;
|
79
|
+
}
|
80
|
+
|
81
|
+
return 0;
|
82
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
;#########################################################################
|
2
|
+
;# FPC - Floating Point Constant #
|
3
|
+
;# Macro by BitRake #
|
4
|
+
;#########################################################################
|
5
|
+
|
6
|
+
fpc MACRO val:REQ
|
7
|
+
LOCAL w,x,y,z,zz,ww
|
8
|
+
|
9
|
+
;; split type and value, defaulting to REAL4
|
10
|
+
z INSTR 1,<&val>,<! >
|
11
|
+
IF z EQ 0
|
12
|
+
y TEXTEQU <REAL4>
|
13
|
+
x TEXTEQU <&val>
|
14
|
+
ELSE
|
15
|
+
y TEXTEQU @SubStr(<&val>,1,z-1) ;; Type
|
16
|
+
x TEXTEQU @SubStr(<&val>,z+1,) ;; Value
|
17
|
+
ENDIF
|
18
|
+
|
19
|
+
;; replace . with _
|
20
|
+
z INSTR 1,x,<!.>
|
21
|
+
IF z EQ 0
|
22
|
+
w TEXTEQU x
|
23
|
+
x CATSTR x,<.0> ;; prevent error message
|
24
|
+
ELSE
|
25
|
+
w CATSTR @SubStr(%x,1,z-1),<_>,@SubStr(%x,z+1,)
|
26
|
+
ENDIF
|
27
|
+
|
28
|
+
;; replace - with _
|
29
|
+
zz INSTR 1,w,<!->
|
30
|
+
IF zz EQ 0
|
31
|
+
ww TEXTEQU w
|
32
|
+
ELSE
|
33
|
+
ww CATSTR @SubStr(%w,1,zz-1),<_>,@SubStr(%w,zz+1,)
|
34
|
+
ENDIF
|
35
|
+
|
36
|
+
;; figure out global name for constant
|
37
|
+
z SIZESTR y ;; use last char for size distiction
|
38
|
+
ww CATSTR <__>,ww,<r>,@SubStr(%y,z,1)
|
39
|
+
|
40
|
+
IF (OPATTR(ww)) EQ 0 ;; not defined
|
41
|
+
CONST SEGMENT
|
42
|
+
ww y x
|
43
|
+
CONST ENDS
|
44
|
+
ENDIF
|
45
|
+
EXITM ww
|
46
|
+
ENDM
|
47
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
@ECHO OFF
|
2
|
+
|
3
|
+
REM **********************************************************************
|
4
|
+
REM * This is the build script for the GLFW example programs for MASM32. *
|
5
|
+
REM * *
|
6
|
+
REM * Unlike the MASM32 recommendations, I like to keep my MASM32 *
|
7
|
+
REM * installation on one partition, and my GLFW/MASM32 projects on *
|
8
|
+
REM * another partition, which is why the script begins by finding which *
|
9
|
+
REM * drive MASM32 is installed on. Thus, all MASM32 related paths (BIN, *
|
10
|
+
REM * INCLUDE and LIB) are absolute rather than drive relative. *
|
11
|
+
REM * *
|
12
|
+
REM * Feel free to use this build file for your own MASM32 projects (it *
|
13
|
+
REM * is only necessary to make minor changes in the Compile section). *
|
14
|
+
REM **********************************************************************
|
15
|
+
|
16
|
+
REM **********************************************************************
|
17
|
+
REM * MASM32 is drive sensitive. Figure out where it is installed. *
|
18
|
+
REM **********************************************************************
|
19
|
+
SET masmdrv=
|
20
|
+
IF EXIST C:\masm32\bin\ml.exe SET masmdrv=C:
|
21
|
+
IF EXIST D:\masm32\bin\ml.exe SET masmdrv=D:
|
22
|
+
IF EXIST E:\masm32\bin\ml.exe SET masmdrv=E:
|
23
|
+
IF EXIST F:\masm32\bin\ml.exe SET masmdrv=F:
|
24
|
+
IF EXIST G:\masm32\bin\ml.exe SET masmdrv=G:
|
25
|
+
IF EXIST H:\masm32\bin\ml.exe SET masmdrv=H:
|
26
|
+
IF NOT "%masmdrv%" == "" GOTO Compile
|
27
|
+
|
28
|
+
|
29
|
+
REM **********************************************************************
|
30
|
+
REM * Could not find MASM32 installation *
|
31
|
+
REM **********************************************************************
|
32
|
+
|
33
|
+
ECHO ERROR: Could not find MASM32 installation - Aborting.
|
34
|
+
GOTO Exit
|
35
|
+
|
36
|
+
|
37
|
+
REM **********************************************************************
|
38
|
+
REM * Compile programs *
|
39
|
+
REM **********************************************************************
|
40
|
+
:Compile
|
41
|
+
|
42
|
+
REM *** ASSEMBLER AND LINKER FLAGS (for all examples) ***
|
43
|
+
SET aflags=/nologo /c /coff /I%masmdrv%\masm32\include
|
44
|
+
SET lflags=/NOLOGO /SUBSYSTEM:WINDOWS /LIBPATH:%masmdrv%\masm32\lib
|
45
|
+
|
46
|
+
REM *** TRIANGLE ***
|
47
|
+
SET prgname=triangle
|
48
|
+
%masmdrv%\masm32\bin\ml %aflags% %prgname%.asm
|
49
|
+
%masmdrv%\masm32\bin\link %lflags% %prgname%.obj /OUT:%prgname%.exe
|
50
|
+
|
51
|
+
|
52
|
+
REM **********************************************************************
|
53
|
+
REM * Remove internal working variables *
|
54
|
+
REM **********************************************************************
|
55
|
+
:Done
|
56
|
+
|
57
|
+
SET masmdrv=
|
58
|
+
SET aflags=
|
59
|
+
SET lflags=
|
60
|
+
SET prgname=
|
61
|
+
|
62
|
+
|
63
|
+
REM **********************************************************************
|
64
|
+
REM * End of batch file *
|
65
|
+
REM **********************************************************************
|
66
|
+
:Exit
|
@@ -0,0 +1,232 @@
|
|
1
|
+
;=========================================================================
|
2
|
+
; This is a small test application for GLFW.
|
3
|
+
; The program opens a window (640x480), and renders a spinning colored
|
4
|
+
; triangle (it is controlled with both the GLFW timer and the mouse). It
|
5
|
+
; also calculates the rendering speed (FPS), which is displayed in the
|
6
|
+
; window title bar.
|
7
|
+
;
|
8
|
+
; This program was converted from C to x86 assembler by Toni Jovanoski.
|
9
|
+
;=========================================================================
|
10
|
+
|
11
|
+
.686
|
12
|
+
.MODEL FLAT, STDCALL
|
13
|
+
OPTION CASEMAP:NONE
|
14
|
+
|
15
|
+
|
16
|
+
;#########################################################################
|
17
|
+
;# INCLUDES #
|
18
|
+
;#########################################################################
|
19
|
+
|
20
|
+
; Standard Windows includes
|
21
|
+
INCLUDE windows.inc
|
22
|
+
INCLUDE kernel32.inc
|
23
|
+
INCLUDE masm32.inc
|
24
|
+
|
25
|
+
; OpenGL includes
|
26
|
+
INCLUDE opengl32.inc
|
27
|
+
INCLUDE glu32.inc
|
28
|
+
INCLUDE glfw.inc
|
29
|
+
|
30
|
+
; Macros
|
31
|
+
INCLUDE fpc.mac ; floating point constant macro
|
32
|
+
|
33
|
+
|
34
|
+
;#########################################################################
|
35
|
+
;# INCLUDE LIBS #
|
36
|
+
;#########################################################################
|
37
|
+
|
38
|
+
; Standard Windows libs
|
39
|
+
INCLUDELIB kernel32.lib
|
40
|
+
INCLUDELIB masm32.lib
|
41
|
+
|
42
|
+
; OpenGL libs
|
43
|
+
INCLUDELIB opengl32.lib
|
44
|
+
INCLUDELIB glu32.lib
|
45
|
+
INCLUDELIB glfwdll.lib
|
46
|
+
|
47
|
+
|
48
|
+
;#########################################################################
|
49
|
+
;# INIT DATA #
|
50
|
+
;#########################################################################
|
51
|
+
|
52
|
+
.DATA
|
53
|
+
|
54
|
+
|
55
|
+
;#########################################################################
|
56
|
+
;# UNINIT DATA #
|
57
|
+
;#########################################################################
|
58
|
+
|
59
|
+
.DATA?
|
60
|
+
|
61
|
+
ALIGN 8
|
62
|
+
|
63
|
+
t REAL8 ?
|
64
|
+
t0 REAL8 ?
|
65
|
+
fps REAL8 ?
|
66
|
+
ratio REAL8 ?
|
67
|
+
|
68
|
+
temp REAL4 ?
|
69
|
+
|
70
|
+
windowwidth DWORD ?
|
71
|
+
windowheight DWORD ?
|
72
|
+
cursorx DWORD ?
|
73
|
+
cursory DWORD ?
|
74
|
+
frames DWORD ?
|
75
|
+
|
76
|
+
windowtitle BYTE 64 DUP (?)
|
77
|
+
|
78
|
+
|
79
|
+
;#########################################################################
|
80
|
+
;# CODE #
|
81
|
+
;#########################################################################
|
82
|
+
|
83
|
+
.CODE
|
84
|
+
|
85
|
+
start:
|
86
|
+
|
87
|
+
push ebx
|
88
|
+
|
89
|
+
;We init GLFW
|
90
|
+
INVOKE glfwInit
|
91
|
+
|
92
|
+
;We open window
|
93
|
+
INVOKE glfwOpenWindow, 640, 480, 0, 0, 0, 0, 0, 0, GLFW_WINDOW
|
94
|
+
|
95
|
+
;If there is a problem with opening window, get out
|
96
|
+
.IF (!eax)
|
97
|
+
INVOKE glfwTerminate
|
98
|
+
INVOKE ExitProcess, NULL
|
99
|
+
.ENDIF
|
100
|
+
|
101
|
+
;Enabling sticky keys
|
102
|
+
INVOKE glfwEnable, GLFW_STICKY_KEYS
|
103
|
+
|
104
|
+
;we don't want vsync on
|
105
|
+
INVOKE glfwSwapInterval, 0
|
106
|
+
|
107
|
+
;in frames we keep how much frames are rendered
|
108
|
+
and frames, 0
|
109
|
+
|
110
|
+
;get a first "reference" time
|
111
|
+
INVOKE glfwGetTime
|
112
|
+
fstp t0
|
113
|
+
|
114
|
+
;repeat until ESC is pressed or window is closed
|
115
|
+
.REPEAT
|
116
|
+
|
117
|
+
|
118
|
+
INVOKE glfwGetTime
|
119
|
+
fst t ;don't pop we gonna use him again
|
120
|
+
|
121
|
+
;we find how much time had been elapsed
|
122
|
+
fsub t0 ;st(0)=t-t0
|
123
|
+
fld1 ;1, t-t0
|
124
|
+
|
125
|
+
;we test if elapsed time is above or below 1 second
|
126
|
+
fcomip st(0), st(1) ;compare 1 with t-t0 (PPro upward instruction!!!)
|
127
|
+
|
128
|
+
ja @F
|
129
|
+
|
130
|
+
;if elapsed time is above 1 second calculate fps
|
131
|
+
fild frames ;frames, t-t0
|
132
|
+
fdivrp st(1), st(0) ;frames/t-t0
|
133
|
+
fstp fps ;calculate fps
|
134
|
+
|
135
|
+
;convert to string
|
136
|
+
INVOKE FloatToStr, fps, ADDR windowtitle ;float to string
|
137
|
+
INVOKE glfwSetWindowTitle, ADDR windowtitle
|
138
|
+
|
139
|
+
;update t0, or t is now new "reference" time and reset frames
|
140
|
+
mov eax, DWORD PTR [t] ;using integer move instead FPU move
|
141
|
+
mov ecx, DWORD PTR [t+4]
|
142
|
+
mov DWORD PTR [t0], eax
|
143
|
+
mov DWORD PTR [t0+4], ecx
|
144
|
+
and frames, 0 ;reset frames
|
145
|
+
|
146
|
+
@@:
|
147
|
+
|
148
|
+
fstp st(0) ;free st(0) because st(0)=t-t0
|
149
|
+
inc frames
|
150
|
+
|
151
|
+
;we need mouse position for rotating
|
152
|
+
INVOKE glfwGetMousePos, ADDR cursorx, ADDR cursory
|
153
|
+
|
154
|
+
;we need size of window to setup the viewport and perspective
|
155
|
+
INVOKE glfwGetWindowSize, ADDR windowwidth, ADDR windowheight
|
156
|
+
|
157
|
+
.IF (windowheight==0)
|
158
|
+
mov windowheight, 1 ;avoid divide with zero
|
159
|
+
.ENDIF
|
160
|
+
|
161
|
+
;setting viewport
|
162
|
+
INVOKE glViewport, 0, 0, windowwidth, windowheight
|
163
|
+
|
164
|
+
;clearing color for framebuffer, pure black
|
165
|
+
INVOKE glClearColor, fpc(0), fpc(0), fpc(0), fpc(0)
|
166
|
+
|
167
|
+
;clear framebuffer
|
168
|
+
INVOKE glClear, GL_COLOR_BUFFER_BIT
|
169
|
+
|
170
|
+
;setting up perspective, first we "reset" projection matrix and
|
171
|
+
;then we set the perspective
|
172
|
+
INVOKE glMatrixMode, GL_PROJECTION
|
173
|
+
INVOKE glLoadIdentity
|
174
|
+
|
175
|
+
;calculate ratio (ratio = windowwidth / windowheight)
|
176
|
+
fild windowwidth
|
177
|
+
fild windowheight
|
178
|
+
fdivp st(1), st(0)
|
179
|
+
fstp ratio
|
180
|
+
|
181
|
+
;FOV=65, znear=1, zfar=100
|
182
|
+
INVOKE gluPerspective, fpc(REAL8 65), ratio, fpc(REAL8 1), fpc(REAL8 100)
|
183
|
+
|
184
|
+
;we "reset" the modelview matrix and we place the camera
|
185
|
+
INVOKE glMatrixMode, GL_MODELVIEW
|
186
|
+
INVOKE glLoadIdentity
|
187
|
+
|
188
|
+
INVOKE gluLookAt, fpc(REAL8 0), fpc(REAL8 1), fpc(REAL8 0),\ ;set camera
|
189
|
+
fpc(REAL8 0), fpc(REAL8 20), fpc(REAL8 0),\
|
190
|
+
fpc(REAL8 0), fpc(REAL8 0), fpc(REAL8 1)
|
191
|
+
|
192
|
+
INVOKE glTranslatef, fpc(0), fpc(14), fpc(0)
|
193
|
+
|
194
|
+
;calculate the angle of rotation
|
195
|
+
fild cursorx
|
196
|
+
fmul fpc(0.3) ;0.3*x
|
197
|
+
fld t ;t, 0.3*x
|
198
|
+
fmul fpc(100) ;100*t, 0.3*x
|
199
|
+
faddp st(1), st(0) ;100*t+0.3*x
|
200
|
+
fstp temp
|
201
|
+
|
202
|
+
INVOKE glRotatef, temp, fpc(0), fpc(0), fpc(1)
|
203
|
+
|
204
|
+
;draw a triagle
|
205
|
+
INVOKE glBegin, GL_TRIANGLES
|
206
|
+
INVOKE glColor3f, fpc(1), fpc(0), fpc(0)
|
207
|
+
INVOKE glVertex3f, fpc(-5), fpc(0), fpc(-4)
|
208
|
+
INVOKE glColor3f, fpc(0), fpc(1), fpc(0)
|
209
|
+
INVOKE glVertex3f, fpc(5), fpc(0), fpc(-4)
|
210
|
+
INVOKE glColor3f, fpc(0), fpc(0), fpc(1)
|
211
|
+
INVOKE glVertex3f, fpc(0), fpc(0), fpc(6)
|
212
|
+
INVOKE glEnd
|
213
|
+
|
214
|
+
;swap buffers
|
215
|
+
INVOKE glfwSwapBuffers
|
216
|
+
|
217
|
+
;get state of ESC key
|
218
|
+
INVOKE glfwGetKey, GLFW_KEY_ESC
|
219
|
+
mov ebx, eax
|
220
|
+
|
221
|
+
;get state of window (opened or closed)
|
222
|
+
INVOKE glfwGetWindowParam, GLFW_OPENED
|
223
|
+
|
224
|
+
.UNTIL (ebx) || (!eax) ;if is pressed ESC or window is closed get out
|
225
|
+
|
226
|
+
INVOKE glfwTerminate
|
227
|
+
|
228
|
+
pop ebx
|
229
|
+
|
230
|
+
INVOKE ExitProcess, NULL
|
231
|
+
|
232
|
+
END start
|