diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/base/UMain.pas | 12 | ||||
-rw-r--r-- | src/lua/ULuaGl.pas | 113 | ||||
-rw-r--r-- | src/lua/ULuaTextGL.pas | 63 | ||||
-rw-r--r-- | src/lua/ULuaTexture.pas | 63 | ||||
-rw-r--r-- | src/ultrastardx.dpr | 4 |
5 files changed, 229 insertions, 26 deletions
diff --git a/src/base/UMain.pas b/src/base/UMain.pas index 99127b76..0f9daa6e 100644 --- a/src/base/UMain.pas +++ b/src/base/UMain.pas @@ -182,8 +182,10 @@ uses UGraphicClasses, UPluginDefs, UPlatform, - ULuaLog, ULuaGl, + ULuaLog, + ULuaTexture, + ULuaTextGL, UThemes; @@ -390,8 +392,14 @@ begin Log.LogError('Lua init failed','Lua'); luaL_openlibs(Lua); - luaopen_Log(Lua); // Log + Benchmark (Lua) luaopen_gl(Lua); // gl (Lua) + lua_pop(Lua, 1); // remove table from stack + luaopen_Log(Lua); // Log + Benchmark (Lua) + lua_pop(Lua, 1); // remove table from stack + luaopen_TextGL(Lua); // TextGL (Lua) + lua_pop(Lua, 1); // remove table from stack + luaopen_Texture(Lua); // Texture (Lua) + lua_pop(Lua, 1); // remove table from stack Log.BenchmarkEnd(1); Log.LogBenchmark('Initializing Lua', 1); diff --git a/src/lua/ULuaGl.pas b/src/lua/ULuaGl.pas index 74fa1a9e..cc30aa88 100644 --- a/src/lua/ULuaGl.pas +++ b/src/lua/ULuaGl.pas @@ -49,6 +49,7 @@ function ULuaGl_ClearColor(L: Plua_State): Integer; cdecl; function ULuaGl_Color(L: Plua_State): Integer; cdecl; function ULuaGl_CullFace(L: Plua_State): Integer; cdecl; function ULuaGl_DepthFunc(L: Plua_State): Integer; cdecl; +function ULuaGl_DepthRange(L: Plua_State): Integer; cdecl; function ULuaGl_Disable(L: Plua_State): Integer; cdecl; function ULuaGl_DisableClientState(L: Plua_State): Integer; cdecl; function ULuaGl_DrawBuffer(L: Plua_State): Integer; cdecl; @@ -63,6 +64,7 @@ function ULuaGl_InitNames(L: Plua_State): Integer; cdecl; function ULuaGl_LoadIdentity(L: Plua_State): Integer; cdecl; function ULuaGl_LogicOp(L: Plua_State): Integer; cdecl; function ULuaGl_MatrixMode(L: Plua_State): Integer; cdecl; +function ULuaGl_Ortho(L: Plua_State): Integer; cdecl; function ULuaGl_PopAttrib(L: Plua_State): Integer; cdecl; function ULuaGl_PopClientAttrib(L: Plua_State): Integer; cdecl; function ULuaGl_PopMatrix(L: Plua_State): Integer; cdecl; @@ -71,8 +73,11 @@ function ULuaGl_PushMatrix(L: Plua_State): Integer; cdecl; function ULuaGl_RasterPos(L: Plua_State): Integer; cdecl; function ULuaGl_ReadBuffer(L: Plua_State): Integer; cdecl; function ULuaGl_Rect(L: Plua_State): Integer; cdecl; +function ULuaGl_Rotate(L: Plua_State): Integer; cdecl; +function ULuaGl_Scale(L: Plua_State): Integer; cdecl; function ULuaGl_ShadeModel(L: Plua_State): Integer; cdecl; function ULuaGl_TexCoord(L: Plua_State): Integer; cdecl; +function ULuaGl_Translate(L: Plua_State): Integer; cdecl; function ULuaGl_Vertex(L: Plua_State): Integer; cdecl; function ULuaGl_Viewport(L: Plua_State): Integer; cdecl; @@ -217,6 +222,23 @@ begin result:=0; // number of results end; +function ULuaGl_DepthRange(L: Plua_State): Integer; cdecl; +var + i: Integer; +begin + if lua_istable(L, 1) then + for i := 1 to lua_objlen(L,1) do + lua_rawgeti(L,1,i); + + if (lua_istable(L, 1) and (lua_objlen(L,1) = 2)) + or (lua_gettop(L) = 2) then + glDepthRange(lual_checkinteger(L,-2), + lual_checkinteger(L,-1)) + else + luaL_error(L, 'incorrect argument to function ''gl.DepthRange'''); + result:=0; // number of results +end; + function ULuaGl_Disable(L: Plua_State): Integer; cdecl; var e : GLenum; @@ -350,6 +372,34 @@ begin result:=0; // number of results end; +function ULuaGl_MatrixMode(L: Plua_State): Integer; cdecl; +var + e : GLenum; +begin + e := ULuaGl_StringToEnum(lual_checkstring(L,1)); + + if (e = ULuaGl_EnumERROR) then + luaL_error(L, 'incorrect string argument to function ''gl.MatrixMode'''); + + glMatrixMode(e); + + result:=0; // number of results +end; + +function ULuaGl_Ortho(L: Plua_State): Integer; cdecl; +begin + if (lua_gettop(L) = 6) then + glOrtho(lual_checkinteger(L,-6), + lual_checkinteger(L,-5), + lual_checkinteger(L,-4), + lual_checkinteger(L,-3), + lual_checkinteger(L,-2), + lual_checkinteger(L,-1)) + else + luaL_error(L, 'incorrect argument to function ''gl.Ortho'''); + result:=0; // number of results +end; + function ULuaGl_PopAttrib(L: Plua_State): Integer; cdecl; begin glPopAttrib(); @@ -380,20 +430,6 @@ begin result:=0; // number of results end; -function ULuaGl_MatrixMode(L: Plua_State): Integer; cdecl; -var - e : GLenum; -begin - e := ULuaGl_StringToEnum(lual_checkstring(L,1)); - - if (e = ULuaGl_EnumERROR) then - luaL_error(L, 'incorrect string argument to function ''gl.MatrixMode'''); - - glMatrixMode(e); - - result:=0; // number of results -end; - function ULuaGl_RasterPos(L: Plua_State): Integer; cdecl; var i: Integer; @@ -457,6 +493,29 @@ begin result:=0; // number of results end; +function ULuaGl_Rotate(L: Plua_State): Integer; cdecl; +begin + if (lua_gettop(L) = 3) then + glRotated(lual_checkinteger(L,-4), + lual_checkinteger(L,-3), + lual_checkinteger(L,-2), + lual_checkinteger(L,-1)) + else + luaL_error(L, 'incorrect argument to function ''gl.Rotate'''); + result:=0; // number of results +end; + +function ULuaGl_Scale(L: Plua_State): Integer; cdecl; +begin + if (lua_gettop(L) = 3) then + glScaled(lual_checkinteger(L,-3), + lual_checkinteger(L,-2), + lual_checkinteger(L,-1)) + else + luaL_error(L, 'incorrect argument to function ''gl.Scale'''); + result:=0; // number of results +end; + function ULuaGl_ShadeModel(L: Plua_State): Integer; cdecl; var e : GLenum; @@ -498,6 +557,17 @@ begin result:=0; // number of results end; +function ULuaGl_Translate(L: Plua_State): Integer; cdecl; +begin + if (lua_gettop(L) = 3) then + glTranslated(lual_checkinteger(L,-3), + lual_checkinteger(L,-2), + lual_checkinteger(L,-1)) + else + luaL_error(L, 'incorrect argument to function ''gl.Translate'''); + result:=0; // number of results +end; + function ULuaGl_Vertex(L: Plua_State): Integer; cdecl; var i: Integer; @@ -553,7 +623,7 @@ begin end; const - ULuaGl_Lib_f: array [0..34] of lual_reg = ( + ULuaGl_Lib_f: array [0..39] of lual_reg = ( (name:'Begin';func:ULuaGl_Begin), (name:'BindTexture';func:ULuaGl_BindTexture), (name:'BlendFunc';func:ULuaGl_BlendFunc), @@ -562,6 +632,7 @@ const (name:'Color';func:ULuaGl_Color), (name:'CullFace';func:ULuaGl_CullFace), (name:'DepthFunc';func:ULuaGl_DepthFunc), + (name:'DepthRange';func:ULuaGl_DepthRange), (name:'Disable';func:ULuaGl_Disable), (name:'DisableClientState';func:ULuaGl_DisableClientState), (name:'DrawBuffer';func:ULuaGl_DrawBuffer), @@ -576,6 +647,7 @@ const (name:'LoadIdentity';func:ULuaGl_LoadIdentity), (name:'LogicOp';func:ULuaGl_LogicOp), (name:'MatrixMode';func:ULuaGl_MatrixMode), + (name:'Ortho';func:ULuaGl_Ortho), (name:'PopAttrib';func:ULuaGl_PopAttrib), (name:'PopClientAttrib';func:ULuaGl_PopClientAttrib), (name:'PopMatrix';func:ULuaGl_PopMatrix), @@ -583,9 +655,12 @@ const (name:'PushMatrix';func:ULuaGl_PushMatrix), (name:'RasterPos';func:ULuaGl_RasterPos), (name:'ReadBuffer';func:ULuaGl_ReadBuffer), + (name:'Rotate';func:ULuaGl_Rotate), (name:'Rect';func:ULuaGl_Rect), + (name:'Scale';func:ULuaGl_Scale), (name:'ShadeModel';func:ULuaGl_ShadeModel), (name:'TexCoord';func:ULuaGl_TexCoord), + (name:'Translate';func:ULuaGl_Translate), (name:'Vertex';func:ULuaGl_Vertex), (name:'Viewport';func:ULuaGl_Viewport), (name:nil;func:nil) @@ -622,7 +697,6 @@ end; glDeleteLists: procedure(list: GLuint; range: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} glDeleteTextures: procedure(n: GLsizei; const textures: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} glDepthMask: procedure(flag: GLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} - glDepthRange: procedure(zNear, zFar: GLclampd); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} glDrawArrays: procedure(mode: GLenum; first: GLint; count: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} glDrawElements: procedure(mode: GLenum; count: GLsizei; atype: GLenum; const indices: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} glDrawPixels: procedure(width, height: GLsizei; format, atype: GLenum; const pixels: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} @@ -739,7 +813,6 @@ end; glNormal3s: procedure(nx, ny, nz: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} glNormal3sv: procedure(const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} glNormalPointer: procedure(atype: GLenum; stride: GLsizei; const pointer: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} - glOrtho: procedure(left, right, bottom, top, zNear, zFar: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} glPassThrough: procedure(token: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} glPixelMapfv: procedure(map: GLenum; mapsize: GLsizei; const values: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} glPixelMapuiv: procedure(map: GLenum; mapsize: GLsizei; const values: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} @@ -760,10 +833,6 @@ end; glReadPixels: procedure(x, y: GLint; width, height: GLsizei; format, atype: GLenum; pixels: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} glRenderMode: function(mode: GLint): GLint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} - glRotated: procedure(angle, x, y, z: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} - glRotatef: procedure(angle, x, y, z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} - glScaled: procedure(x, y, z: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} - glScalef: procedure(x, y, z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} glScissor: procedure(x, y: GLint; width, height: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} glSelectBuffer: procedure(size: GLsizei; buffer: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} glStencilFunc: procedure(func: GLenum; ref: GLint; mask: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} @@ -789,8 +858,6 @@ end; glTexParameteriv: procedure(target: GLenum; pname: GLenum; const params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} glTexSubImage1D: procedure(target: GLenum; level, xoffset: GLint; width: GLsizei; format, atype: GLenum; const pixels: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} glTexSubImage2D: procedure(target: GLenum; level, xoffset, yoffset: GLint; width, height: GLsizei; format, atype: GLenum; const pixels: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} - glTranslated: procedure(x, y, z: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} - glTranslatef: procedure(x, y, z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} glVertexPointer: procedure(size: GLint; atype: GLenum; stride: GLsizei; const pointer: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} {$IFDEF WINDOWS} ChoosePixelFormat: function(DC: HDC; p2: PPixelFormatDescriptor): Integer; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} diff --git a/src/lua/ULuaTextGL.pas b/src/lua/ULuaTextGL.pas new file mode 100644 index 00000000..ffc88154 --- /dev/null +++ b/src/lua/ULuaTextGL.pas @@ -0,0 +1,63 @@ +{* UltraStar Deluxe - Karaoke Game + * + * UltraStar Deluxe is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + *} + +unit ULuaTextGL; + +interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +{$I switches.inc} + +uses + SysUtils, + TextGL, + ULua; + +function luaopen_TextGL (L: Plua_State): Integer; cdecl; + +function ULuaTextGL_Dummy(L: Plua_State): Integer; cdecl; + +implementation + +function ULuaTextGL_Dummy(L: Plua_State): Integer; cdecl; +begin + result:=0; // number of results +end; + +const + ULuaTextGL_Lib_f: array [0..1] of lual_reg = ( + (name:'Print';func:ULuaTextGL_Dummy), + (name:nil;func:nil) + ); + +function luaopen_TextGL (L: Plua_State): Integer; cdecl; +begin + luaL_register(L,'TextGL',@ULuaTextGL_Lib_f[0]); + result:=1; +end; +end. diff --git a/src/lua/ULuaTexture.pas b/src/lua/ULuaTexture.pas new file mode 100644 index 00000000..931c0405 --- /dev/null +++ b/src/lua/ULuaTexture.pas @@ -0,0 +1,63 @@ +{* UltraStar Deluxe - Karaoke Game + * + * UltraStar Deluxe is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + *} + +unit ULuaTexture; + +interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +{$I switches.inc} + +uses + SysUtils, + ULua, + UTexture; + +function luaopen_Texture (L: Plua_State): Integer; cdecl; + +function ULuaTexture_Dummy(L: Plua_State): Integer; cdecl; + +implementation + +function ULuaTexture_Dummy(L: Plua_State): Integer; cdecl; +begin + result:=0; // number of results +end; + +const + ULuaTexture_Lib_f: array [0..1] of lual_reg = ( + (name:'Add';func:ULuaTexture_Dummy), + (name:nil;func:nil) + ); + +function luaopen_Texture (L: Plua_State): Integer; cdecl; +begin + luaL_register(L,'Texture',@ULuaTexture_Lib_f[0]); + result:=1; +end; +end. diff --git a/src/ultrastardx.dpr b/src/ultrastardx.dpr index 54dbd58c..c42d8215 100644 --- a/src/ultrastardx.dpr +++ b/src/ultrastardx.dpr @@ -145,8 +145,10 @@ uses //------------------------------ ULua in 'lib\Lua\ULua.pas', - ULuaLog in 'lua\ULuaLog.pas', ULuaGl in 'lua\ULuaGl.pas', + ULuaLog in 'lua\ULuaLog.pas', + ULuaTextGL in 'lua\ULuaTextGL.pas', + ULuaTexture in 'lua\ULuaTexture.pas', //------------------------------ //Includes - Menu System |