Move Doris source to new source/doris directory. This will break everything. Part of cleanup.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/source/doris/Doris.cpp Wed Nov 04 00:45:28 2009 +0000
1.3 @@ -0,0 +1,335 @@
1.4 +
1.5 +/*
1.6 + File : Doris.cpp
1.7 + Purpose: Entry point for the console application.
1.8 +
1.9 + Copyright (c) 2001-2005 Nick Trout
1.10 + This file is part of Doris. (http://doris.sf.net/)
1.11 +
1.12 + Doris is free software; you can redistribute it and/or modify
1.13 + it under the terms of the GNU General Public License as published by
1.14 + the Free Software Foundation; either version 2 of the License, or
1.15 + (at your option) any later version.
1.16 +
1.17 + Doris is distributed in the hope that it will be useful,
1.18 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1.19 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.20 + GNU General Public License for more details.
1.21 +
1.22 + You should have received a copy of the GNU General Public License
1.23 + along with Doris; if not, write to the Free Software
1.24 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1.25 +
1.26 + CVS: $Id$
1.27 +*/
1.28 +
1.29 +#include <stdio.h>
1.30 +#include <string.h>
1.31 +#include <stdlib.h>
1.32 +#ifndef WIN32
1.33 +#include <sys/errno.h>
1.34 +#endif
1.35 +
1.36 +// Note, Lua and toLua are in C.
1.37 +extern "C" {
1.38 +#include "lua.h"
1.39 +#include "lualib.h"
1.40 +#include "tolua++.h"
1.41 +extern int luaopen_pack(lua_State *L);
1.42 +#include "luasocket.h"
1.43 +}
1.44 +
1.45 +#include "dorisbind.h"
1.46 +#include "doriswin.h"
1.47 +#include "dorisnet.h"
1.48 +#include "gluibind.h"
1.49 +#include "glbind.h"
1.50 +#include "glubind.h"
1.51 +#include "glutbind.h"
1.52 +#include "GL/glut.h"
1.53 +#include "jversion.h" // get version information from IJG
1.54 +
1.55 +static const char* DORIS_VERSION = "1.1"; // current binary release version
1.56 +lua_State *luaS = NULL;
1.57 +static void cleanUp();
1.58 +
1.59 +#ifdef _DEBUG
1.60 + // If we include the develop flag then we execute the scripts otherwise we include the compiled code.
1.61 + #define _DEVELOP
1.62 +#endif
1.63 +
1.64 +// The following define controls whether Doris' helper libraries are included in
1.65 +// their luac pre-compiled form.
1.66 +#if !defined(_DEVELOP)
1.67 + #define INCLUDE_LIBS_AS_BIN
1.68 +#endif
1.69 +
1.70 +#ifdef INCLUDE_LIBS_AS_BIN
1.71 + // include the doris libraries as compiled scripts i.e following is function prototype:
1.72 + static void DorisLibs(lua_State *L)
1.73 + // {
1.74 + #include "dorislibsbin.h"
1.75 + // }
1.76 +#endif
1.77 +
1.78 +
1.79 +
1.80 +static void showHelp()
1.81 +{
1.82 + printf( "\nDoris version: %s (Built " __DATE__ ").\n"
1.83 + "Copyright (c) 2001-2005 Nick Trout.\n"
1.84 + "Source code is released under the GNU GPL license.\n"
1.85 + "Homepage: http://doris.sourceforge.net/\n"
1.86 + "\n"
1.87 + "Doris comes with ABSOLUTELY NO WARRANTY; This is free software,\n"
1.88 + "and you are welcome to redistribute it under certain conditions.\n"
1.89 + "For details on warranty and conditions see accompanying file License.txt\n"
1.90 + "or visit the GNU website http://www.gnu.org/licenses/gpl.html\n"
1.91 + "\n", DORIS_VERSION );
1.92 + printf( "Doris uses " LUA_VERSION ", " LUA_COPYRIGHT "\n"
1.93 + "by " LUA_AUTHORS ".\n"
1.94 + "See http://www.lua.org/ and http://www.lua-users.org/\n"
1.95 + "\n" );
1.96 + printf( "GLUI version %.2f. Copyright (c) 1998 Paul Rademacher.\n"
1.97 + "See http://www.cs.unc.edu/~rademach/glui/\n"
1.98 + "\n", GLUI_VERSION );
1.99 + printf( "JPEG support provided by the IJG library (" JVERSION ")\n"
1.100 + JCOPYRIGHT "\n"
1.101 + "\n" );
1.102 + printf( "Network support from " LUASOCKET_VERSION "\n"
1.103 + LUASOCKET_COPYRIGHT "\n"
1.104 + "\n" );
1.105 + printf( "Usage: doris [flags|script]\n"
1.106 + " -h,-? Show this message.\n"
1.107 + " -f name Execute file 'name' with remaining arguments in table 'arg'\n\n"
1.108 + );
1.109 +}
1.110 +
1.111 +// Turn an error enumeration into a string. Values can be found in lua.h
1.112 +//
1.113 +static const char* GetLuaErrorMessage(int iValue)
1.114 +{
1.115 + switch (iValue)
1.116 + {
1.117 + case LUA_ERRRUN:
1.118 + return "Error while running the script.";
1.119 +
1.120 + case LUA_ERRFILE:
1.121 + // (only for lua_dofile). In this case, you may want to check errno,
1.122 + // call strerror, or call perror to tell the user what went wrong. ", 2
1.123 + return"Error opening the file.";
1.124 +
1.125 + case LUA_ERRSYNTAX:
1.126 + return "Syntax error during pre-compilation."; // 3
1.127 +
1.128 + case LUA_ERRMEM:
1.129 + // For such errors, Lua does not call _ERRORMESSAGE (see Section 4.7).", // 4
1.130 + // "Error while running _ERRORMESSAGE. For such errors,\n"
1.131 + return "Memory allocation error.";
1.132 +
1.133 + case LUA_ERRERR:
1.134 + return "Lua does not call _ERRORMESSAGE again, to avoid loops."; // 5
1.135 +
1.136 + default:
1.137 + return "Bad error message.";
1.138 + };
1.139 +}
1.140 +
1.141 +static void noFileError()
1.142 +{
1.143 + fprintf(stderr,"\nError: No script file specified. Doris needs a Lua script to execute.\n"
1.144 + "Usage: doris <script.lua>\n"
1.145 + "Use doris -h to get more help.\n");
1.146 + exit(1);
1.147 +}
1.148 +
1.149 +static int reportError(lua_State *luaS)
1.150 +{
1.151 + const char *errmsg = lua_tostring(luaS,-1);
1.152 + printf("\nError: %s\n", errmsg ? errmsg : "<no message>");
1.153 +
1.154 + lua_getglobal(luaS, "_TRACEBACK");
1.155 + lua_pcall(luaS, 0,0, 0);
1.156 +
1.157 + return 0;
1.158 +}
1.159 +
1.160 +// This is so we can start the window from a script and then return to Lua.
1.161 +//
1.162 +static int LuaGlutMainLoop(lua_State *L)
1.163 +{
1.164 + glutMainLoop();
1.165 + return 0;
1.166 +}
1.167 +
1.168 +int main(int argc, char* argv[])
1.169 +{
1.170 + // see if we just want help or docs
1.171 + bool bArgs = false;
1.172 + char *filename = NULL;
1.173 +
1.174 + if (argc<=1)
1.175 + {
1.176 + noFileError();
1.177 + }
1.178 + else if (argc>1 && (stricmp(argv[1],"-h")==0 || stricmp(argv[1],"-?")==0))
1.179 + {
1.180 + showHelp();
1.181 + exit(0);
1.182 + }
1.183 + else if (argc>=2 && stricmp(argv[1],"-f")==0)
1.184 + {
1.185 + if (argc<3)
1.186 + noFileError();
1.187 + filename = argv[2];
1.188 + bArgs = true;
1.189 + }
1.190 + else
1.191 + {
1.192 + filename = argv[1];
1.193 + }
1.194 +
1.195 +
1.196 + printf("Welcome to Doris %s.\n", DORIS_VERSION);
1.197 + printf("Using " LUA_VERSION ", " LUA_COPYRIGHT "\n\n");
1.198 +
1.199 + #ifdef _DEBUG
1.200 + printf("* DEBUG version\n");
1.201 + #endif
1.202 + #ifdef _DEVELOP
1.203 + printf("* DEVELOP version\n");
1.204 + #endif
1.205 +
1.206 + glutInit(&argc,argv);
1.207 +
1.208 + // create our Lua state and initialise all the relevant libraries we'll need
1.209 + luaS = lua_open();
1.210 +
1.211 + // add Luas base libraries
1.212 + lua_baselibopen(luaS);
1.213 + lua_iolibopen(luaS);
1.214 + lua_strlibopen(luaS);
1.215 + lua_mathlibopen(luaS);
1.216 + lua_dblibopen(luaS);
1.217 + luaopen_table(luaS);
1.218 +
1.219 + // add our bindings
1.220 + tolua_doris_open(luaS);
1.221 + tolua_gl_open(luaS);
1.222 + tolua_glu_open(luaS);
1.223 + tolua_glut_open(luaS);
1.224 + tolua_glui_open(luaS);
1.225 + luaopen_pack(luaS);
1.226 + luaopen_lsocket(luaS);
1.227 +
1.228 + #ifdef INCLUDE_LIBS_AS_BIN
1.229 + DorisLibs(luaS);
1.230 + #endif
1.231 +
1.232 + lua_register(luaS, "glutMainLoop", LuaGlutMainLoop);
1.233 +
1.234 + #ifdef _DEVELOP
1.235 + // define a _DEVELOP flag so we can have development/debug info in Lua code to debug Doris
1.236 + lua_pushnumber(luaS,1);
1.237 + lua_setglobal(luaS,"_DEVELOP");
1.238 +
1.239 + // give the option of changing the script path
1.240 + char *scriptpath = getenv("DORIS_SOURCE");
1.241 + if (!scriptpath)
1.242 + scriptpath = "../src";
1.243 +
1.244 + // include helper wrappers
1.245 + char path[64];
1.246 +
1.247 + sprintf(path, "%s/%s", scriptpath, "dorisgui.lua");
1.248 + lua_dofile(luaS, path);
1.249 +
1.250 + sprintf(path, "%s/%s", scriptpath, "render.lua");
1.251 + lua_dofile(luaS, path);
1.252 +
1.253 + #endif // _DEVELOP
1.254 +
1.255 + lua_register(luaS, "_ALERT", reportError);
1.256 + lua_atpanic(luaS, reportError);
1.257 +
1.258 + // define exit handler as we have to exit() to finish Doris because cant
1.259 + // exit glutMainLoop().
1.260 + // We probably don't need to do this but its nice to tidy up after ourselves.
1.261 + atexit(cleanUp);
1.262 +
1.263 + // include argument list for Lua ?
1.264 + if (bArgs)
1.265 + {
1.266 + // a-la lua.c and standard Lua console - create arg table
1.267 + lua_newtable(luaS);
1.268 + const int startArg = 3;
1.269 + int i;
1.270 + for (i=startArg; i<argc && argv[i]; i++)
1.271 + {
1.272 + lua_pushnumber(luaS, i-startArg+1);
1.273 + lua_pushstring(luaS, argv[i]);
1.274 + lua_settable(luaS, -3);
1.275 + }
1.276 + // don't really need to do this as getn should do
1.277 + lua_pushstring(luaS, "n");
1.278 + lua_pushnumber(luaS, i-startArg);
1.279 + lua_settable(luaS, -3);
1.280 + lua_setglobal(luaS,"arg");
1.281 + }
1.282 +
1.283 + // push on our error handler for the call to the script we are about to run
1.284 + lua_getglobal(luaS, "_ALERT");
1.285 +
1.286 + // Try compiling the script that we have been passed
1.287 + printf("Executing Lua file: %s\n\n",filename);
1.288 + int iRet;
1.289 + if ( (iRet=luaL_loadfile(luaS,filename)) !=0 )
1.290 + {
1.291 + fprintf(stderr,"Problem compiling file (%d) :\n%s\n",iRet, GetLuaErrorMessage(iRet));
1.292 +
1.293 + // Give extra information for this warning
1.294 + if (iRet == LUA_ERRFILE)
1.295 + fprintf(stderr, "Reason for error: %s.\n", strerror(errno));
1.296 +
1.297 + if (iRet == LUA_ERRSYNTAX)
1.298 + reportError(luaS);
1.299 +
1.300 + exit(1); // oops
1.301 + }
1.302 +
1.303 + // No call the script with error handler that we chose
1.304 + iRet = lua_pcall(luaS, 0, 0, -2);
1.305 +
1.306 + if (iRet!=0)
1.307 + {
1.308 + fprintf(stderr,"Problem executing file (%d) :\n%s\n",iRet, GetLuaErrorMessage(iRet));
1.309 + exit(1);
1.310 + }
1.311 +
1.312 + // And off we go - hand over control to GLUT.
1.313 + // If no window is created then we don't need to call GLUT main loop.
1.314 + if (Window::instance())
1.315 + {
1.316 + glutMainLoop();
1.317 + }
1.318 +
1.319 + // we'll never get here if Window is created.
1.320 + return 0;
1.321 +}
1.322 +
1.323 +// Called when we exit the application.
1.324 +static void cleanUp()
1.325 +{
1.326 + //glutReportErrors();
1.327 +
1.328 + // no more close functions? --NDT
1.329 + //tolua_doris_close(luaS);
1.330 + //tolua_glui_close(luaS);
1.331 + //tolua_gl_close(luaS);
1.332 + //tolua_glu_close(luaS);
1.333 + //tolua_glut_close(luaS);
1.334 +
1.335 + lua_close(luaS);
1.336 +}
1.337 +
1.338 +
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/source/doris/doris.pkg Wed Nov 04 00:45:28 2009 +0000
2.3 @@ -0,0 +1,250 @@
2.4 +
2.5 +/*
2.6 + Purpose: Doris toLua packaging.
2.7 +
2.8 + Copyright (c) 2001,2002 Nick Trout
2.9 + This file is part of Doris. (http://doris.sf.net/)
2.10 +
2.11 + Doris is free software; you can redistribute it and/or modify
2.12 + it under the terms of the GNU General Public License as published by
2.13 + the Free Software Foundation; either version 2 of the License, or
2.14 + (at your option) any later version.
2.15 +
2.16 + Doris is distributed in the hope that it will be useful,
2.17 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2.18 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2.19 + GNU General Public License for more details.
2.20 +
2.21 + You should have received a copy of the GNU General Public License
2.22 + along with Doris; if not, write to the Free Software
2.23 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2.24 +
2.25 + CVS: $Id$
2.26 +*/
2.27 +
2.28 +$#include <GL/glut.h>
2.29 +$#include "algebra3.h"
2.30 +$#include "doriswin.h"
2.31 +$#include "dorisobjs.h"
2.32 +$#include "dorisimage.h"
2.33 +
2.34 +// Force toLua to create Matrix type for us.
2.35 +// $typedef float MatrixArray;
2.36 +
2.37 +//typedef void* GLUI_Update_CB;
2.38 +GLUI_Update_CB_t GLUIUpdateCB_t;
2.39 +
2.40 +
2.41 +class Window
2.42 +{
2.43 + Window(char *name);
2.44 + int getHandle();
2.45 + void setCallback(GLUI_Control *p_ctrl);
2.46 +};
2.47 +
2.48 +// Helpers //
2.49 +
2.50 +//! group="Vector",
2.51 +//! about=[[A Vector is a 4D vector.
2.52 +//! This is a wrapper class for the GLUI vec4 vector class.
2.53 +//! We expose this to Lua so we can use Vectors.]]
2.54 +
2.55 +class Vector
2.56 +{
2.57 + //! group="Vector", item="new(x,y,z,w)",
2.58 + //! about=[[Constructor.]],
2.59 + //! params=[[The constructor can accept 0,3 or 4 arguments.
2.60 + //! If passed no arguments it initialises to (0,0,0,1).]],
2.61 + //! eg=[[
2.62 + //! a = Vector:new()
2.63 + //! b = Vector:new(1,2,3)
2.64 + //! a:set(3,2,1)
2.65 + //! b = a+b ]]
2.66 +
2.67 + Vector(void);
2.68 + Vector(float x,float y,float z,float w);
2.69 +
2.70 + //! group="Vector", item="set(x,y,z,w)",
2.71 + //! about=[[Set the scalar elements of the vector.]],
2.72 + //! params=[[twta
2.73 + //! * x,y,z - the x,y and z elements of the vector.
2.74 + //! * w - optional argument, defaults to 1. ]],
2.75 + //! eg=[[
2.76 + //! a = Vector:new()
2.77 + //! a:set(3,2,1) ]]
2.78 +
2.79 + void set(float x,float y,float z,float w=1.f);
2.80 +
2.81 + //! group="Vector", item="+ -",
2.82 + //! about=[[Binary vector addition and subtraction operators.]],
2.83 + //! eg=[[
2.84 + //! a,b = Vector:new(7,8,9), Vector:new(1,2,3)
2.85 + //! a = a+b
2.86 + //! b = a-b ]]
2.87 +
2.88 + //! group="Vector", item="* /",
2.89 + //! about=[[Vector scalar scaling operators.]],
2.90 + //! eg=[[
2.91 + //! a = Vector:new(7,8,9)
2.92 + //! a = a * .5
2.93 + //! a = a / 2 ]]
2.94 +
2.95 + void operator+(Vector& a);
2.96 + void operator-(Vector& a);
2.97 + void operator*(float s);
2.98 + void operator/(float s);
2.99 +
2.100 + //! group="Vector", item="normalise()",
2.101 + //! about=[[Normalise the length of this vector. i.e. make the length one.]],
2.102 + //! eg=[[
2.103 + //! a = Vector:new(7,8,9)
2.104 + //! a:normalise()
2.105 + //! assert( a:length() - 1 < .0001 ) ]]
2.106 +
2.107 + //! group="Vector", item="length()",
2.108 + //! about=[[Return the length of this Vector.]],
2.109 + //! returns=[[The length of the Vector.]],
2.110 + //! eg=[[
2.111 + //! a = Vector:new(7,8,9)
2.112 + //! print( a:length() ) ]]
2.113 +
2.114 + //! group="Vector", item="dot(vec)",
2.115 + //! about=[[Return the dot product of this Vector with the argument vector passed.]],
2.116 + //! params=[[ * vec - The vector to perform the dot product with. ]],
2.117 + //! eg=[[
2.118 + //! a,b = Vector:new(1,2,3),Vector:new(2,3,4)
2.119 + //! print( a:dot(b) ) ]]
2.120 +
2.121 + void normalise();
2.122 + float length();
2.123 + float dot(Vector& a);
2.124 +};
2.125 +
2.126 +//! group="Matrix",
2.127 +//! about=[[Matrix is a 4 by 4 matrix.
2.128 +//! This is a wrapper class for the GLUI mat4 matrix class.
2.129 +//! We expose this to Lua so we can use Matrices.
2.130 +//! The methods tend not to create new matrices as return values. This allows the client
2.131 +//! more control and hopefully should result in the script being faster through less
2.132 +//! objects being created. ]]
2.133 +
2.134 +class Matrix
2.135 +{
2.136 + Matrix(void);
2.137 +
2.138 + //! group="Matrix", item="dump()",
2.139 + //! about=[[Print out the value of the Matrix.]],
2.140 + //! eg=[[
2.141 + //! a = Matrix:new()
2.142 + //! a:dump() ]]
2.143 +
2.144 + //! group="Matrix", item="set(Matrix m)",
2.145 + //! about=[[Set the value of this matrix to the one given. ie. copy.]],
2.146 + //! eg=[[
2.147 + //! a,b = Matrix:new(),Matrix:new()
2.148 + //! a:set(b) ]]
2.149 +
2.150 + float& operator [] (int i);
2.151 + void set(Matrix* m);
2.152 + // MatrixArray* getArray();
2.153 + void dump();
2.154 +
2.155 + //! group="Matrix", item="times(Matrix m), plus(Matrix m), minus(Matrix m)",
2.156 + //! about=[[Matrix multiplication, addition and subtraction.]],
2.157 + //! params=" * m - The matrix to apply the operation with.",
2.158 + //! eg=[[
2.159 + //! a,b = Matrix:new(), Matrix:new() -- create matrices
2.160 + //! a:makeScale(.5,.5,.5) b:makeTranslate(1,2,3) -- set some values
2.161 + //! a:times(b) b:plus(a) a:minus(b) -- examples of usage ]]
2.162 +
2.163 + //! group="Matrix", item="transpose()",
2.164 + //! about=[[Transpose the matrix.]],
2.165 + //! eg=[[
2.166 + //! a = Matrix:new()
2.167 + //! a:makeTranslate(1,2,3)
2.168 + //! a:transpose() ]]
2.169 +
2.170 + //! group="Matrix", item="translateBy(x,y,z)",
2.171 + //! about=[[Translate this matrix by the values given.]],
2.172 + //! params=[[ * x,y,z - translation required in each axis.]],
2.173 + //! eg=[[
2.174 + //! a = Matrix:new()
2.175 + //! a:makeTranslate(1,2,3)
2.176 + //! a:translateBy(-1,-2,-3) -- back to origin ]]
2.177 +
2.178 + void times(Matrix& t);
2.179 + Vector operator * (Vector& a);
2.180 + void plus(Matrix& t);
2.181 + void minus(Matrix& t);
2.182 + void transpose();
2.183 + void translateBy(float x,float y,float z);
2.184 +
2.185 + //! group="Matrix", item="makeIndentity()",
2.186 + //! about=[[Make this matrix an identity transform. ie. its does nothing.]],
2.187 + //! eg=[[
2.188 + //! a = Matrix:new()
2.189 + //! a:makeIdentity() ]]
2.190 +
2.191 + //! group="Matrix", item="makeInverse()",
2.192 + //! about=[[Make this matrix the inverse of itself.]],
2.193 + //! eg=[[
2.194 + //! a,b = Matrix:new(),Matrix:new()
2.195 + //! a:makeScale(1,2,3)
2.196 + //! b:set(a)
2.197 + //! b:makeInverse() -- b is the inverse of a ]]
2.198 +
2.199 + //! group="Matrix", item="makeScale(x,y,z)",
2.200 + //! about=[[Create a scaling matrix.]],
2.201 + //! params=" * x,y,z - The scale in each axis required.",
2.202 + //! eg=[[
2.203 + //! a = Matrix:new()
2.204 + //! a:makeScale(1,2,3) ]]
2.205 +
2.206 + //! group="Matrix", item="makeTranslate(x,y,z)",
2.207 + //! about=[[Create a translation matrix.]],
2.208 + //! params=" * x,y,z - The translation in each axis required.",
2.209 + //! eg=[[
2.210 + //! a = Matrix:new()
2.211 + //! a:makeTranslation(1,2,3) ]]
2.212 +
2.213 + void makeIdentity();
2.214 + void makeInverse();
2.215 + void makeScale(float x,float y,float z);
2.216 + void makeTranslate(float x,float y,float z);
2.217 +};
2.218 +
2.219 +// Work around for enums in classes. toLua struggles with this.
2.220 +// $#define ImageType Image::ImageType
2.221 +
2.222 +class Image
2.223 +{
2.224 + enum ImageType {
2.225 + ImageUndefined,
2.226 + ImageRGB,
2.227 + ImageRGBA,
2.228 + ImageGrayscale
2.229 + };
2.230 +
2.231 + Image();
2.232 + ~Image();
2.233 +
2.234 + bool load(char *filename);
2.235 + void unload();
2.236 +
2.237 + int getAlphaBits();
2.238 + GLLbuffer* getPixels();
2.239 + int getHeight();
2.240 + int getWidth();
2.241 + int getPixelDepth();
2.242 + ImageType getImageType();
2.243 +
2.244 + void greyscale();
2.245 + void convertToNormalMap();
2.246 + void scaleDownNormalMap();
2.247 + void smooth();
2.248 +};
2.249 +
2.250 +
2.251 +
2.252 +
2.253 +
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/source/doris/dorisbind.cpp Wed Nov 04 00:45:28 2009 +0000
3.3 @@ -0,0 +1,1596 @@
3.4 +/*
3.5 +** Lua binding: doris
3.6 +** Generated automatically by tolua++-1.0.6 on 10/17/05 18:37:05.
3.7 +*/
3.8 +
3.9 +#ifndef __cplusplus
3.10 +#include "stdlib.h"
3.11 +#endif
3.12 +#include "string.h"
3.13 +
3.14 +#include "tolua++.h"
3.15 +
3.16 +/* Exported function */
3.17 +TOLUA_API int tolua_doris_open (lua_State* tolua_S);
3.18 +
3.19 +#include <GL/glut.h>
3.20 +#include "algebra3.h"
3.21 +#include "doriswin.h"
3.22 +#include "dorisobjs.h"
3.23 +#include "dorisimage.h"
3.24 +
3.25 +/* function to release collected object via destructor */
3.26 +#ifdef __cplusplus
3.27 +
3.28 +static int tolua_collect_Matrix (lua_State* tolua_S)
3.29 +{
3.30 + Matrix* self = (Matrix*) tolua_tousertype(tolua_S,1,0);
3.31 + delete self;
3.32 + return 0;
3.33 +}
3.34 +
3.35 +static int tolua_collect_Vector (lua_State* tolua_S)
3.36 +{
3.37 + Vector* self = (Vector*) tolua_tousertype(tolua_S,1,0);
3.38 + delete self;
3.39 + return 0;
3.40 +}
3.41 +
3.42 +static int tolua_collect_Window (lua_State* tolua_S)
3.43 +{
3.44 + Window* self = (Window*) tolua_tousertype(tolua_S,1,0);
3.45 + delete self;
3.46 + return 0;
3.47 +}
3.48 +
3.49 +static int tolua_collect_Image (lua_State* tolua_S)
3.50 +{
3.51 + Image* self = (Image*) tolua_tousertype(tolua_S,1,0);
3.52 + delete self;
3.53 + return 0;
3.54 +}
3.55 +#endif
3.56 +
3.57 +
3.58 +/* function to register type */
3.59 +static void tolua_reg_types (lua_State* tolua_S)
3.60 +{
3.61 + tolua_usertype(tolua_S,"GLUI_Update_CB");
3.62 + tolua_usertype(tolua_S,"Matrix");
3.63 + tolua_usertype(tolua_S,"Vector");
3.64 + tolua_usertype(tolua_S,"GLLbuffer");
3.65 + tolua_usertype(tolua_S,"Window");
3.66 + tolua_usertype(tolua_S,"Image");
3.67 + tolua_usertype(tolua_S,"GLUI_Control");
3.68 +}
3.69 +
3.70 +/* get function: GLUIUpdateCB */
3.71 +static int tolua_get_GLUIUpdateCB(lua_State* tolua_S)
3.72 +{
3.73 + tolua_pushusertype(tolua_S,(void*)&GLUIUpdateCB,"GLUI_Update_CB");
3.74 + return 1;
3.75 +}
3.76 +
3.77 +/* set function: GLUIUpdateCB */
3.78 +static int tolua_set_GLUIUpdateCB(lua_State* tolua_S)
3.79 +{
3.80 +#ifndef TOLUA_RELEASE
3.81 + tolua_Error tolua_err;
3.82 + if (!tolua_isusertype(tolua_S,2,"GLUI_Update_CB",0,&tolua_err))
3.83 + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
3.84 +#endif
3.85 + GLUIUpdateCB = *((GLUI_Update_CB*) tolua_tousertype(tolua_S,2,0))
3.86 +;
3.87 + return 0;
3.88 +}
3.89 +
3.90 +/* method: new of class Window */
3.91 +static int tolua_doris_Window_new00(lua_State* tolua_S)
3.92 +{
3.93 +#ifndef TOLUA_RELEASE
3.94 + tolua_Error tolua_err;
3.95 + if (
3.96 + !tolua_isusertable(tolua_S,1,"Window",0,&tolua_err) ||
3.97 + !tolua_isstring(tolua_S,2,0,&tolua_err) ||
3.98 + !tolua_isnoobj(tolua_S,3,&tolua_err)
3.99 + )
3.100 + goto tolua_lerror;
3.101 + else
3.102 +#endif
3.103 + {
3.104 + char* name = ((char*) tolua_tostring(tolua_S,2,0));
3.105 + {
3.106 + Window* tolua_ret = (Window*) new Window(name);
3.107 + tolua_pushusertype(tolua_S,(void*)tolua_ret,"Window");
3.108 + }
3.109 + }
3.110 + return 1;
3.111 +#ifndef TOLUA_RELEASE
3.112 + tolua_lerror:
3.113 + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
3.114 + return 0;
3.115 +#endif
3.116 +}
3.117 +
3.118 +/* method: new_local of class Window */
3.119 +static int tolua_doris_Window_new00_local(lua_State* tolua_S)
3.120 +{
3.121 +#ifndef TOLUA_RELEASE
3.122 + tolua_Error tolua_err;
3.123 + if (
3.124 + !tolua_isusertable(tolua_S,1,"Window",0,&tolua_err) ||
3.125 + !tolua_isstring(tolua_S,2,0,&tolua_err) ||
3.126 + !tolua_isnoobj(tolua_S,3,&tolua_err)
3.127 + )
3.128 + goto tolua_lerror;
3.129 + else
3.130 +#endif
3.131 + {
3.132 + char* name = ((char*) tolua_tostring(tolua_S,2,0));
3.133 + {
3.134 + Window* tolua_ret = (Window*) new Window(name);
3.135 + tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"Window");
3.136 + }
3.137 + }
3.138 + return 1;
3.139 +#ifndef TOLUA_RELEASE
3.140 + tolua_lerror:
3.141 + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
3.142 + return 0;
3.143 +#endif
3.144 +}
3.145 +
3.146 +/* method: getHandle of class Window */
3.147 +static int tolua_doris_Window_getHandle00(lua_State* tolua_S)
3.148 +{
3.149 +#ifndef TOLUA_RELEASE
3.150 + tolua_Error tolua_err;
3.151 + if (
3.152 + !tolua_isusertype(tolua_S,1,"Window",0,&tolua_err) ||
3.153 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.154 + )
3.155 + goto tolua_lerror;
3.156 + else
3.157 +#endif
3.158 + {
3.159 + Window* self = (Window*) tolua_tousertype(tolua_S,1,0);
3.160 +#ifndef TOLUA_RELEASE
3.161 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHandle'",NULL);
3.162 +#endif
3.163 + {
3.164 + int tolua_ret = (int) self->getHandle();
3.165 + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
3.166 + }
3.167 + }
3.168 + return 1;
3.169 +#ifndef TOLUA_RELEASE
3.170 + tolua_lerror:
3.171 + tolua_error(tolua_S,"#ferror in function 'getHandle'.",&tolua_err);
3.172 + return 0;
3.173 +#endif
3.174 +}
3.175 +
3.176 +/* method: setCallback of class Window */
3.177 +static int tolua_doris_Window_setCallback00(lua_State* tolua_S)
3.178 +{
3.179 +#ifndef TOLUA_RELEASE
3.180 + tolua_Error tolua_err;
3.181 + if (
3.182 + !tolua_isusertype(tolua_S,1,"Window",0,&tolua_err) ||
3.183 + !tolua_isusertype(tolua_S,2,"GLUI_Control",0,&tolua_err) ||
3.184 + !tolua_isnoobj(tolua_S,3,&tolua_err)
3.185 + )
3.186 + goto tolua_lerror;
3.187 + else
3.188 +#endif
3.189 + {
3.190 + Window* self = (Window*) tolua_tousertype(tolua_S,1,0);
3.191 + GLUI_Control* p_ctrl = ((GLUI_Control*) tolua_tousertype(tolua_S,2,0));
3.192 +#ifndef TOLUA_RELEASE
3.193 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setCallback'",NULL);
3.194 +#endif
3.195 + {
3.196 + self->setCallback(p_ctrl);
3.197 + }
3.198 + }
3.199 + return 0;
3.200 +#ifndef TOLUA_RELEASE
3.201 + tolua_lerror:
3.202 + tolua_error(tolua_S,"#ferror in function 'setCallback'.",&tolua_err);
3.203 + return 0;
3.204 +#endif
3.205 +}
3.206 +
3.207 +/* method: new of class Vector */
3.208 +static int tolua_doris_Vector_new00(lua_State* tolua_S)
3.209 +{
3.210 +#ifndef TOLUA_RELEASE
3.211 + tolua_Error tolua_err;
3.212 + if (
3.213 + !tolua_isusertable(tolua_S,1,"Vector",0,&tolua_err) ||
3.214 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.215 + )
3.216 + goto tolua_lerror;
3.217 + else
3.218 +#endif
3.219 + {
3.220 + {
3.221 + Vector* tolua_ret = (Vector*) new Vector();
3.222 + tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector");
3.223 + }
3.224 + }
3.225 + return 1;
3.226 +#ifndef TOLUA_RELEASE
3.227 + tolua_lerror:
3.228 + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
3.229 + return 0;
3.230 +#endif
3.231 +}
3.232 +
3.233 +/* method: new_local of class Vector */
3.234 +static int tolua_doris_Vector_new00_local(lua_State* tolua_S)
3.235 +{
3.236 +#ifndef TOLUA_RELEASE
3.237 + tolua_Error tolua_err;
3.238 + if (
3.239 + !tolua_isusertable(tolua_S,1,"Vector",0,&tolua_err) ||
3.240 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.241 + )
3.242 + goto tolua_lerror;
3.243 + else
3.244 +#endif
3.245 + {
3.246 + {
3.247 + Vector* tolua_ret = (Vector*) new Vector();
3.248 + tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"Vector");
3.249 + }
3.250 + }
3.251 + return 1;
3.252 +#ifndef TOLUA_RELEASE
3.253 + tolua_lerror:
3.254 + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
3.255 + return 0;
3.256 +#endif
3.257 +}
3.258 +
3.259 +/* method: new of class Vector */
3.260 +static int tolua_doris_Vector_new01(lua_State* tolua_S)
3.261 +{
3.262 + tolua_Error tolua_err;
3.263 + if (
3.264 + !tolua_isusertable(tolua_S,1,"Vector",0,&tolua_err) ||
3.265 + !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
3.266 + !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
3.267 + !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
3.268 + !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
3.269 + !tolua_isnoobj(tolua_S,6,&tolua_err)
3.270 + )
3.271 + goto tolua_lerror;
3.272 + else
3.273 + {
3.274 + float x = ((float) tolua_tonumber(tolua_S,2,0));
3.275 + float y = ((float) tolua_tonumber(tolua_S,3,0));
3.276 + float z = ((float) tolua_tonumber(tolua_S,4,0));
3.277 + float w = ((float) tolua_tonumber(tolua_S,5,0));
3.278 + {
3.279 + Vector* tolua_ret = (Vector*) new Vector(x,y,z,w);
3.280 + tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector");
3.281 + }
3.282 + }
3.283 + return 1;
3.284 +tolua_lerror:
3.285 + return tolua_doris_Vector_new00(tolua_S);
3.286 +}
3.287 +
3.288 +/* method: new_local of class Vector */
3.289 +static int tolua_doris_Vector_new01_local(lua_State* tolua_S)
3.290 +{
3.291 + tolua_Error tolua_err;
3.292 + if (
3.293 + !tolua_isusertable(tolua_S,1,"Vector",0,&tolua_err) ||
3.294 + !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
3.295 + !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
3.296 + !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
3.297 + !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
3.298 + !tolua_isnoobj(tolua_S,6,&tolua_err)
3.299 + )
3.300 + goto tolua_lerror;
3.301 + else
3.302 + {
3.303 + float x = ((float) tolua_tonumber(tolua_S,2,0));
3.304 + float y = ((float) tolua_tonumber(tolua_S,3,0));
3.305 + float z = ((float) tolua_tonumber(tolua_S,4,0));
3.306 + float w = ((float) tolua_tonumber(tolua_S,5,0));
3.307 + {
3.308 + Vector* tolua_ret = (Vector*) new Vector(x,y,z,w);
3.309 + tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"Vector");
3.310 + }
3.311 + }
3.312 + return 1;
3.313 +tolua_lerror:
3.314 + return tolua_doris_Vector_new00_local(tolua_S);
3.315 +}
3.316 +
3.317 +/* method: set of class Vector */
3.318 +static int tolua_doris_Vector_set00(lua_State* tolua_S)
3.319 +{
3.320 +#ifndef TOLUA_RELEASE
3.321 + tolua_Error tolua_err;
3.322 + if (
3.323 + !tolua_isusertype(tolua_S,1,"Vector",0,&tolua_err) ||
3.324 + !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
3.325 + !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
3.326 + !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
3.327 + !tolua_isnumber(tolua_S,5,1,&tolua_err) ||
3.328 + !tolua_isnoobj(tolua_S,6,&tolua_err)
3.329 + )
3.330 + goto tolua_lerror;
3.331 + else
3.332 +#endif
3.333 + {
3.334 + Vector* self = (Vector*) tolua_tousertype(tolua_S,1,0);
3.335 + float x = ((float) tolua_tonumber(tolua_S,2,0));
3.336 + float y = ((float) tolua_tonumber(tolua_S,3,0));
3.337 + float z = ((float) tolua_tonumber(tolua_S,4,0));
3.338 + float w = ((float) tolua_tonumber(tolua_S,5,1.f));
3.339 +#ifndef TOLUA_RELEASE
3.340 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'set'",NULL);
3.341 +#endif
3.342 + {
3.343 + self->set(x,y,z,w);
3.344 + }
3.345 + }
3.346 + return 0;
3.347 +#ifndef TOLUA_RELEASE
3.348 + tolua_lerror:
3.349 + tolua_error(tolua_S,"#ferror in function 'set'.",&tolua_err);
3.350 + return 0;
3.351 +#endif
3.352 +}
3.353 +
3.354 +/* method: operator+ of class Vector */
3.355 +static int tolua_doris_Vector__add00(lua_State* tolua_S)
3.356 +{
3.357 +#ifndef TOLUA_RELEASE
3.358 + tolua_Error tolua_err;
3.359 + if (
3.360 + !tolua_isusertype(tolua_S,1,"Vector",0,&tolua_err) ||
3.361 + !tolua_isusertype(tolua_S,2,"Vector",0,&tolua_err) ||
3.362 + !tolua_isnoobj(tolua_S,3,&tolua_err)
3.363 + )
3.364 + goto tolua_lerror;
3.365 + else
3.366 +#endif
3.367 + {
3.368 + Vector* self = (Vector*) tolua_tousertype(tolua_S,1,0);
3.369 + Vector* a = ((Vector*) tolua_tousertype(tolua_S,2,0));
3.370 +#ifndef TOLUA_RELEASE
3.371 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'",NULL);
3.372 +#endif
3.373 + {
3.374 + self->operator+(*a);
3.375 + }
3.376 + }
3.377 + return 0;
3.378 +#ifndef TOLUA_RELEASE
3.379 + tolua_lerror:
3.380 + tolua_error(tolua_S,"#ferror in function '.add'.",&tolua_err);
3.381 + return 0;
3.382 +#endif
3.383 +}
3.384 +
3.385 +/* method: operator- of class Vector */
3.386 +static int tolua_doris_Vector__sub00(lua_State* tolua_S)
3.387 +{
3.388 +#ifndef TOLUA_RELEASE
3.389 + tolua_Error tolua_err;
3.390 + if (
3.391 + !tolua_isusertype(tolua_S,1,"Vector",0,&tolua_err) ||
3.392 + !tolua_isusertype(tolua_S,2,"Vector",0,&tolua_err) ||
3.393 + !tolua_isnoobj(tolua_S,3,&tolua_err)
3.394 + )
3.395 + goto tolua_lerror;
3.396 + else
3.397 +#endif
3.398 + {
3.399 + Vector* self = (Vector*) tolua_tousertype(tolua_S,1,0);
3.400 + Vector* a = ((Vector*) tolua_tousertype(tolua_S,2,0));
3.401 +#ifndef TOLUA_RELEASE
3.402 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'",NULL);
3.403 +#endif
3.404 + {
3.405 + self->operator-(*a);
3.406 + }
3.407 + }
3.408 + return 0;
3.409 +#ifndef TOLUA_RELEASE
3.410 + tolua_lerror:
3.411 + tolua_error(tolua_S,"#ferror in function '.sub'.",&tolua_err);
3.412 + return 0;
3.413 +#endif
3.414 +}
3.415 +
3.416 +/* method: operator* of class Vector */
3.417 +static int tolua_doris_Vector__mul00(lua_State* tolua_S)
3.418 +{
3.419 +#ifndef TOLUA_RELEASE
3.420 + tolua_Error tolua_err;
3.421 + if (
3.422 + !tolua_isusertype(tolua_S,1,"Vector",0,&tolua_err) ||
3.423 + !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
3.424 + !tolua_isnoobj(tolua_S,3,&tolua_err)
3.425 + )
3.426 + goto tolua_lerror;
3.427 + else
3.428 +#endif
3.429 + {
3.430 + Vector* self = (Vector*) tolua_tousertype(tolua_S,1,0);
3.431 + float s = ((float) tolua_tonumber(tolua_S,2,0));
3.432 +#ifndef TOLUA_RELEASE
3.433 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'",NULL);
3.434 +#endif
3.435 + {
3.436 + self->operator*(s);
3.437 + }
3.438 + }
3.439 + return 0;
3.440 +#ifndef TOLUA_RELEASE
3.441 + tolua_lerror:
3.442 + tolua_error(tolua_S,"#ferror in function '.mul'.",&tolua_err);
3.443 + return 0;
3.444 +#endif
3.445 +}
3.446 +
3.447 +/* method: operator/ of class Vector */
3.448 +static int tolua_doris_Vector__div00(lua_State* tolua_S)
3.449 +{
3.450 +#ifndef TOLUA_RELEASE
3.451 + tolua_Error tolua_err;
3.452 + if (
3.453 + !tolua_isusertype(tolua_S,1,"Vector",0,&tolua_err) ||
3.454 + !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
3.455 + !tolua_isnoobj(tolua_S,3,&tolua_err)
3.456 + )
3.457 + goto tolua_lerror;
3.458 + else
3.459 +#endif
3.460 + {
3.461 + Vector* self = (Vector*) tolua_tousertype(tolua_S,1,0);
3.462 + float s = ((float) tolua_tonumber(tolua_S,2,0));
3.463 +#ifndef TOLUA_RELEASE
3.464 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator/'",NULL);
3.465 +#endif
3.466 + {
3.467 + self->operator/(s);
3.468 + }
3.469 + }
3.470 + return 0;
3.471 +#ifndef TOLUA_RELEASE
3.472 + tolua_lerror:
3.473 + tolua_error(tolua_S,"#ferror in function '.div'.",&tolua_err);
3.474 + return 0;
3.475 +#endif
3.476 +}
3.477 +
3.478 +/* method: normalise of class Vector */
3.479 +static int tolua_doris_Vector_normalise00(lua_State* tolua_S)
3.480 +{
3.481 +#ifndef TOLUA_RELEASE
3.482 + tolua_Error tolua_err;
3.483 + if (
3.484 + !tolua_isusertype(tolua_S,1,"Vector",0,&tolua_err) ||
3.485 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.486 + )
3.487 + goto tolua_lerror;
3.488 + else
3.489 +#endif
3.490 + {
3.491 + Vector* self = (Vector*) tolua_tousertype(tolua_S,1,0);
3.492 +#ifndef TOLUA_RELEASE
3.493 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'normalise'",NULL);
3.494 +#endif
3.495 + {
3.496 + self->normalise();
3.497 + }
3.498 + }
3.499 + return 0;
3.500 +#ifndef TOLUA_RELEASE
3.501 + tolua_lerror:
3.502 + tolua_error(tolua_S,"#ferror in function 'normalise'.",&tolua_err);
3.503 + return 0;
3.504 +#endif
3.505 +}
3.506 +
3.507 +/* method: length of class Vector */
3.508 +static int tolua_doris_Vector_length00(lua_State* tolua_S)
3.509 +{
3.510 +#ifndef TOLUA_RELEASE
3.511 + tolua_Error tolua_err;
3.512 + if (
3.513 + !tolua_isusertype(tolua_S,1,"Vector",0,&tolua_err) ||
3.514 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.515 + )
3.516 + goto tolua_lerror;
3.517 + else
3.518 +#endif
3.519 + {
3.520 + Vector* self = (Vector*) tolua_tousertype(tolua_S,1,0);
3.521 +#ifndef TOLUA_RELEASE
3.522 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'length'",NULL);
3.523 +#endif
3.524 + {
3.525 + float tolua_ret = (float) self->length();
3.526 + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
3.527 + }
3.528 + }
3.529 + return 1;
3.530 +#ifndef TOLUA_RELEASE
3.531 + tolua_lerror:
3.532 + tolua_error(tolua_S,"#ferror in function 'length'.",&tolua_err);
3.533 + return 0;
3.534 +#endif
3.535 +}
3.536 +
3.537 +/* method: dot of class Vector */
3.538 +static int tolua_doris_Vector_dot00(lua_State* tolua_S)
3.539 +{
3.540 +#ifndef TOLUA_RELEASE
3.541 + tolua_Error tolua_err;
3.542 + if (
3.543 + !tolua_isusertype(tolua_S,1,"Vector",0,&tolua_err) ||
3.544 + !tolua_isusertype(tolua_S,2,"Vector",0,&tolua_err) ||
3.545 + !tolua_isnoobj(tolua_S,3,&tolua_err)
3.546 + )
3.547 + goto tolua_lerror;
3.548 + else
3.549 +#endif
3.550 + {
3.551 + Vector* self = (Vector*) tolua_tousertype(tolua_S,1,0);
3.552 + Vector* a = ((Vector*) tolua_tousertype(tolua_S,2,0));
3.553 +#ifndef TOLUA_RELEASE
3.554 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'dot'",NULL);
3.555 +#endif
3.556 + {
3.557 + float tolua_ret = (float) self->dot(*a);
3.558 + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
3.559 + }
3.560 + }
3.561 + return 1;
3.562 +#ifndef TOLUA_RELEASE
3.563 + tolua_lerror:
3.564 + tolua_error(tolua_S,"#ferror in function 'dot'.",&tolua_err);
3.565 + return 0;
3.566 +#endif
3.567 +}
3.568 +
3.569 +/* method: new of class Matrix */
3.570 +static int tolua_doris_Matrix_new00(lua_State* tolua_S)
3.571 +{
3.572 +#ifndef TOLUA_RELEASE
3.573 + tolua_Error tolua_err;
3.574 + if (
3.575 + !tolua_isusertable(tolua_S,1,"Matrix",0,&tolua_err) ||
3.576 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.577 + )
3.578 + goto tolua_lerror;
3.579 + else
3.580 +#endif
3.581 + {
3.582 + {
3.583 + Matrix* tolua_ret = (Matrix*) new Matrix();
3.584 + tolua_pushusertype(tolua_S,(void*)tolua_ret,"Matrix");
3.585 + }
3.586 + }
3.587 + return 1;
3.588 +#ifndef TOLUA_RELEASE
3.589 + tolua_lerror:
3.590 + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
3.591 + return 0;
3.592 +#endif
3.593 +}
3.594 +
3.595 +/* method: new_local of class Matrix */
3.596 +static int tolua_doris_Matrix_new00_local(lua_State* tolua_S)
3.597 +{
3.598 +#ifndef TOLUA_RELEASE
3.599 + tolua_Error tolua_err;
3.600 + if (
3.601 + !tolua_isusertable(tolua_S,1,"Matrix",0,&tolua_err) ||
3.602 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.603 + )
3.604 + goto tolua_lerror;
3.605 + else
3.606 +#endif
3.607 + {
3.608 + {
3.609 + Matrix* tolua_ret = (Matrix*) new Matrix();
3.610 + tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"Matrix");
3.611 + }
3.612 + }
3.613 + return 1;
3.614 +#ifndef TOLUA_RELEASE
3.615 + tolua_lerror:
3.616 + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
3.617 + return 0;
3.618 +#endif
3.619 +}
3.620 +
3.621 +/* method: operator&[] of class Matrix */
3.622 +static int tolua_doris_Matrix__seti00(lua_State* tolua_S)
3.623 +{
3.624 +#ifndef TOLUA_RELEASE
3.625 + tolua_Error tolua_err;
3.626 + if (
3.627 + !tolua_isusertype(tolua_S,1,"Matrix",0,&tolua_err) ||
3.628 + !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
3.629 + !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
3.630 + !tolua_isnoobj(tolua_S,4,&tolua_err)
3.631 + )
3.632 + goto tolua_lerror;
3.633 + else
3.634 +#endif
3.635 + {
3.636 + Matrix* self = (Matrix*) tolua_tousertype(tolua_S,1,0);
3.637 + int i = ((int) tolua_tonumber(tolua_S,2,0));
3.638 + float tolua_value = ((float) tolua_tonumber(tolua_S,3,0));
3.639 +#ifndef TOLUA_RELEASE
3.640 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator&[]'",NULL);
3.641 +#endif
3.642 + self->operator[](i) = tolua_value;
3.643 + }
3.644 + return 0;
3.645 +#ifndef TOLUA_RELEASE
3.646 + tolua_lerror:
3.647 + tolua_error(tolua_S,"#ferror in function '.seti'.",&tolua_err);
3.648 + return 0;
3.649 +#endif
3.650 +}
3.651 +
3.652 +/* method: operator[] of class Matrix */
3.653 +static int tolua_doris_Matrix__geti00(lua_State* tolua_S)
3.654 +{
3.655 +#ifndef TOLUA_RELEASE
3.656 + tolua_Error tolua_err;
3.657 + if (
3.658 + !tolua_isusertype(tolua_S,1,"Matrix",0,&tolua_err) ||
3.659 + !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
3.660 + !tolua_isnoobj(tolua_S,3,&tolua_err)
3.661 + )
3.662 + goto tolua_lerror;
3.663 + else
3.664 +#endif
3.665 + {
3.666 + Matrix* self = (Matrix*) tolua_tousertype(tolua_S,1,0);
3.667 + int i = ((int) tolua_tonumber(tolua_S,2,0));
3.668 +#ifndef TOLUA_RELEASE
3.669 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator[]'",NULL);
3.670 +#endif
3.671 + {
3.672 + float tolua_ret = (float) self->operator[](i);
3.673 + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
3.674 + }
3.675 + }
3.676 + return 1;
3.677 +#ifndef TOLUA_RELEASE
3.678 + tolua_lerror:
3.679 + tolua_error(tolua_S,"#ferror in function '.geti'.",&tolua_err);
3.680 + return 0;
3.681 +#endif
3.682 +}
3.683 +
3.684 +/* method: set of class Matrix */
3.685 +static int tolua_doris_Matrix_set00(lua_State* tolua_S)
3.686 +{
3.687 +#ifndef TOLUA_RELEASE
3.688 + tolua_Error tolua_err;
3.689 + if (
3.690 + !tolua_isusertype(tolua_S,1,"Matrix",0,&tolua_err) ||
3.691 + !tolua_isusertype(tolua_S,2,"Matrix",0,&tolua_err) ||
3.692 + !tolua_isnoobj(tolua_S,3,&tolua_err)
3.693 + )
3.694 + goto tolua_lerror;
3.695 + else
3.696 +#endif
3.697 + {
3.698 + Matrix* self = (Matrix*) tolua_tousertype(tolua_S,1,0);
3.699 + Matrix* m = ((Matrix*) tolua_tousertype(tolua_S,2,0));
3.700 +#ifndef TOLUA_RELEASE
3.701 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'set'",NULL);
3.702 +#endif
3.703 + {
3.704 + self->set(m);
3.705 + }
3.706 + }
3.707 + return 0;
3.708 +#ifndef TOLUA_RELEASE
3.709 + tolua_lerror:
3.710 + tolua_error(tolua_S,"#ferror in function 'set'.",&tolua_err);
3.711 + return 0;
3.712 +#endif
3.713 +}
3.714 +
3.715 +/* method: dump of class Matrix */
3.716 +static int tolua_doris_Matrix_dump00(lua_State* tolua_S)
3.717 +{
3.718 +#ifndef TOLUA_RELEASE
3.719 + tolua_Error tolua_err;
3.720 + if (
3.721 + !tolua_isusertype(tolua_S,1,"Matrix",0,&tolua_err) ||
3.722 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.723 + )
3.724 + goto tolua_lerror;
3.725 + else
3.726 +#endif
3.727 + {
3.728 + Matrix* self = (Matrix*) tolua_tousertype(tolua_S,1,0);
3.729 +#ifndef TOLUA_RELEASE
3.730 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'dump'",NULL);
3.731 +#endif
3.732 + {
3.733 + self->dump();
3.734 + }
3.735 + }
3.736 + return 0;
3.737 +#ifndef TOLUA_RELEASE
3.738 + tolua_lerror:
3.739 + tolua_error(tolua_S,"#ferror in function 'dump'.",&tolua_err);
3.740 + return 0;
3.741 +#endif
3.742 +}
3.743 +
3.744 +/* method: times of class Matrix */
3.745 +static int tolua_doris_Matrix_times00(lua_State* tolua_S)
3.746 +{
3.747 +#ifndef TOLUA_RELEASE
3.748 + tolua_Error tolua_err;
3.749 + if (
3.750 + !tolua_isusertype(tolua_S,1,"Matrix",0,&tolua_err) ||
3.751 + !tolua_isusertype(tolua_S,2,"Matrix",0,&tolua_err) ||
3.752 + !tolua_isnoobj(tolua_S,3,&tolua_err)
3.753 + )
3.754 + goto tolua_lerror;
3.755 + else
3.756 +#endif
3.757 + {
3.758 + Matrix* self = (Matrix*) tolua_tousertype(tolua_S,1,0);
3.759 + Matrix* t = ((Matrix*) tolua_tousertype(tolua_S,2,0));
3.760 +#ifndef TOLUA_RELEASE
3.761 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'times'",NULL);
3.762 +#endif
3.763 + {
3.764 + self->times(*t);
3.765 + }
3.766 + }
3.767 + return 0;
3.768 +#ifndef TOLUA_RELEASE
3.769 + tolua_lerror:
3.770 + tolua_error(tolua_S,"#ferror in function 'times'.",&tolua_err);
3.771 + return 0;
3.772 +#endif
3.773 +}
3.774 +
3.775 +/* method: operator* of class Matrix */
3.776 +static int tolua_doris_Matrix__mul00(lua_State* tolua_S)
3.777 +{
3.778 +#ifndef TOLUA_RELEASE
3.779 + tolua_Error tolua_err;
3.780 + if (
3.781 + !tolua_isusertype(tolua_S,1,"Matrix",0,&tolua_err) ||
3.782 + !tolua_isusertype(tolua_S,2,"Vector",0,&tolua_err) ||
3.783 + !tolua_isnoobj(tolua_S,3,&tolua_err)
3.784 + )
3.785 + goto tolua_lerror;
3.786 + else
3.787 +#endif
3.788 + {
3.789 + Matrix* self = (Matrix*) tolua_tousertype(tolua_S,1,0);
3.790 + Vector* a = ((Vector*) tolua_tousertype(tolua_S,2,0));
3.791 +#ifndef TOLUA_RELEASE
3.792 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'",NULL);
3.793 +#endif
3.794 + {
3.795 + Vector tolua_ret = (Vector) self->operator*(*a);
3.796 + {
3.797 +#ifdef __cplusplus
3.798 + void* tolua_obj = new Vector(tolua_ret);
3.799 + tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"Vector");
3.800 +#else
3.801 + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector));
3.802 + tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"Vector");
3.803 +#endif
3.804 + }
3.805 + }
3.806 + }
3.807 + return 1;
3.808 +#ifndef TOLUA_RELEASE
3.809 + tolua_lerror:
3.810 + tolua_error(tolua_S,"#ferror in function '.mul'.",&tolua_err);
3.811 + return 0;
3.812 +#endif
3.813 +}
3.814 +
3.815 +/* method: plus of class Matrix */
3.816 +static int tolua_doris_Matrix_plus00(lua_State* tolua_S)
3.817 +{
3.818 +#ifndef TOLUA_RELEASE
3.819 + tolua_Error tolua_err;
3.820 + if (
3.821 + !tolua_isusertype(tolua_S,1,"Matrix",0,&tolua_err) ||
3.822 + !tolua_isusertype(tolua_S,2,"Matrix",0,&tolua_err) ||
3.823 + !tolua_isnoobj(tolua_S,3,&tolua_err)
3.824 + )
3.825 + goto tolua_lerror;
3.826 + else
3.827 +#endif
3.828 + {
3.829 + Matrix* self = (Matrix*) tolua_tousertype(tolua_S,1,0);
3.830 + Matrix* t = ((Matrix*) tolua_tousertype(tolua_S,2,0));
3.831 +#ifndef TOLUA_RELEASE
3.832 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'plus'",NULL);
3.833 +#endif
3.834 + {
3.835 + self->plus(*t);
3.836 + }
3.837 + }
3.838 + return 0;
3.839 +#ifndef TOLUA_RELEASE
3.840 + tolua_lerror:
3.841 + tolua_error(tolua_S,"#ferror in function 'plus'.",&tolua_err);
3.842 + return 0;
3.843 +#endif
3.844 +}
3.845 +
3.846 +/* method: minus of class Matrix */
3.847 +static int tolua_doris_Matrix_minus00(lua_State* tolua_S)
3.848 +{
3.849 +#ifndef TOLUA_RELEASE
3.850 + tolua_Error tolua_err;
3.851 + if (
3.852 + !tolua_isusertype(tolua_S,1,"Matrix",0,&tolua_err) ||
3.853 + !tolua_isusertype(tolua_S,2,"Matrix",0,&tolua_err) ||
3.854 + !tolua_isnoobj(tolua_S,3,&tolua_err)
3.855 + )
3.856 + goto tolua_lerror;
3.857 + else
3.858 +#endif
3.859 + {
3.860 + Matrix* self = (Matrix*) tolua_tousertype(tolua_S,1,0);
3.861 + Matrix* t = ((Matrix*) tolua_tousertype(tolua_S,2,0));
3.862 +#ifndef TOLUA_RELEASE
3.863 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'minus'",NULL);
3.864 +#endif
3.865 + {
3.866 + self->minus(*t);
3.867 + }
3.868 + }
3.869 + return 0;
3.870 +#ifndef TOLUA_RELEASE
3.871 + tolua_lerror:
3.872 + tolua_error(tolua_S,"#ferror in function 'minus'.",&tolua_err);
3.873 + return 0;
3.874 +#endif
3.875 +}
3.876 +
3.877 +/* method: transpose of class Matrix */
3.878 +static int tolua_doris_Matrix_transpose00(lua_State* tolua_S)
3.879 +{
3.880 +#ifndef TOLUA_RELEASE
3.881 + tolua_Error tolua_err;
3.882 + if (
3.883 + !tolua_isusertype(tolua_S,1,"Matrix",0,&tolua_err) ||
3.884 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.885 + )
3.886 + goto tolua_lerror;
3.887 + else
3.888 +#endif
3.889 + {
3.890 + Matrix* self = (Matrix*) tolua_tousertype(tolua_S,1,0);
3.891 +#ifndef TOLUA_RELEASE
3.892 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'transpose'",NULL);
3.893 +#endif
3.894 + {
3.895 + self->transpose();
3.896 + }
3.897 + }
3.898 + return 0;
3.899 +#ifndef TOLUA_RELEASE
3.900 + tolua_lerror:
3.901 + tolua_error(tolua_S,"#ferror in function 'transpose'.",&tolua_err);
3.902 + return 0;
3.903 +#endif
3.904 +}
3.905 +
3.906 +/* method: translateBy of class Matrix */
3.907 +static int tolua_doris_Matrix_translateBy00(lua_State* tolua_S)
3.908 +{
3.909 +#ifndef TOLUA_RELEASE
3.910 + tolua_Error tolua_err;
3.911 + if (
3.912 + !tolua_isusertype(tolua_S,1,"Matrix",0,&tolua_err) ||
3.913 + !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
3.914 + !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
3.915 + !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
3.916 + !tolua_isnoobj(tolua_S,5,&tolua_err)
3.917 + )
3.918 + goto tolua_lerror;
3.919 + else
3.920 +#endif
3.921 + {
3.922 + Matrix* self = (Matrix*) tolua_tousertype(tolua_S,1,0);
3.923 + float x = ((float) tolua_tonumber(tolua_S,2,0));
3.924 + float y = ((float) tolua_tonumber(tolua_S,3,0));
3.925 + float z = ((float) tolua_tonumber(tolua_S,4,0));
3.926 +#ifndef TOLUA_RELEASE
3.927 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'translateBy'",NULL);
3.928 +#endif
3.929 + {
3.930 + self->translateBy(x,y,z);
3.931 + }
3.932 + }
3.933 + return 0;
3.934 +#ifndef TOLUA_RELEASE
3.935 + tolua_lerror:
3.936 + tolua_error(tolua_S,"#ferror in function 'translateBy'.",&tolua_err);
3.937 + return 0;
3.938 +#endif
3.939 +}
3.940 +
3.941 +/* method: makeIdentity of class Matrix */
3.942 +static int tolua_doris_Matrix_makeIdentity00(lua_State* tolua_S)
3.943 +{
3.944 +#ifndef TOLUA_RELEASE
3.945 + tolua_Error tolua_err;
3.946 + if (
3.947 + !tolua_isusertype(tolua_S,1,"Matrix",0,&tolua_err) ||
3.948 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.949 + )
3.950 + goto tolua_lerror;
3.951 + else
3.952 +#endif
3.953 + {
3.954 + Matrix* self = (Matrix*) tolua_tousertype(tolua_S,1,0);
3.955 +#ifndef TOLUA_RELEASE
3.956 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'makeIdentity'",NULL);
3.957 +#endif
3.958 + {
3.959 + self->makeIdentity();
3.960 + }
3.961 + }
3.962 + return 0;
3.963 +#ifndef TOLUA_RELEASE
3.964 + tolua_lerror:
3.965 + tolua_error(tolua_S,"#ferror in function 'makeIdentity'.",&tolua_err);
3.966 + return 0;
3.967 +#endif
3.968 +}
3.969 +
3.970 +/* method: makeInverse of class Matrix */
3.971 +static int tolua_doris_Matrix_makeInverse00(lua_State* tolua_S)
3.972 +{
3.973 +#ifndef TOLUA_RELEASE
3.974 + tolua_Error tolua_err;
3.975 + if (
3.976 + !tolua_isusertype(tolua_S,1,"Matrix",0,&tolua_err) ||
3.977 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.978 + )
3.979 + goto tolua_lerror;
3.980 + else
3.981 +#endif
3.982 + {
3.983 + Matrix* self = (Matrix*) tolua_tousertype(tolua_S,1,0);
3.984 +#ifndef TOLUA_RELEASE
3.985 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'makeInverse'",NULL);
3.986 +#endif
3.987 + {
3.988 + self->makeInverse();
3.989 + }
3.990 + }
3.991 + return 0;
3.992 +#ifndef TOLUA_RELEASE
3.993 + tolua_lerror:
3.994 + tolua_error(tolua_S,"#ferror in function 'makeInverse'.",&tolua_err);
3.995 + return 0;
3.996 +#endif
3.997 +}
3.998 +
3.999 +/* method: makeScale of class Matrix */
3.1000 +static int tolua_doris_Matrix_makeScale00(lua_State* tolua_S)
3.1001 +{
3.1002 +#ifndef TOLUA_RELEASE
3.1003 + tolua_Error tolua_err;
3.1004 + if (
3.1005 + !tolua_isusertype(tolua_S,1,"Matrix",0,&tolua_err) ||
3.1006 + !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
3.1007 + !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
3.1008 + !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
3.1009 + !tolua_isnoobj(tolua_S,5,&tolua_err)
3.1010 + )
3.1011 + goto tolua_lerror;
3.1012 + else
3.1013 +#endif
3.1014 + {
3.1015 + Matrix* self = (Matrix*) tolua_tousertype(tolua_S,1,0);
3.1016 + float x = ((float) tolua_tonumber(tolua_S,2,0));
3.1017 + float y = ((float) tolua_tonumber(tolua_S,3,0));
3.1018 + float z = ((float) tolua_tonumber(tolua_S,4,0));
3.1019 +#ifndef TOLUA_RELEASE
3.1020 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'makeScale'",NULL);
3.1021 +#endif
3.1022 + {
3.1023 + self->makeScale(x,y,z);
3.1024 + }
3.1025 + }
3.1026 + return 0;
3.1027 +#ifndef TOLUA_RELEASE
3.1028 + tolua_lerror:
3.1029 + tolua_error(tolua_S,"#ferror in function 'makeScale'.",&tolua_err);
3.1030 + return 0;
3.1031 +#endif
3.1032 +}
3.1033 +
3.1034 +/* method: makeTranslate of class Matrix */
3.1035 +static int tolua_doris_Matrix_makeTranslate00(lua_State* tolua_S)
3.1036 +{
3.1037 +#ifndef TOLUA_RELEASE
3.1038 + tolua_Error tolua_err;
3.1039 + if (
3.1040 + !tolua_isusertype(tolua_S,1,"Matrix",0,&tolua_err) ||
3.1041 + !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
3.1042 + !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
3.1043 + !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
3.1044 + !tolua_isnoobj(tolua_S,5,&tolua_err)
3.1045 + )
3.1046 + goto tolua_lerror;
3.1047 + else
3.1048 +#endif
3.1049 + {
3.1050 + Matrix* self = (Matrix*) tolua_tousertype(tolua_S,1,0);
3.1051 + float x = ((float) tolua_tonumber(tolua_S,2,0));
3.1052 + float y = ((float) tolua_tonumber(tolua_S,3,0));
3.1053 + float z = ((float) tolua_tonumber(tolua_S,4,0));
3.1054 +#ifndef TOLUA_RELEASE
3.1055 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'makeTranslate'",NULL);
3.1056 +#endif
3.1057 + {
3.1058 + self->makeTranslate(x,y,z);
3.1059 + }
3.1060 + }
3.1061 + return 0;
3.1062 +#ifndef TOLUA_RELEASE
3.1063 + tolua_lerror:
3.1064 + tolua_error(tolua_S,"#ferror in function 'makeTranslate'.",&tolua_err);
3.1065 + return 0;
3.1066 +#endif
3.1067 +}
3.1068 +
3.1069 +/* method: new of class Image */
3.1070 +static int tolua_doris_Image_new00(lua_State* tolua_S)
3.1071 +{
3.1072 +#ifndef TOLUA_RELEASE
3.1073 + tolua_Error tolua_err;
3.1074 + if (
3.1075 + !tolua_isusertable(tolua_S,1,"Image",0,&tolua_err) ||
3.1076 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.1077 + )
3.1078 + goto tolua_lerror;
3.1079 + else
3.1080 +#endif
3.1081 + {
3.1082 + {
3.1083 + Image* tolua_ret = (Image*) new Image();
3.1084 + tolua_pushusertype(tolua_S,(void*)tolua_ret,"Image");
3.1085 + }
3.1086 + }
3.1087 + return 1;
3.1088 +#ifndef TOLUA_RELEASE
3.1089 + tolua_lerror:
3.1090 + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
3.1091 + return 0;
3.1092 +#endif
3.1093 +}
3.1094 +
3.1095 +/* method: new_local of class Image */
3.1096 +static int tolua_doris_Image_new00_local(lua_State* tolua_S)
3.1097 +{
3.1098 +#ifndef TOLUA_RELEASE
3.1099 + tolua_Error tolua_err;
3.1100 + if (
3.1101 + !tolua_isusertable(tolua_S,1,"Image",0,&tolua_err) ||
3.1102 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.1103 + )
3.1104 + goto tolua_lerror;
3.1105 + else
3.1106 +#endif
3.1107 + {
3.1108 + {
3.1109 + Image* tolua_ret = (Image*) new Image();
3.1110 + tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"Image");
3.1111 + }
3.1112 + }
3.1113 + return 1;
3.1114 +#ifndef TOLUA_RELEASE
3.1115 + tolua_lerror:
3.1116 + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
3.1117 + return 0;
3.1118 +#endif
3.1119 +}
3.1120 +
3.1121 +/* method: delete of class Image */
3.1122 +static int tolua_doris_Image_delete00(lua_State* tolua_S)
3.1123 +{
3.1124 +#ifndef TOLUA_RELEASE
3.1125 + tolua_Error tolua_err;
3.1126 + if (
3.1127 + !tolua_isusertype(tolua_S,1,"Image",0,&tolua_err) ||
3.1128 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.1129 + )
3.1130 + goto tolua_lerror;
3.1131 + else
3.1132 +#endif
3.1133 + {
3.1134 + Image* self = (Image*) tolua_tousertype(tolua_S,1,0);
3.1135 +#ifndef TOLUA_RELEASE
3.1136 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'",NULL);
3.1137 +#endif
3.1138 + delete self;
3.1139 + }
3.1140 + return 0;
3.1141 +#ifndef TOLUA_RELEASE
3.1142 + tolua_lerror:
3.1143 + tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err);
3.1144 + return 0;
3.1145 +#endif
3.1146 +}
3.1147 +
3.1148 +/* method: load of class Image */
3.1149 +static int tolua_doris_Image_load00(lua_State* tolua_S)
3.1150 +{
3.1151 +#ifndef TOLUA_RELEASE
3.1152 + tolua_Error tolua_err;
3.1153 + if (
3.1154 + !tolua_isusertype(tolua_S,1,"Image",0,&tolua_err) ||
3.1155 + !tolua_isstring(tolua_S,2,0,&tolua_err) ||
3.1156 + !tolua_isnoobj(tolua_S,3,&tolua_err)
3.1157 + )
3.1158 + goto tolua_lerror;
3.1159 + else
3.1160 +#endif
3.1161 + {
3.1162 + Image* self = (Image*) tolua_tousertype(tolua_S,1,0);
3.1163 + char* filename = ((char*) tolua_tostring(tolua_S,2,0));
3.1164 +#ifndef TOLUA_RELEASE
3.1165 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'load'",NULL);
3.1166 +#endif
3.1167 + {
3.1168 + bool tolua_ret = (bool) self->load(filename);
3.1169 + tolua_pushboolean(tolua_S,(bool)tolua_ret);
3.1170 + }
3.1171 + }
3.1172 + return 1;
3.1173 +#ifndef TOLUA_RELEASE
3.1174 + tolua_lerror:
3.1175 + tolua_error(tolua_S,"#ferror in function 'load'.",&tolua_err);
3.1176 + return 0;
3.1177 +#endif
3.1178 +}
3.1179 +
3.1180 +/* method: unload of class Image */
3.1181 +static int tolua_doris_Image_unload00(lua_State* tolua_S)
3.1182 +{
3.1183 +#ifndef TOLUA_RELEASE
3.1184 + tolua_Error tolua_err;
3.1185 + if (
3.1186 + !tolua_isusertype(tolua_S,1,"Image",0,&tolua_err) ||
3.1187 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.1188 + )
3.1189 + goto tolua_lerror;
3.1190 + else
3.1191 +#endif
3.1192 + {
3.1193 + Image* self = (Image*) tolua_tousertype(tolua_S,1,0);
3.1194 +#ifndef TOLUA_RELEASE
3.1195 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'unload'",NULL);
3.1196 +#endif
3.1197 + {
3.1198 + self->unload();
3.1199 + }
3.1200 + }
3.1201 + return 0;
3.1202 +#ifndef TOLUA_RELEASE
3.1203 + tolua_lerror:
3.1204 + tolua_error(tolua_S,"#ferror in function 'unload'.",&tolua_err);
3.1205 + return 0;
3.1206 +#endif
3.1207 +}
3.1208 +
3.1209 +/* method: getAlphaBits of class Image */
3.1210 +static int tolua_doris_Image_getAlphaBits00(lua_State* tolua_S)
3.1211 +{
3.1212 +#ifndef TOLUA_RELEASE
3.1213 + tolua_Error tolua_err;
3.1214 + if (
3.1215 + !tolua_isusertype(tolua_S,1,"Image",0,&tolua_err) ||
3.1216 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.1217 + )
3.1218 + goto tolua_lerror;
3.1219 + else
3.1220 +#endif
3.1221 + {
3.1222 + Image* self = (Image*) tolua_tousertype(tolua_S,1,0);
3.1223 +#ifndef TOLUA_RELEASE
3.1224 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getAlphaBits'",NULL);
3.1225 +#endif
3.1226 + {
3.1227 + int tolua_ret = (int) self->getAlphaBits();
3.1228 + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
3.1229 + }
3.1230 + }
3.1231 + return 1;
3.1232 +#ifndef TOLUA_RELEASE
3.1233 + tolua_lerror:
3.1234 + tolua_error(tolua_S,"#ferror in function 'getAlphaBits'.",&tolua_err);
3.1235 + return 0;
3.1236 +#endif
3.1237 +}
3.1238 +
3.1239 +/* method: getPixels of class Image */
3.1240 +static int tolua_doris_Image_getPixels00(lua_State* tolua_S)
3.1241 +{
3.1242 +#ifndef TOLUA_RELEASE
3.1243 + tolua_Error tolua_err;
3.1244 + if (
3.1245 + !tolua_isusertype(tolua_S,1,"Image",0,&tolua_err) ||
3.1246 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.1247 + )
3.1248 + goto tolua_lerror;
3.1249 + else
3.1250 +#endif
3.1251 + {
3.1252 + Image* self = (Image*) tolua_tousertype(tolua_S,1,0);
3.1253 +#ifndef TOLUA_RELEASE
3.1254 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixels'",NULL);
3.1255 +#endif
3.1256 + {
3.1257 + GLLbuffer* tolua_ret = (GLLbuffer*) self->getPixels();
3.1258 + tolua_pushusertype(tolua_S,(void*)tolua_ret,"GLLbuffer");
3.1259 + }
3.1260 + }
3.1261 + return 1;
3.1262 +#ifndef TOLUA_RELEASE
3.1263 + tolua_lerror:
3.1264 + tolua_error(tolua_S,"#ferror in function 'getPixels'.",&tolua_err);
3.1265 + return 0;
3.1266 +#endif
3.1267 +}
3.1268 +
3.1269 +/* method: getHeight of class Image */
3.1270 +static int tolua_doris_Image_getHeight00(lua_State* tolua_S)
3.1271 +{
3.1272 +#ifndef TOLUA_RELEASE
3.1273 + tolua_Error tolua_err;
3.1274 + if (
3.1275 + !tolua_isusertype(tolua_S,1,"Image",0,&tolua_err) ||
3.1276 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.1277 + )
3.1278 + goto tolua_lerror;
3.1279 + else
3.1280 +#endif
3.1281 + {
3.1282 + Image* self = (Image*) tolua_tousertype(tolua_S,1,0);
3.1283 +#ifndef TOLUA_RELEASE
3.1284 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeight'",NULL);
3.1285 +#endif
3.1286 + {
3.1287 + int tolua_ret = (int) self->getHeight();
3.1288 + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
3.1289 + }
3.1290 + }
3.1291 + return 1;
3.1292 +#ifndef TOLUA_RELEASE
3.1293 + tolua_lerror:
3.1294 + tolua_error(tolua_S,"#ferror in function 'getHeight'.",&tolua_err);
3.1295 + return 0;
3.1296 +#endif
3.1297 +}
3.1298 +
3.1299 +/* method: getWidth of class Image */
3.1300 +static int tolua_doris_Image_getWidth00(lua_State* tolua_S)
3.1301 +{
3.1302 +#ifndef TOLUA_RELEASE
3.1303 + tolua_Error tolua_err;
3.1304 + if (
3.1305 + !tolua_isusertype(tolua_S,1,"Image",0,&tolua_err) ||
3.1306 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.1307 + )
3.1308 + goto tolua_lerror;
3.1309 + else
3.1310 +#endif
3.1311 + {
3.1312 + Image* self = (Image*) tolua_tousertype(tolua_S,1,0);
3.1313 +#ifndef TOLUA_RELEASE
3.1314 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidth'",NULL);
3.1315 +#endif
3.1316 + {
3.1317 + int tolua_ret = (int) self->getWidth();
3.1318 + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
3.1319 + }
3.1320 + }
3.1321 + return 1;
3.1322 +#ifndef TOLUA_RELEASE
3.1323 + tolua_lerror:
3.1324 + tolua_error(tolua_S,"#ferror in function 'getWidth'.",&tolua_err);
3.1325 + return 0;
3.1326 +#endif
3.1327 +}
3.1328 +
3.1329 +/* method: getPixelDepth of class Image */
3.1330 +static int tolua_doris_Image_getPixelDepth00(lua_State* tolua_S)
3.1331 +{
3.1332 +#ifndef TOLUA_RELEASE
3.1333 + tolua_Error tolua_err;
3.1334 + if (
3.1335 + !tolua_isusertype(tolua_S,1,"Image",0,&tolua_err) ||
3.1336 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.1337 + )
3.1338 + goto tolua_lerror;
3.1339 + else
3.1340 +#endif
3.1341 + {
3.1342 + Image* self = (Image*) tolua_tousertype(tolua_S,1,0);
3.1343 +#ifndef TOLUA_RELEASE
3.1344 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixelDepth'",NULL);
3.1345 +#endif
3.1346 + {
3.1347 + int tolua_ret = (int) self->getPixelDepth();
3.1348 + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
3.1349 + }
3.1350 + }
3.1351 + return 1;
3.1352 +#ifndef TOLUA_RELEASE
3.1353 + tolua_lerror:
3.1354 + tolua_error(tolua_S,"#ferror in function 'getPixelDepth'.",&tolua_err);
3.1355 + return 0;
3.1356 +#endif
3.1357 +}
3.1358 +
3.1359 +/* method: getImageType of class Image */
3.1360 +static int tolua_doris_Image_getImageType00(lua_State* tolua_S)
3.1361 +{
3.1362 +#ifndef TOLUA_RELEASE
3.1363 + tolua_Error tolua_err;
3.1364 + if (
3.1365 + !tolua_isusertype(tolua_S,1,"Image",0,&tolua_err) ||
3.1366 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.1367 + )
3.1368 + goto tolua_lerror;
3.1369 + else
3.1370 +#endif
3.1371 + {
3.1372 + Image* self = (Image*) tolua_tousertype(tolua_S,1,0);
3.1373 +#ifndef TOLUA_RELEASE
3.1374 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getImageType'",NULL);
3.1375 +#endif
3.1376 + {
3.1377 + Image::ImageType tolua_ret = (Image::ImageType) self->getImageType();
3.1378 + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
3.1379 + }
3.1380 + }
3.1381 + return 1;
3.1382 +#ifndef TOLUA_RELEASE
3.1383 + tolua_lerror:
3.1384 + tolua_error(tolua_S,"#ferror in function 'getImageType'.",&tolua_err);
3.1385 + return 0;
3.1386 +#endif
3.1387 +}
3.1388 +
3.1389 +/* method: greyscale of class Image */
3.1390 +static int tolua_doris_Image_greyscale00(lua_State* tolua_S)
3.1391 +{
3.1392 +#ifndef TOLUA_RELEASE
3.1393 + tolua_Error tolua_err;
3.1394 + if (
3.1395 + !tolua_isusertype(tolua_S,1,"Image",0,&tolua_err) ||
3.1396 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.1397 + )
3.1398 + goto tolua_lerror;
3.1399 + else
3.1400 +#endif
3.1401 + {
3.1402 + Image* self = (Image*) tolua_tousertype(tolua_S,1,0);
3.1403 +#ifndef TOLUA_RELEASE
3.1404 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'greyscale'",NULL);
3.1405 +#endif
3.1406 + {
3.1407 + self->greyscale();
3.1408 + }
3.1409 + }
3.1410 + return 0;
3.1411 +#ifndef TOLUA_RELEASE
3.1412 + tolua_lerror:
3.1413 + tolua_error(tolua_S,"#ferror in function 'greyscale'.",&tolua_err);
3.1414 + return 0;
3.1415 +#endif
3.1416 +}
3.1417 +
3.1418 +/* method: convertToNormalMap of class Image */
3.1419 +static int tolua_doris_Image_convertToNormalMap00(lua_State* tolua_S)
3.1420 +{
3.1421 +#ifndef TOLUA_RELEASE
3.1422 + tolua_Error tolua_err;
3.1423 + if (
3.1424 + !tolua_isusertype(tolua_S,1,"Image",0,&tolua_err) ||
3.1425 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.1426 + )
3.1427 + goto tolua_lerror;
3.1428 + else
3.1429 +#endif
3.1430 + {
3.1431 + Image* self = (Image*) tolua_tousertype(tolua_S,1,0);
3.1432 +#ifndef TOLUA_RELEASE
3.1433 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'convertToNormalMap'",NULL);
3.1434 +#endif
3.1435 + {
3.1436 + self->convertToNormalMap();
3.1437 + }
3.1438 + }
3.1439 + return 0;
3.1440 +#ifndef TOLUA_RELEASE
3.1441 + tolua_lerror:
3.1442 + tolua_error(tolua_S,"#ferror in function 'convertToNormalMap'.",&tolua_err);
3.1443 + return 0;
3.1444 +#endif
3.1445 +}
3.1446 +
3.1447 +/* method: scaleDownNormalMap of class Image */
3.1448 +static int tolua_doris_Image_scaleDownNormalMap00(lua_State* tolua_S)
3.1449 +{
3.1450 +#ifndef TOLUA_RELEASE
3.1451 + tolua_Error tolua_err;
3.1452 + if (
3.1453 + !tolua_isusertype(tolua_S,1,"Image",0,&tolua_err) ||
3.1454 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.1455 + )
3.1456 + goto tolua_lerror;
3.1457 + else
3.1458 +#endif
3.1459 + {
3.1460 + Image* self = (Image*) tolua_tousertype(tolua_S,1,0);
3.1461 +#ifndef TOLUA_RELEASE
3.1462 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'scaleDownNormalMap'",NULL);
3.1463 +#endif
3.1464 + {
3.1465 + self->scaleDownNormalMap();
3.1466 + }
3.1467 + }
3.1468 + return 0;
3.1469 +#ifndef TOLUA_RELEASE
3.1470 + tolua_lerror:
3.1471 + tolua_error(tolua_S,"#ferror in function 'scaleDownNormalMap'.",&tolua_err);
3.1472 + return 0;
3.1473 +#endif
3.1474 +}
3.1475 +
3.1476 +/* method: smooth of class Image */
3.1477 +static int tolua_doris_Image_smooth00(lua_State* tolua_S)
3.1478 +{
3.1479 +#ifndef TOLUA_RELEASE
3.1480 + tolua_Error tolua_err;
3.1481 + if (
3.1482 + !tolua_isusertype(tolua_S,1,"Image",0,&tolua_err) ||
3.1483 + !tolua_isnoobj(tolua_S,2,&tolua_err)
3.1484 + )
3.1485 + goto tolua_lerror;
3.1486 + else
3.1487 +#endif
3.1488 + {
3.1489 + Image* self = (Image*) tolua_tousertype(tolua_S,1,0);
3.1490 +#ifndef TOLUA_RELEASE
3.1491 + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'smooth'",NULL);
3.1492 +#endif
3.1493 + {
3.1494 + self->smooth();
3.1495 + }
3.1496 + }
3.1497 + return 0;
3.1498 +#ifndef TOLUA_RELEASE
3.1499 + tolua_lerror:
3.1500 + tolua_error(tolua_S,"#ferror in function 'smooth'.",&tolua_err);
3.1501 + return 0;
3.1502 +#endif
3.1503 +}
3.1504 +
3.1505 +/* Open function */
3.1506 +TOLUA_API int tolua_doris_open (lua_State* tolua_S)
3.1507 +{
3.1508 + tolua_open(tolua_S);
3.1509 + tolua_reg_types(tolua_S);
3.1510 + tolua_module(tolua_S,NULL,1);
3.1511 + tolua_beginmodule(tolua_S,NULL);
3.1512 + tolua_variable(tolua_S,"GLUIUpdateCB",tolua_get_GLUIUpdateCB,tolua_set_GLUIUpdateCB);
3.1513 +#ifdef __cplusplus
3.1514 + tolua_cclass(tolua_S,"Window","Window","",tolua_collect_Window);
3.1515 +#else
3.1516 + tolua_cclass(tolua_S,"Window","Window","",NULL);
3.1517 +#endif
3.1518 + tolua_beginmodule(tolua_S,"Window");
3.1519 + tolua_function(tolua_S,"new",tolua_doris_Window_new00);
3.1520 + tolua_function(tolua_S,"new_local",tolua_doris_Window_new00_local);
3.1521 + tolua_function(tolua_S,".call",tolua_doris_Window_new00_local);
3.1522 + tolua_function(tolua_S,"getHandle",tolua_doris_Window_getHandle00);
3.1523 + tolua_function(tolua_S,"setCallback",tolua_doris_Window_setCallback00);
3.1524 + tolua_endmodule(tolua_S);
3.1525 +#ifdef __cplusplus
3.1526 + tolua_cclass(tolua_S,"Vector","Vector","",tolua_collect_Vector);
3.1527 +#else
3.1528 + tolua_cclass(tolua_S,"Vector","Vector","",NULL);
3.1529 +#endif
3.1530 + tolua_beginmodule(tolua_S,"Vector");
3.1531 + tolua_function(tolua_S,"new",tolua_doris_Vector_new00);
3.1532 + tolua_function(tolua_S,"new_local",tolua_doris_Vector_new00_local);
3.1533 + tolua_function(tolua_S,".call",tolua_doris_Vector_new00_local);
3.1534 + tolua_function(tolua_S,"new",tolua_doris_Vector_new01);
3.1535 + tolua_function(tolua_S,"new_local",tolua_doris_Vector_new01_local);
3.1536 + tolua_function(tolua_S,".call",tolua_doris_Vector_new01_local);
3.1537 + tolua_function(tolua_S,"set",tolua_doris_Vector_set00);
3.1538 + tolua_function(tolua_S,".add",tolua_doris_Vector__add00);
3.1539 + tolua_function(tolua_S,".sub",tolua_doris_Vector__sub00);
3.1540 + tolua_function(tolua_S,".mul",tolua_doris_Vector__mul00);
3.1541 + tolua_function(tolua_S,".div",tolua_doris_Vector__div00);
3.1542 + tolua_function(tolua_S,"normalise",tolua_doris_Vector_normalise00);
3.1543 + tolua_function(tolua_S,"length",tolua_doris_Vector_length00);
3.1544 + tolua_function(tolua_S,"dot",tolua_doris_Vector_dot00);
3.1545 + tolua_endmodule(tolua_S);
3.1546 +#ifdef __cplusplus
3.1547 + tolua_cclass(tolua_S,"Matrix","Matrix","",tolua_collect_Matrix);
3.1548 +#else
3.1549 + tolua_cclass(tolua_S,"Matrix","Matrix","",NULL);
3.1550 +#endif
3.1551 + tolua_beginmodule(tolua_S,"Matrix");
3.1552 + tolua_function(tolua_S,"new",tolua_doris_Matrix_new00);
3.1553 + tolua_function(tolua_S,"new_local",tolua_doris_Matrix_new00_local);
3.1554 + tolua_function(tolua_S,".call",tolua_doris_Matrix_new00_local);
3.1555 + tolua_function(tolua_S,".seti",tolua_doris_Matrix__seti00);
3.1556 + tolua_function(tolua_S,".geti",tolua_doris_Matrix__geti00);
3.1557 + tolua_function(tolua_S,"set",tolua_doris_Matrix_set00);
3.1558 + tolua_function(tolua_S,"dump",tolua_doris_Matrix_dump00);
3.1559 + tolua_function(tolua_S,"times",tolua_doris_Matrix_times00);
3.1560 + tolua_function(tolua_S,".mul",tolua_doris_Matrix__mul00);
3.1561 + tolua_function(tolua_S,"plus",tolua_doris_Matrix_plus00);
3.1562 + tolua_function(tolua_S,"minus",tolua_doris_Matrix_minus00);
3.1563 + tolua_function(tolua_S,"transpose",tolua_doris_Matrix_transpose00);
3.1564 + tolua_function(tolua_S,"translateBy",tolua_doris_Matrix_translateBy00);
3.1565 + tolua_function(tolua_S,"makeIdentity",tolua_doris_Matrix_makeIdentity00);
3.1566 + tolua_function(tolua_S,"makeInverse",tolua_doris_Matrix_makeInverse00);
3.1567 + tolua_function(tolua_S,"makeScale",tolua_doris_Matrix_makeScale00);
3.1568 + tolua_function(tolua_S,"makeTranslate",tolua_doris_Matrix_makeTranslate00);
3.1569 + tolua_endmodule(tolua_S);
3.1570 +#ifdef __cplusplus
3.1571 + tolua_cclass(tolua_S,"Image","Image","",tolua_collect_Image);
3.1572 +#else
3.1573 + tolua_cclass(tolua_S,"Image","Image","",NULL);
3.1574 +#endif
3.1575 + tolua_beginmodule(tolua_S,"Image");
3.1576 + tolua_constant(tolua_S,"ImageUndefined",Image::ImageUndefined);
3.1577 + tolua_constant(tolua_S,"ImageRGB",Image::ImageRGB);
3.1578 + tolua_constant(tolua_S,"ImageRGBA",Image::ImageRGBA);
3.1579 + tolua_constant(tolua_S,"ImageGrayscale",Image::ImageGrayscale);
3.1580 + tolua_function(tolua_S,"new",tolua_doris_Image_new00);
3.1581 + tolua_function(tolua_S,"new_local",tolua_doris_Image_new00_local);
3.1582 + tolua_function(tolua_S,".call",tolua_doris_Image_new00_local);
3.1583 + tolua_function(tolua_S,"delete",tolua_doris_Image_delete00);
3.1584 + tolua_function(tolua_S,"load",tolua_doris_Image_load00);
3.1585 + tolua_function(tolua_S,"unload",tolua_doris_Image_unload00);
3.1586 + tolua_function(tolua_S,"getAlphaBits",tolua_doris_Image_getAlphaBits00);
3.1587 + tolua_function(tolua_S,"getPixels",tolua_doris_Image_getPixels00);
3.1588 + tolua_function(tolua_S,"getHeight",tolua_doris_Image_getHeight00);
3.1589 + tolua_function(tolua_S,"getWidth",tolua_doris_Image_getWidth00);
3.1590 + tolua_function(tolua_S,"getPixelDepth",tolua_doris_Image_getPixelDepth00);
3.1591 + tolua_function(tolua_S,"getImageType",tolua_doris_Image_getImageType00);
3.1592 + tolua_function(tolua_S,"greyscale",tolua_doris_Image_greyscale00);
3.1593 + tolua_function(tolua_S,"convertToNormalMap",tolua_doris_Image_convertToNormalMap00);
3.1594 + tolua_function(tolua_S,"scaleDownNormalMap",tolua_doris_Image_scaleDownNormalMap00);
3.1595 + tolua_function(tolua_S,"smooth",tolua_doris_Image_smooth00);
3.1596 + tolua_endmodule(tolua_S);
3.1597 + tolua_endmodule(tolua_S);
3.1598 + return 1;
3.1599 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/source/doris/dorisbind.h Wed Nov 04 00:45:28 2009 +0000
4.3 @@ -0,0 +1,8 @@
4.4 +/*
4.5 +** Lua binding: doris
4.6 +** Generated automatically by tolua++-1.0.6 on 10/17/05 18:37:05.
4.7 +*/
4.8 +
4.9 +/* Exported function */
4.10 +TOLUA_API int tolua_doris_open (lua_State* tolua_S);
4.11 +
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/source/doris/dorisgui.lua Wed Nov 04 00:45:28 2009 +0000
5.3 @@ -0,0 +1,842 @@
5.4 +
5.5 +-- Doris GUI
5.6 +-- $Id$
5.7 +
5.8 +
5.9 +--! item = "Window", group = "Window",
5.10 +--! about = [[This is a wrapper for Doris window and GLUI code.
5.11 +--! This is a collection of helper methods to allow window
5.12 +--! creation from Luas nice table format.]],
5.13 +--! author= "Nick Trout"
5.14 +
5.15 +-- Private: Check is entry e is in table t.
5.16 +--
5.17 +_contains = function (e,t)
5.18 + assert(type(t)=="table","contains expects arg 2 is table")
5.19 +
5.20 + for k,v in t do
5.21 + if e==v then return true end
5.22 + end
5.23 + return nil
5.24 +end
5.25 +
5.26 +-----------------------------------------------------------------
5.27 +--! group = "Window", item = "Seperators",
5.28 +--! about = [[
5.29 +--! Seperators add spaces and lines between the widgets.
5.30 +--! These can be lines or spaces, horizontally or vertically.
5.31 +--! <tt>space = "h" | "-" | "v" | "|"</tt> inserts a space, and
5.32 +--! <tt>line = "h" | "-" | "v" | "|"</tt> creates a line either
5.33 +--! horizontally or vertically. You will have to pick the appropriate
5.34 +--! one according to your widget layout. You cannot have a space and
5.35 +--! a line. ]],
5.36 +--! eg = [[{ space="h" } , { line="v" } or { line="|" }]]
5.37 +
5.38 +function Window:_Separators(t)
5.39 + -- Private: Given a widget description table, look for a "space" or "line"
5.40 + -- entry and add the appropriate seperator to the parent widget.
5.41 + -- ie. t={ space="h" }, or t={ line="v" } are valid.
5.42 + assert(type(t)=="table","Separators expects table")
5.43 +
5.44 + -- set width and height
5.45 +
5.46 + if t.width then
5.47 + assert(type(t.width)=="number","width expecting number")
5.48 + t._wdg:set_w(t.width)
5.49 + end
5.50 +
5.51 + if t.height then
5.52 + assert(type(t.height)=="number","height expecting number")
5.53 + t._wdg:set_h(t.height)
5.54 + end
5.55 +
5.56 + -- check valid
5.57 +
5.58 + if not (t.line or t.space) then return end -- no separators
5.59 + assert(not (t.line and t.space),"You cannot have a line and a space!")
5.60 +
5.61 + -- add seperators
5.62 +
5.63 + local validwords = {"h","-","v","|"}
5.64 +
5.65 + if t.parent.type=="sub" then
5.66 +
5.67 + if t.line then
5.68 + assert(_contains(t.line,validwords),"Bad line type")
5.69 + if t.line=="h" or t.line=="-" then
5.70 + Window.glui:add_separator() -- horiz line
5.71 + else
5.72 + Window.glui:add_column(1)
5.73 + end
5.74 +
5.75 + else -- space
5.76 + assert(_contains(t.space,validwords),"Bad space type")
5.77 + if t.space=="h" or t.space=="-" then
5.78 + Window.glui:add_statictext("")
5.79 + else
5.80 + Window.glui:add_column(0)
5.81 + end
5.82 + end
5.83 +
5.84 + else -- "panel" or "rollout"
5.85 +
5.86 + if t.line then
5.87 + assert(_contains(t.line,validwords),"Bad line type")
5.88 + if t.line=="h" or t.line=="-" then
5.89 + Window.glui:add_separator_to_panel(t.parent) -- horiz line
5.90 + else
5.91 + Window.glui:add_column_to_panel(t.parent,1)
5.92 + end
5.93 +
5.94 + else -- space
5.95 + assert(_contains(t.space,validwords),"Bad space type")
5.96 + if t.space=="h" or t.space=="-" then
5.97 + Window.glui:add_statictext_to_panel(t.parent,"")
5.98 + else
5.99 + Window.glui:add_column_to_panel(t.parent,0)
5.100 + end
5.101 + end
5.102 +
5.103 + end
5.104 +end
5.105 +
5.106 +-- Private: Does a few generic widget checks on widget type "typ",
5.107 +-- with description table t.
5.108 +--
5.109 +function Window:_checkBasics(typ,t)
5.110 + assert(Window.wmain,"No main window created")
5.111 + assert(Window.glui, "No glui object")
5.112 + assert(type(t)=="table",typ.." expects a table")
5.113 + assert(t.parent,"No parent")
5.114 + assert(t.parent.type,"Parent has no type")
5.115 +end
5.116 +
5.117 +-----------------------------------------------------------------
5.118 +-- Register a widget callback or update function.
5.119 +-- This will be called whenever the widget value changes allowing you
5.120 +-- to perform some function. The function is passed in the widget
5.121 +-- description table eg. { update=myUpdateFunction } where
5.122 +-- eg. Print out new value of widget:
5.123 +-- { update = function(x) print("The new value is "..str(x)) end }
5.124 +-- *Note* This is a private function and should not be called directly.
5.125 +-- The "update" parameter in your widget description will be passed here
5.126 +-- automatically.
5.127 +
5.128 +function Window:_RegisterCB(typ,t)
5.129 + -- Private: Maintain callback table. For a given callback, stick it in a table and
5.130 + -- return an id for referencing it in the table.
5.131 + assert(type and type(t)=="table")
5.132 +
5.133 + if not (t.value or t.update) then return -1 end -- dont bother
5.134 +
5.135 + if not self.cb_count then -- initialise
5.136 + self.cb_count = 1
5.137 + self.cb_info = {}
5.138 + end
5.139 +
5.140 + local id = self.cb_count
5.141 + self.cb_count = self.cb_count+1
5.142 + self.cb_info[id] = t
5.143 + t._valtype=typ -- set the edit value type in the widget description
5.144 +
5.145 + return id
5.146 +end
5.147 +
5.148 +function _WindowCB(id)
5.149 + -- Private: GLUI callbacks call here. id is the identifier of the widget that
5.150 + -- is related to the event.
5.151 +
5.152 + local info = Window.cb_info[id]
5.153 + assert(info,"No info registered for callback")
5.154 +
5.155 + local vt, newvalue = info._valtype
5.156 +
5.157 + if vt then
5.158 + --TODO: optimise the ifelses out into a global table
5.159 + if vt=="int" then
5.160 + newvalue = info._wdg:get_int_val()
5.161 +
5.162 + elseif vt=="bool_int" then
5.163 + -- convert integer to boolean
5.164 + newvalue = (info._wdg:get_int_val() ~= 0)
5.165 +
5.166 + elseif vt=="float" then
5.167 + newvalue = info._wdg:get_float_val()
5.168 +
5.169 + elseif vt=="text" then
5.170 + newvalue = info._wdg:get_text_val()
5.171 +
5.172 + elseif vt=="x" then
5.173 + newvalue = info._wdg:get_x()
5.174 +
5.175 + elseif vt=="y" then
5.176 + newvalue = info._wdg:get_y()
5.177 +
5.178 + elseif vt=="z" then
5.179 + newvalue = info._wdg:get_z()
5.180 +
5.181 + elseif vt=="xy" then
5.182 + newvalue = {info._wdg:get_x(),info._wdg:get_y()}
5.183 +
5.184 + elseif vt=="listitem" then
5.185 + local val = info._wdg:get_int_val()
5.186 + newvalue = info._itemvals[val]
5.187 +
5.188 + elseif vt=="matrix" or vt=="none" then
5.189 + -- do nothing
5.190 +
5.191 + else
5.192 + error("Bad value type: "..tostring(vt))
5.193 +
5.194 + end
5.195 + end
5.196 +
5.197 + -- this relies on all value containers having a Get() fn
5.198 + info.value = newvalue -- set widget value
5.199 + local cb=info.update
5.200 + if cb then -- call update fn if one exists
5.201 + if newvalue~=nil then
5.202 + cb(newvalue)
5.203 + else
5.204 + cb()
5.205 + end
5.206 + end
5.207 +
5.208 +end
5.209 +
5.210 +-----------------------------------------------------------------
5.211 +--! item = "Window:create{params}", group = "Window",
5.212 +--! about=[[Create a window for the application to use.
5.213 +--! You must do this first to create a window that can be used by the rest
5.214 +--! of the GUI. ]],
5.215 +--! params = [[
5.216 +--! t is a table describing the window. Relevent table fields to set are:
5.217 +--! * title - the window title.
5.218 +--! * render - the render callback function. A default value is set for this. You
5.219 +--! would not ordinarily override this. ]],
5.220 +--! returns = [[Reference to Window created.]],
5.221 +--! eg = [[winmain = Window:Create{ title="My Doris App" }]]
5.222 +
5.223 +function Window:create(t)
5.224 + assert(type(t)=="table")
5.225 + assert(not self.wmain,"Can only have one main window")
5.226 +
5.227 + -- get details and create
5.228 + local text = t.title or "Doris"
5.229 + local w = Window:new(text) -- create the window
5.230 + self.wmain = w
5.231 +
5.232 + -- See if render callback has been specified - must have
5.233 + assert(t.render, "No render callback specified in Window creation")
5.234 + assert(type(t.render)=="function","Window render callback is not a function")
5.235 + _RenderCB = t.render
5.236 +
5.237 + -- See if idle callback
5.238 + if t.idle then
5.239 + assert(type(t.idle)=="function","Window idle callback is not a function")
5.240 + _IdleCB = t.idle
5.241 + end
5.242 +
5.243 + -- See if key event callback
5.244 + if t.key then
5.245 + assert(type(t.key)=="function","Window key callback is not a function")
5.246 + _KeyCB = t.key
5.247 + end
5.248 +
5.249 + -- See if mouse event callback
5.250 + if t.mouse then
5.251 + assert(type(t.mouse)=="function","Window mouse callback is not a function")
5.252 + _MouseCB = t.mouse
5.253 + end
5.254 +
5.255 + -- See if drag (motion) event callback
5.256 + if t.drag then
5.257 + assert(type(t.drag)=="function","Window drag callback is not a function")
5.258 + _MotionCB = t.drag
5.259 + end
5.260 +
5.261 + -- See if move (passive motion) event callback
5.262 + if t.move then
5.263 + assert(type(t.move)=="function","Window move callback is not a function")
5.264 + _PassiveCB = t.move
5.265 + end
5.266 + return w
5.267 +end
5.268 +
5.269 +-----------------------------------------------------------------
5.270 +--! item = "SubWindow{params}", group = "Window",
5.271 +--! about=[[Create a subwindow with the main window.
5.272 +--! Subwindows are what the widgets go into. You must have first created a main
5.273 +--! window. ]],
5.274 +--! params=[[ A table containing subwindow parameters:
5.275 +--! * parent - main window must be specified.
5.276 +--! * side - gives the location of the window: top, bottom, left or right.]],
5.277 +--! returns = [[A reference to the subwindow.]],
5.278 +--! eg = [[sw=SubWindow{ parent=winmain, side="right" } ]]
5.279 +
5.280 +function SubWindow(t)
5.281 + assert(type(t)=="table", "SubWindow expects a table")
5.282 + assert(Window.wmain,"No main window created")
5.283 +
5.284 + local side = t.side or "bottom"
5.285 + local smap = {
5.286 + top=GLUI_SUBWINDOW_TOP,
5.287 + bottom=GLUI_SUBWINDOW_BOTTOM,
5.288 + left=GLUI_SUBWINDOW_LEFT,
5.289 + right=GLUI_SUBWINDOW_RIGHT
5.290 + }
5.291 + assert(smap[side],"Bad SubWindow side")
5.292 +
5.293 + -- create in GLUI
5.294 + local sw = GLUI_Master:create_glui_subwindow( Window.wmain:getHandle(), smap[side] )
5.295 + sw:set_main_gfx_window( Window.wmain:getHandle() )
5.296 +
5.297 + -- remember the details
5.298 + t._wdg, sw.type = sw,"sub"
5.299 + Window.glui = sw
5.300 + return sw -- return the subwindow
5.301 +end
5.302 +
5.303 +-- These are all of the GLUI widget types :-
5.304 +-- GLUI_CONTROL_CHECKBOX =1,
5.305 +-- GLUI_CONTROL_BUTTON,
5.306 +-- GLUI_CONTROL_RADIOBUTTON,
5.307 +-- GLUI_CONTROL_RADIOGROUP,
5.308 +-- GLUI_CONTROL_SLIDER, -- where??
5.309 +-- GLUI_CONTROL_STATICTEXT,
5.310 +-- GLUI_CONTROL_EDITTEXT,
5.311 +-- GLUI_CONTROL_BITMAP, -- we dont use these
5.312 +-- GLUI_CONTROL_PANEL,
5.313 +-- GLUI_CONTROL_SPINNER,
5.314 +-- GLUI_CONTROL_SEPARATOR, -- Window._Separators()
5.315 +-- GLUI_CONTROL_COLUMN, -- Window._Separators()
5.316 +-- GLUI_CONTROL_LISTBOX,
5.317 +-- GLUI_CONTROL_MOUSE_INTERACTION,
5.318 +-- GLUI_CONTROL_ROTATION,
5.319 +-- GLUI_CONTROL_TRANSLATION,
5.320 +-- GLUI_CONTROL_ROLLOUT
5.321 +
5.322 +-----------------------------------------------------------------
5.323 +--! item = "Checkbox{params}", group = "Window",
5.324 +--! about = [[Creates a Checkbox widget. Check boxes are boolean widgets
5.325 +--! that you can tick on and off. The parameters are passed in a table.
5.326 +--! eg. <tt>Checkbox{ parent=subwindow, text="Solid", value=sphere.solid }</tt> ]],
5.327 +--! params = [[
5.328 +--! * parent - widget must be specified.
5.329 +--! * text - is the text displayed next to the Checkbox.
5.330 +--! * value - gives the initial value of the Checkbox, ie. 0 for off, 1 for on.
5.331 +--! * line - "|" or "-". See Window:Separators.
5.332 +--! * space - "|" or "-". See Window:Separators.
5.333 +--! * update - Call back function called when value changes. See Window:Upate Callbacks.]],
5.334 +--! returns = "A reference to the Checkbox."
5.335 +
5.336 +function Checkbox(t)
5.337 + Window:_checkBasics("Checkbox",t)
5.338 + assert(_contains(t.parent.type,{"sub","panel","rollout"}),"Bad parent type")
5.339 +
5.340 + local text = t.text or "<Checkbox>"
5.341 + local id = Window:_RegisterCB("bool_int",t)
5.342 + local w
5.343 +
5.344 + if t.parent.type=="sub" then
5.345 + w = Window.glui:add_checkbox(text,0,id,GLUIUpdateCB)
5.346 + else
5.347 + w = Window.glui:add_checkbox_to_panel(t.parent,text,0,id,GLUIUpdateCB)
5.348 + end
5.349 +
5.350 + t._wdg,w.type=w,"checkbox"
5.351 + -- we must convert any boolean values to integers
5.352 + local bool_to_int = { [true]=1, [false]=0 }
5.353 + if t.value then w:set_int_val(bool_to_int[t.value] or t.value) end -- initial value
5.354 + Window:_Separators(t)
5.355 +
5.356 + return w
5.357 +end
5.358 +
5.359 +-----------------------------------------------------------------
5.360 +--! item = "Button{params}", group = "Window",
5.361 +--! about=[[Create a Button widget.
5.362 +--! Buttons are widgets that create an event when you click on them. ]],
5.363 +--! params=[[ A table containing Button parameters:
5.364 +--! * parent - widget must be specified.
5.365 +--! * text - is the text displayed in the Button.
5.366 +--! * line - "|" or "-". See Window:Separators.
5.367 +--! * space - "|" or "-". See Window:Separators.
5.368 +--! * update - Call back function called when value changes. See Window:Upate Callbacks.]],
5.369 +--! returns=[[A reference to the Button.]],
5.370 +--! eg=[[Button{ parent=subwin, text="Click me!" }]]
5.371 +
5.372 +function Button(t)
5.373 + Window:_checkBasics("Button",t)
5.374 + assert(_contains(t.parent.type,{"sub","panel","rollout"}),"Bad parent type")
5.375 +
5.376 + local text = t.text or "<Button>"
5.377 + local id = Window:_RegisterCB("none",t)
5.378 + local w
5.379 +
5.380 + if t.parent.type=="sub" then
5.381 + w = Window.glui:add_button(text,id,GLUIUpdateCB)
5.382 + else
5.383 + w = Window.glui:add_button_to_panel(t.parent,text,id,GLUIUpdateCB)
5.384 + end
5.385 +
5.386 + t._wdg,w.type=w,"button"
5.387 + Window:_Separators(t)
5.388 + return w
5.389 +end
5.390 +
5.391 +-----------------------------------------------------------------
5.392 +--! item = "Radiobutton{params}", group = "Window",
5.393 +--! about=[[Create a Radiobutton widget.
5.394 +--! This type of button goes in a Radiogroup and only one of the buttons in the
5.395 +--! group may be on at once. The Radiogroup should be the widget interrogated to
5.396 +--! find out which Radiobutton is currently selected. ]],
5.397 +--! params=[[ A Table containing Radiobutton parameters:
5.398 +--! * parent - Radiogroup widget must be specified.
5.399 +--! * text - the text displayed next to the Radiobutton.
5.400 +--! * line - "|" or "-". See Window:Separators.
5.401 +--! * space - "|" or "-". See Window:Separators. ]],
5.402 +--! returns=[[ A reference to the Radiobutton.]],
5.403 +--! eg=[[ Radiobutton{ parent=radiogroup1, text="Red" } ]]
5.404 +
5.405 +function Radiobutton(t)
5.406 + Window:_checkBasics("Radiobutton",t)
5.407 + assert(t.parent.type=="radiogroup","Radiobutton's parent must be Radiogroup")
5.408 + assert(not t.update,"Radiobutton does not have an update(), use Radiogroup")
5.409 +
5.410 + local text = t.text or "<Radiobutton>"
5.411 + -- text should be a list of names eg. text={"a","b","c"}
5.412 + if type(text)~="table" then text={text} end
5.413 +
5.414 + local w
5.415 + for i=1,table.getn(text) do
5.416 + w = Window.glui:add_radiobutton_to_group(t.parent,text[i])
5.417 + w.type="radiobutton"
5.418 + end
5.419 +
5.420 + t._wdg=w
5.421 + Window:_Separators(t)
5.422 + return w -- note we only return the last one if a list
5.423 +end
5.424 +
5.425 +-----------------------------------------------------------------
5.426 +--! item = "Radiogroup{params}", group = "Window",
5.427 +--! about=[[Create a Radiogroup widget.
5.428 +--! This is a container widget which holds a group of Radiobutton widgets. ]],
5.429 +--! params=[[ A table containing Radiogroup parameters:
5.430 +--! * parent - widget must be specified.
5.431 +--! * text - the text displayed in the border heading.
5.432 +--! * value - sets which one of the Radiobuttons is on initially.
5.433 +--! * line - "|" or "-". See Window:Separators.
5.434 +--! * space - "|" or "-". See Window:Separators.
5.435 +--! * update - Call back function called when value changes. See Window:Upate Callbacks.]],
5.436 +--! returns=[[ A reference to the Radiogroup. ]],
5.437 +--! eg=[[ Radiogroup{ parent=subwin, text="Colours:", value=1 } ]]
5.438 +
5.439 +function Radiogroup(t)
5.440 + Window:_checkBasics("Radiogroup",t)
5.441 + assert(_contains(t.parent.type,{"sub","panel","rollout"}),"Bad parent type")
5.442 +
5.443 + local text = t.text or "<Radiogroup>"
5.444 + local id = Window:_RegisterCB("int",t)
5.445 + local w
5.446 +
5.447 + if t.parent.type=="sub" then
5.448 + w = Window.glui:add_radiogroup(0,id,GLUIUpdateCB)
5.449 + else
5.450 + w = Window.glui:add_radiogroup_to_panel(t.parent,0,id,GLUIUpdateCB)
5.451 + end
5.452 +
5.453 + t._wdg,w.type=w,"radiogroup"
5.454 + if t.value then w:set_int_val(t.value) end
5.455 + Window:_Separators(t)
5.456 + return w
5.457 +end
5.458 +
5.459 +-----------------------------------------------------------------
5.460 +--! item = "Text{params}", group = "Window",
5.461 +--! about=[[Create a simple text label.
5.462 +--! This widget just displays some text. ]],
5.463 +--! params=[[ At table containing Text parameters:
5.464 +--! * parent - parent widget of this Text.
5.465 +--! * text - the text displayed.
5.466 +--! * line - "|" or "-". See Window:Separators.
5.467 +--! * space - "|" or "-". See Window:Separators. ]],
5.468 +--! returns=[[ A reference to the Text. ]],
5.469 +--! eg=[[ Text{ parent=subwin, text="Hello world" } ]]
5.470 +
5.471 +function Text(t)
5.472 + Window:_checkBasics("Text",t)
5.473 + assert(_contains(t.parent.type,{"sub","panel","rollout"}),"Bad parent type")
5.474 + local text = t.text or "<Text>"
5.475 + local w
5.476 +
5.477 + if t.parent.type=="sub" then
5.478 + w = Window.glui:add_statictext(text)
5.479 + else
5.480 + w = Window.glui:add_statictext_to_panel(t.parent,text)
5.481 + end
5.482 +
5.483 + t._wdg,w.type=w,"text"
5.484 + Window:_Separators(t)
5.485 + return w
5.486 +end
5.487 +
5.488 +-----------------------------------------------------------------
5.489 +--! item = "Edit{params}", group = "Window",
5.490 +--! about=[[Create a text and number editing widget.
5.491 +--! The text in the widget can be edited by the user. The values held can either
5.492 +--! be a string, an integer number or a float number. ]],
5.493 +--! params=[[ A table containing Edit parameters:
5.494 +--! * parent - parent widget of this Edit.
5.495 +--! * text - the Edit label, or title.
5.496 +--! * value - the initial value displayed.
5.497 +--! * type - the edit type, ie. "text", "int" or "float". Default is "text".
5.498 +--! * line - "|" or "-". See Window:Separators.
5.499 +--! * space - "|" or "-". See Window:Separators.
5.500 +--! * update - Call back function called when value changes. See Window:Upate Callbacks.]],
5.501 +--! returns=[[ A reference to the Edit. ]],
5.502 +--! eg=[[ Edit{ parent=subwin, value="Hello world", type=text } ]]
5.503 +
5.504 +function Edit(t)
5.505 + Window:_checkBasics("Edit",t)
5.506 + assert(_contains(t.parent.type, {"sub","panel","rollout"}), "Bad parent type")
5.507 +
5.508 + local text = t.text or "<Edit>"
5.509 + local value = t.value or "<Value>"
5.510 +
5.511 + local typmap={
5.512 + text = GLUI_EDITTEXT_TEXT,
5.513 + int = GLUI_EDITTEXT_INT,
5.514 + float = GLUI_EDITTEXT_FLOAT
5.515 + }
5.516 + local type = t.type or "text"
5.517 + assert(typmap[type], "Bad Edit type: "..type)
5.518 + gtype = typmap[type]
5.519 + local id = Window:_RegisterCB(type, t)
5.520 + local w
5.521 +
5.522 + if t.parent.type=="sub" then
5.523 + w = Window.glui:add_edittext(text,gtype,0,id,GLUIUpdateCB)
5.524 + else
5.525 + w = Window.glui:add_edittext_to_panel(t.parent,text,gtype,0,id,GLUIUpdateCB)
5.526 + end
5.527 +
5.528 + t._wdg,w.type=w,"edit"
5.529 + w.valtype = type
5.530 + --w:set_text(text)
5.531 + Window:_Separators(t)
5.532 + return w
5.533 +end
5.534 +
5.535 +-- Bitmap should be here
5.536 +
5.537 +-----------------------------------------------------------------
5.538 +--! item = "Panel{params}", group = "Window",
5.539 +--! about=[[ Create a panel widget container.
5.540 +--! The is a simple container which can be used to organise widgets
5.541 +--! into groups. Once a panel has been created other widgets can be
5.542 +--! put into it. ]],
5.543 +--! params=[[A table containing Panel parameters:
5.544 +--! * parent - parent widget of this Panel.
5.545 +--! * text - the text displayed in panel centre.
5.546 +--! * type - the graphical appearence of the panel edge,
5.547 +--! ie. "none", "embossed", or "raised". The default is "embossed".
5.548 +--! * line - "|" or "-". See Window:Separators.
5.549 +--! * space - "|" or "-". See Window:Separators. ]],
5.550 +--! returns=[[ A reference to the Panel. ]],
5.551 +--! eg=[[ Panel{ parent=subwin, text="Hello world", type="text" } ]]
5.552 +
5.553 +function Panel(t)
5.554 + -- todo: set_type()
5.555 + Window:_checkBasics("Panel",t)
5.556 + assert(_contains(t.parent.type,{"sub","panel","rollout"}),"Bad parent type")
5.557 +
5.558 + local text = t.text or "<Panel>"
5.559 + local typmap = {
5.560 + none=GLUI_PANEL_NONE,
5.561 + embossed=GLUI_PANEL_EMBOSSED,
5.562 + raised=GLUI_PANEL_RAISED
5.563 + }
5.564 +
5.565 + local type = t.type or "embossed"
5.566 + assert(typmap[type], "Bad Panel type")
5.567 + type = typmap[type]
5.568 + local w
5.569 +
5.570 + if t.parent.type=="sub" then
5.571 + w = Window.glui:add_panel(text,type)
5.572 + else
5.573 + w = Window.glui:add_panel_to_panel(t.parent,text,type)
5.574 + end
5.575 +
5.576 + t._wdg,w.type = w,"panel"
5.577 + return w
5.578 +end
5.579 +
5.580 +-----------------------------------------------------------------
5.581 +--! item = "Spinner{params}", group = "Window",
5.582 +--! about=[[ Create a value spinner.
5.583 +--! The value in this widget can be edited several ways, ''directly'',
5.584 +--! like an Edit widget, using ''up and down'' buttons and by ''dragging''
5.585 +--! with the mouse. ]],
5.586 +--! params=[[A table containing Spinner parameters:
5.587 +--! * parent - parent widget of this Spinner.
5.588 +--! * text - the text label to the spinner.
5.589 +--! * value - is the initial value.
5.590 +--! * type - the number type. ie. "int" or "float". Default is "int".
5.591 +--! * limits - @T limits={min,max} @t specifies the range limits of the values allowed,
5.592 +--! eg. @T limits={-10,100} @t
5.593 +--! * line - "|" or "-". See Window:Separators.
5.594 +--! * space - "|" or "-". See Window:Separators.
5.595 +--! * update - Call back function called when value changes. See Window:Upate Callbacks.]],
5.596 +--! returns=[[ A reference to the Spinner. ]],
5.597 +--! eg=[[ Spinner{ parent=subwin, value=12.34, type="float", limits={0,20} } ]]
5.598 +
5.599 +function Spinner(t)
5.600 + Window:_checkBasics("Spinner",t)
5.601 + assert(_contains(t.parent.type,{"sub","panel","rollout"}), "Bad parent type")
5.602 +
5.603 + local text = t.text or t.value -- set value as default if no text given
5.604 + local typmap = {
5.605 + int = GLUI_SPINNER_INT,
5.606 + float = GLUI_SPINNER_FLOAT
5.607 + }
5.608 + local stype = t.type or "int"
5.609 + assert(typmap[stype], "Bad Spinner type")
5.610 + local gtype = typmap[stype]
5.611 + local id = Window:_RegisterCB(stype,t)
5.612 + local w
5.613 +
5.614 + if t.parent.type=="sub" then
5.615 + w = Window.glui:add_spinner(text,gtype,0,id,GLUIUpdateCB)
5.616 + else
5.617 + w = Window.glui:add_spinner_to_panel(t.parent,text,gtype,0,id,GLUIUpdateCB)
5.618 + end
5.619 +
5.620 + t._wdg, w.type = w, "spinner"
5.621 +
5.622 + -- set limits
5.623 + if t.limits then
5.624 + local lim = t.limits
5.625 + assert(type(lim)=="table", "Spinner limits should be a table")
5.626 + assert(table.getn(lim)==2, "Spinner limits should contain 2 items: (min,max)")
5.627 + local lmt = GLUI_LIMIT_CLAMP
5.628 + if t.wrap and t.wrap~=0 then lmt = GLUI_LIMIT_WRAP end
5.629 + if stype=="int" then
5.630 + w:set_int_limits(lim[1], lim[2], lmt)
5.631 + else
5.632 + w:set_float_limits(lim[1], lim[2], lmt)
5.633 + end
5.634 + end
5.635 +
5.636 + if t.value then -- initial value
5.637 + if stype=="int" then
5.638 + w:set_int_val(t.value)
5.639 + else
5.640 + w:set_float_val(t.value)
5.641 + end
5.642 + end
5.643 +
5.644 + Window:_Separators(t)
5.645 + return w
5.646 +end
5.647 +
5.648 +-----------------------------------------------------------------
5.649 +--! item = "Listbox{params}", group = "Window",
5.650 +--! about=[[ Create a list of choices.
5.651 +--! A drop down list or combi box. ]],
5.652 +--! params=[[ A table containing Listbox parameters:
5.653 +--! * parent - widget of this Listbox.
5.654 +--! * text - the Listbox title.
5.655 +--! * items - a list of the items in the listbox,
5.656 +--! eg. @T { items={"red","yellow","green"} @t
5.657 +--! * line - "|" or "-". See Window:Separators.
5.658 +--! * space - "|" or "-". See Window:Separators.
5.659 +--! * update - Call back function called when value changes. See Window:Upate Callbacks.]],
5.660 +--! returns=[[ A reference to the Listbox. ]],
5.661 +--! eg=[[ Listbox{ parent=subwin, text="title", items={"a","b","c"} } ]]
5.662 +
5.663 +function Listbox(t)
5.664 + Window:_checkBasics("Listbox",t)
5.665 + assert(_contains(t.parent.type,{"sub","panel","rollout"}),"Bad parent type")
5.666 + local text = t.text or "<Listbox>"
5.667 + local id = Window:_RegisterCB("listitem",t)
5.668 + local w
5.669 +
5.670 + if t.parent.type=="sub" then
5.671 + w = Window.glui:add_listbox(text,0,id,GLUIUpdateCB)
5.672 + else
5.673 + w = Window.glui:add_listbox_to_panel(t.parent,text,0,id,GLUIUpdateCB)
5.674 + end
5.675 +
5.676 + t._wdg,w.type=w,"listbox"
5.677 +
5.678 + -- put items in the listbox
5.679 +
5.680 + local items = t.items or {"<no items>"}
5.681 + assert(type(items)=="table","Listbox items must be a list in table")
5.682 + t._itemvals = {} -- remember items for callbacks
5.683 + if table.getn(items)>0 then
5.684 + -- we have an ordered list, eg. {"a","b","c"}
5.685 + for i=1,table.getn(items) do
5.686 + w:add_item(i,tostring(items[i]))
5.687 + table.insert(t._itemvals,items[i])
5.688 + end
5.689 + else
5.690 + -- we have a mapped list?
5.691 + local i=1
5.692 + for k,v in items do
5.693 + w:add_item(i,tostring(k)) -- v is id, key is text
5.694 + table.insert(t._itemvals,v)
5.695 + i=i+1
5.696 + end
5.697 + end
5.698 +
5.699 + -- if the sort flag is set we need to sort them
5.700 + if t.sort then
5.701 + if t.sort~=0 then w:sort_items() end
5.702 + end
5.703 +
5.704 + -- if we have a value, set the selection
5.705 + if t.value then
5.706 + w:do_selection(t.value)
5.707 + end
5.708 +
5.709 + Window:_Separators(t)
5.710 + return w
5.711 +end
5.712 +
5.713 +-- No mouse interaction
5.714 +
5.715 +-----------------------------------------------------------------
5.716 +--! item = "Rotator{params}", group = "Window",
5.717 +--! about=[[ Create a rotation trackball widget.
5.718 +--! This creates a spherical widget which can be used to rotate an object in your scene.
5.719 +--! When you rotate the sphere in the widget, the object attached to the Rotator behaves
5.720 +--! similarly. The widget is attached to a matrix which it manipulates. <br>
5.721 +--! Note: The matrix you attach to the widget must only be used by this widget,
5.722 +--! ie. you cannot manipulate the matrix value as its value is set directly by GLUI. ]],
5.723 +--! params=[[A table containing Rotator parameters:
5.724 +--! * parent - parent widget of this Rotator.
5.725 +--! * text - the Rotator title.
5.726 +--! * value - is the Matrix to use (see note above).
5.727 +--! * spin - the spin damping factor. 0 for no spin, 1 for no damping.
5.728 +--! * line - "|" or "-". See Window:Separators.
5.729 +--! * space - "|" or "-". See Window:Separators.
5.730 +--! * update - Call back function called when value changes. See Window:Upate Callbacks.]],
5.731 +--! returns=[[ A reference to the Rotator. ]],
5.732 +--! eg=[[ Rotator{ parent=subwin, text="Scene", value=scene.rotationMatrix } ]]
5.733 +
5.734 +function Rotator(t)
5.735 + Window:_checkBasics("Rotator",t)
5.736 + assert(_contains(t.parent.type,{"sub","panel","rollout"}),"Bad parent type")
5.737 +
5.738 + local text = t.text or "<Rotator>"
5.739 + local val = t.value
5.740 + assert(val,"Rotator has no value to manipulate")
5.741 +
5.742 + --assert(tag(val)==tolua:tag(Matrix),"Rotator value is not a Matrix")
5.743 + local id = Window:_RegisterCB("matrix",t)
5.744 + local w
5.745 +
5.746 + if t.parent.type=="sub" then
5.747 + w = Window.glui:add_rotation(text,val,id,GLUIUpdateCB)
5.748 + else
5.749 + w = Window.glui:add_rotation_to_panel(t.parent,text,val,id,GLUIUpdateCB)
5.750 + end
5.751 +
5.752 + if t.spin then
5.753 + assert(type(t.spin)=="number","Rotator spin should be number")
5.754 + assert(t.spin>=0 and t.spin<=1.0,"Rotator spin out of range 0-1")
5.755 + w:set_spin(t.spin)
5.756 + end
5.757 +
5.758 + t._wdg,w.type=w,"rotator"
5.759 + Window:_Separators(t)
5.760 + return w
5.761 +end
5.762 +
5.763 +-----------------------------------------------------------------
5.764 +--! item = "Translator{params}", group = "Window",
5.765 +--! about=[[ Create a translation widget.
5.766 +--! This creates a pointer arrow widget which can be used to move objects. When
5.767 +--! you click and drag the mouse over the widget, the movement is applied to the matrix
5.768 +--! and any object influenced by the matrix. <br>
5.769 +--! Note: The matrix you attach to the widget must only be used by this widget,
5.770 +--! ie. you cannot manipulate the matrix value as its value is set directly by GLUI. ]],
5.771 +--! params=[[A table containing Translator parameters:
5.772 +--! * parent - parent widget of this Translator.
5.773 +--! * text - the Translator title.
5.774 +--! * value - the Matrix to use (see note above).
5.775 +--! * type - sets the constraints of the movement, ie. "xy", "x", "y" or "z". Default is "xy".
5.776 +--! * line - "|" or "-". See Window:Separators.
5.777 +--! * space - "|" or "-". See Window:Separators.
5.778 +--! * update - Call back function called when value changes. See Window:Upate Callbacks.]],
5.779 +--! returns=[[ A reference to the Rotator. ]],
5.780 +--! eg=[[Translator{ parent=subwin, text="Scene", type=z, value=scene.transMatrix } ]]
5.781 +
5.782 +function Translator(t)
5.783 + Window:_checkBasics("Translator",t)
5.784 + assert(_contains(t.parent.type,{"sub","panel","rollout"}),"Bad parent type")
5.785 +
5.786 + local text = t.text or "<Translator>"
5.787 + local typmap = { xy=GLUI_TRANSLATION_XY, z=GLUI_TRANSLATION_Z,
5.788 + x=GLUI_TRANSLATION_X, y=GLUI_TRANSLATION_Y }
5.789 + local transtype = t.type or "xy" -- get translator type
5.790 + assert(typmap[transtype],"Bad Translator translation type:"..transtype)
5.791 + gluitranstype = typmap[transtype] -- get GLUI type
5.792 +
5.793 + --local val = t.value
5.794 + --assert(val,"Translator has no value to manipulate")
5.795 + --assert(tag(val)==tolua:tag(Matrix),"Rotator value is not a Matrix")
5.796 +
5.797 + local id = Window:_RegisterCB(transtype,t)
5.798 + local w
5.799 +
5.800 + if t.parent.type=="sub" then
5.801 + w = Window.glui:add_translation(text,gluitranstype,0,id,GLUIUpdateCB)
5.802 + else
5.803 + w = Window.glui:add_translation_to_panel(t.parent,
5.804 + gluitranstype,text,0,id,GLUIUpdateCB)
5.805 + end
5.806 +
5.807 + t._wdg,w.type=w,"translator"
5.808 + Window:_Separators(t)
5.809 + return w
5.810 +end
5.811 +
5.812 +-----------------------------------------------------------------
5.813 +--! item = "Rollout{params}", group = "Window",
5.814 +--! about=[[ Create a rollout container.
5.815 +--! This widget is like a Panel except you can open and close it. ]],
5.816 +--! params=[[A table containing Rollout parameters:
5.817 +--! * parent - parent widget of this Rollout.
5.818 +--! * text - the Rollout title.
5.819 +--! * open - sets the initial state of the Rollout, open or closed. Its value
5.820 +--! should be 0 or 1.
5.821 +--! * line - "|" or "-". See Window:Separators.
5.822 +--! * space - "|" or "-". See Window:Separators. ]],
5.823 +--! returns=[[ A reference to the Rollout. ]],
5.824 +--! eg=[[Rollout{ parent=subwin, text="Scene", type=z, value=scene.transMatrix }]]
5.825 +
5.826 +function Rollout(t)
5.827 + -- todo: set_type()
5.828 + Window:_checkBasics("Rollout",t)
5.829 + assert(_contains(t.parent.type,{"sub","panel","rollout"}),"Bad parent type")
5.830 +
5.831 + local text = t.text or "<Rollout>"
5.832 +
5.833 + local opened=0
5.834 + if t.open and t.open~=0 then opened=1 end
5.835 +
5.836 + local w
5.837 + if t.parent.type=="sub" then
5.838 + w = Window.glui:add_rollout(text,opened)
5.839 + else
5.840 + w = Window.glui:add_rollout_to_panel(t.parent,text,opened)
5.841 + end
5.842 +
5.843 + t._wdg,w.type = w,"rollout"
5.844 + return w
5.845 +end
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/source/doris/dorisimage.cpp Wed Nov 04 00:45:28 2009 +0000
6.3 @@ -0,0 +1,476 @@
6.4 +/*
6.5 + copyright (c) 1999-2001 Lev Povalahev
6.6 +
6.7 + Notes about License copied from http://www.uni-karlsruhe.de/~uli2/index.html :-
6.8 +
6.9 + The source code which is written by me is available under the modified BSD lisence.
6.10 + You can download, modify, redistribute the code, for both free and commercial use.
6.11 + However you are required to mention the copyright holder, me. Every file should
6.12 + contain a copyright notice, just make sure you don't remove it, and you basically
6.13 + can do what you want with this code. I'm not responsible for any problems or damage
6.14 + my code may cause. This license only applies to my code. I'm also not responsible
6.15 + for any problems may be caused by the code contributed by others.
6.16 +
6.17 + This code originates from: http://www.uni-karlsruhe.de/~uli2/index.html
6.18 + Modified by Nick Trout 2002.
6.19 +
6.20 + $Id$
6.21 +*/
6.22 +
6.23 +#include <string.h>
6.24 +#include <ctype.h>
6.25 +#include "dorisimage.h"
6.26 +#include "doristga.h"
6.27 +#include "dorisjpg.h"
6.28 +extern "C" {
6.29 +#include "lua.h"
6.30 +}
6.31 +#include "gl/glut.h"
6.32 +#include "gllbuffer.h"
6.33 +
6.34 +typedef unsigned char byte;
6.35 +
6.36 +Image::Image()
6.37 +{
6.38 + m_pixels = 0;
6.39 + unload();
6.40 +}
6.41 +
6.42 +Image::~Image()
6.43 +{
6.44 + if (m_pixels)
6.45 + unload();
6.46 +}
6.47 +
6.48 +bool Image::load(const char *filename)
6.49 +{
6.50 + if (!filename)
6.51 + return false;
6.52 +
6.53 + // get the file extension
6.54 + char ext[8];
6.55 + const char *dot = strrchr(filename, '.');
6.56 + if (!dot)
6.57 + {
6.58 + fprintf(stderr,"Image::Load : No file extension");
6.59 + return false;
6.60 + }
6.61 +
6.62 + // copy and make lower case
6.63 + char *p = ext;
6.64 + while (*dot)
6.65 + *p++ = tolower(*dot++);
6.66 + *p = 0; // terminator. I'll be back!
6.67 +
6.68 + // Do we recognise this extension?
6.69 + if (strcmp(ext,".tga")!=0
6.70 + && strcmp(ext,".jpg")!=0
6.71 + && strcmp(ext,".jpeg")!=0)
6.72 + {
6.73 + fprintf(stderr,"Image::Load : File extension unrecognised: %s\n", ext);
6.74 + return false;
6.75 + }
6.76 +
6.77 + if (strcmp(ext,".tga")==0)
6.78 + {
6.79 + FILE *fh = fopen(filename,"rb");
6.80 + if (!fh)
6.81 + {
6.82 + fprintf(stderr,"Image::Load : Could not open file: %s\n",filename);
6.83 + return false;
6.84 + }
6.85 + FileReader fr(fh);
6.86 + return Image_LoadTga(*this, fr);
6.87 + }
6.88 + else // must be JPEG
6.89 + {
6.90 + return Image_LoadJpeg(*this, filename);
6.91 + }
6.92 +
6.93 + return false;
6.94 +}
6.95 +
6.96 +/** reimplemented from LLoadable */
6.97 +void Image::unload()
6.98 +{
6.99 + if (m_pixels)
6.100 + gllDeleteBuffer(m_pixels); //delete [] m_pixels;
6.101 + m_pixels = 0;
6.102 + m_width = 0;
6.103 + m_height = 0;
6.104 + m_pixelDepth = 0;
6.105 + m_alphaBits = 0;
6.106 + m_type = ImageUndefined;
6.107 +}
6.108 +
6.109 +/** returns the pointer to the pixel buffer */
6.110 +GLLbuffer* Image::getPixels()
6.111 +{
6.112 + return m_pixels;
6.113 +}
6.114 +
6.115 +/** returns the number of alpha bits in the image */
6.116 +int Image::getAlphaBits()
6.117 +{
6.118 + return m_alphaBits;
6.119 +}
6.120 +
6.121 +/** returns the pixel depth */
6.122 +int Image::getPixelDepth()
6.123 +{
6.124 + return m_pixelDepth;
6.125 +}
6.126 +
6.127 +/** returns the width of the image */
6.128 +int Image::getWidth()
6.129 +{
6.130 + return m_width;
6.131 +}
6.132 +
6.133 +/** returns the height of teh image */
6.134 +int Image::getHeight()
6.135 +{
6.136 + return m_height;
6.137 +}
6.138 +
6.139 +/** returns the image type */
6.140 +Image::ImageType Image::getImageType()
6.141 +{
6.142 + return m_type;
6.143 +}
6.144 +
6.145 +void Image::greyscale()
6.146 +{
6.147 + if ((!m_pixels) ||
6.148 + (m_pixelDepth == 0) ||
6.149 + (m_width == 0) ||
6.150 + (m_height == 0))
6.151 + {
6.152 + fprintf(stderr,"Image::Greyscale: the image is not loaded or has no dimentions\n");
6.153 + return;
6.154 + }
6.155 + if ((m_type != ImageRGBA) && (m_type != ImageRGB))
6.156 + {
6.157 + fprintf(stderr,"Image::Greyscale: only can greyscale 24 and 32 bit colour images\n");
6.158 + return;
6.159 + }
6.160 + GLLbuffer *buf, *t;
6.161 + buf = gllCreateBuffer2(m_width*m_height,GL_BYTE); //(byte*) malloc(m_width*m_height);
6.162 + float RedBandWeight = 0.2125f;
6.163 + float GreenBandWeight = 0.7154f;
6.164 + float BlueBandWeight = 0.0721f;
6.165 + for (int w=0; w<m_width; w++)
6.166 + for (int h=0; h<m_height; h++)
6.167 + {
6.168 + t = getPixel(w, h);
6.169 + buf[h*m_width + w] = (byte)(t[0]*RedBandWeight +
6.170 + t[1]*GreenBandWeight +
6.171 + t[2]*BlueBandWeight);
6.172 + }
6.173 + gllDeleteBuffer(m_pixels); //delete [] m_pixels;// free(m_pixels);
6.174 + m_pixels = buf;
6.175 + m_type = ImageGrayscale;
6.176 + m_pixelDepth = 8;
6.177 + m_alphaBits = 0;
6.178 +}
6.179 +
6.180 +void Image::convertToNormalMap()
6.181 +{
6.182 + printf("Image::ConvertToNormalMap() not implemented yet!\n");
6.183 +#if 0
6.184 + if (!m_loaded) return;
6.185 + if (m_type != ImageGrayscale)
6.186 + Greyscale();
6.187 + byte* t1, *t2, *t3;
6.188 + LVector3 vec1, vec2, vec3, vec4, vec5, res;
6.189 + const float scale = 3.0f;
6.190 + byte* buf = (byte*)malloc(m_width*m_height*4);
6.191 + for (int w=0; w<m_width; w++)
6.192 + for (int h=0; h<m_height; h++)
6.193 + {
6.194 +
6.195 + // first triangle + +
6.196 + t1 = GetPixel(w, h);
6.197 + t2 = GetPixel(w+1, h);
6.198 + t3 = GetPixel(w, h+1);
6.199 +
6.200 + vec1.x = (float)w;
6.201 + vec1.y = (float)h;
6.202 + vec1.z = t3[0]/scale;
6.203 +
6.204 + vec2.x = (float)(w+1);
6.205 + vec2.y = (float)h;
6.206 + vec2.z = t2[0]/scale;
6.207 +
6.208 + vec3.x = (float)w;
6.209 + vec3.y = (float)(h+1);
6.210 + vec3.z = t1[0]/scale;
6.211 +
6.212 + vec4 = vec1 - vec2;
6.213 + vec5 = vec1 - vec3;
6.214 +
6.215 + res = vec4.CrossProduct(vec5);
6.216 +
6.217 + //res.Normalize();
6.218 +
6.219 + // second triangle + -
6.220 + t1 = GetPixel(w, h);
6.221 + t2 = GetPixel(w+1, h);
6.222 + t3 = GetPixel(w, h-1);
6.223 +
6.224 + vec1.x = (float)w;
6.225 + vec1.y = (float)h;
6.226 + vec1.z = t3[0]/scale;
6.227 +
6.228 + vec2.x = (float)(w+1);
6.229 + vec2.y = (float)h;
6.230 + vec2.z = t2[0]/scale;
6.231 +
6.232 + vec3.x = (float)w;
6.233 + vec3.y = (float)(h-1);
6.234 + vec3.z = t1[0]/scale;
6.235 +
6.236 + vec4 = vec1 - vec3;
6.237 + vec5 = vec1 - vec2;
6.238 +
6.239 + vec1 = vec4.CrossProduct(vec5);
6.240 + //vec1.Normalize();
6.241 +
6.242 + res += vec1;
6.243 +
6.244 + // third triangle - +
6.245 + t1 = GetPixel(w, h);
6.246 + t2 = GetPixel(w-1, h);
6.247 + t3 = GetPixel(w, h+1);
6.248 +
6.249 + vec1.x = (float)w;
6.250 + vec1.y = (float)h;
6.251 + vec1.z = t3[0]/scale;
6.252 +
6.253 + vec2.x = (float)(w-1);
6.254 + vec2.y = (float)h;
6.255 + vec2.z = t2[0]/scale;
6.256 +
6.257 + vec3.x = (float)w;
6.258 + vec3.y = (float)(h+1);
6.259 + vec3.z = t1[0]/scale;
6.260 +
6.261 + vec4 = vec1 - vec3;
6.262 + vec5 = vec1 - vec2;
6.263 +
6.264 + vec1 = vec4.CrossProduct(vec5);
6.265 + //vec1.Normalize();
6.266 +
6.267 + res += vec1;
6.268 +
6.269 + // fourth triangle - -
6.270 + t1 = GetPixel(w, h);
6.271 + t2 = GetPixel(w-1, h);
6.272 + t3 = GetPixel(w, h-1);
6.273 +
6.274 + vec1.x = (float)w;
6.275 + vec1.y = (float)h;
6.276 + vec1.z = t3[0]/scale;
6.277 +
6.278 + vec2.x = (float)(w-1);
6.279 + vec2.y = (float)h;
6.280 + vec2.z = t2[0]/scale;
6.281 +
6.282 + vec3.x = (float)w;
6.283 + vec3.y = (float)(h-1);
6.284 + vec3.z = t1[0]/scale;
6.285 +
6.286 + vec4 = vec1 - vec2;
6.287 + vec5 = vec1 - vec3;
6.288 +
6.289 + vec1 = vec4.CrossProduct(vec5);
6.290 + //vec1.Normalize();
6.291 +
6.292 + res += vec1;
6.293 + res.Normalize();
6.294 +
6.295 + res.x = 128 + 127*res.x;
6.296 + res.y = 128 + 127*res.y;
6.297 + res.z = 128 + 127*res.z;
6.298 +
6.299 + buf[h*4*m_width + w*4] = (byte)res.x;
6.300 + buf[h*4*m_width + w*4+1] = (byte)res.y;
6.301 + buf[h*4*m_width + w*4+2] = (byte)res.z;
6.302 + buf[h*4*m_width + w*4+3] = 255;
6.303 + }
6.304 + free(m_pixels);
6.305 + m_pixels = buf;
6.306 + m_type = ImageRGBA;
6.307 + m_pixelDepth = 32;
6.308 + m_alphaBits = 8;
6.309 +#endif
6.310 +}
6.311 +
6.312 +void Image::scaleDownNormalMap()
6.313 +{
6.314 + printf("Image::ScaleDownNormalMap() not implemented yet!\n");
6.315 +#if 0
6.316 + if (m_type != ImageRGBA)
6.317 + {
6.318 + fprintf(stderr,"Image::ScaleDownNormalMap: image is not a normal map\n");
6.319 + return;
6.320 + }
6.321 + if (( m_width==1) && (m_height == 2))
6.322 + return;
6.323 + int new_w = m_width/2;
6.324 + int new_h = m_height/2;
6.325 + LVector3 v[6];
6.326 + if (new_w == 0)
6.327 + new_w = 1;
6.328 + if (new_h == 0)
6.329 + new_h = 1;
6.330 + int scX = m_width/new_w;
6.331 + int scY = m_height/new_h;
6.332 + // allocate memory for the new image (the image is RGBA,
6.333 + // means each pixel takes 4 bytes
6.334 + GLLbuffer *buf = gllCreateBuffer2(new_w*new_h*4, GL_BYTE); // (byte*) malloc(new_w*new_h*4);
6.335 + GLLbuffer *t;
6.336 + const float one255 = 1.0f/255.0f;
6.337 + const float one127 = 1.0f/127.0f;
6.338 + float len;
6.339 + for (int w=0; w<new_w; w++)
6.340 + for (int h=0; h<new_h; h++)
6.341 + {
6.342 + t = GetPixel(w*scX, h*scY);
6.343 + v[0].x = (t[0]-128)*one127;
6.344 + v[0].y = (t[1]-128)*one127;
6.345 + v[0].z = (t[2]-128)*one127;
6.346 + v[0] *= (t[3])*one255;
6.347 +
6.348 + t = GetPixel(w*scX+1, h*scY);
6.349 + v[1].x = (t[0]-128)*one127;
6.350 + v[1].y = (t[1]-128)*one127;
6.351 + v[1].z = (t[2]-128)*one127;
6.352 + v[1] *= (t[3])*one255;
6.353 +
6.354 + t = GetPixel(w*scX-1, h*scY);
6.355 + v[2].x = (t[0]-128)*one127;
6.356 + v[2].y = (t[1]-128)*one127;
6.357 + v[2].z = (t[2]-128)*one127;
6.358 + v[2] *= (t[3])*one255;
6.359 +
6.360 + t = GetPixel(w*scX, h*scY+1);
6.361 + v[3].x = (t[0]-128)*one127;
6.362 + v[3].y = (t[1]-128)*one127;
6.363 + v[3].z = (t[2]-128)*one127;
6.364 + v[3] *= (t[3])*one255;
6.365 +
6.366 + t = GetPixel(w*scX, h*scY-1);
6.367 + v[4].x = (t[0]-128)*one127;
6.368 + v[4].y = (t[1]-128)*one127;
6.369 + v[4].z = (t[2]-128)*one127;
6.370 + v[4] *= (t[3])*one255;
6.371 +
6.372 + v[5] = v[0] + v[1] + v[2] + v[3] + v[4];
6.373 + len = v[5].Length();
6.374 + v[5].Normalize();
6.375 +
6.376 + v[5].x = 128 + 127*v[5].x;
6.377 + v[5].y = 128 + 127*v[5].y;
6.378 + v[5].z = 128 + 127*v[5].z;
6.379 +
6.380 + len /= 5.0f;
6.381 + if (len>1)
6.382 + len = 255;
6.383 + else
6.384 + len *= 255;
6.385 +
6.386 + buf[(h*new_w + w)*4] = (byte)v[5].x;
6.387 + buf[(h*new_w + w)*4+1] = (byte)v[5].y;
6.388 + buf[(h*new_w + w)*4+2] = (byte)v[5].z;
6.389 + buf[(h*new_w + w)*4+3] = (byte)len;
6.390 + }
6.391 + free(m_pixels);
6.392 + m_pixels = buf;
6.393 + m_width = new_w;
6.394 + m_height = new_h;
6.395 +#endif
6.396 +}
6.397 +
6.398 +inline byte* Image::getPixel(int w, int h)
6.399 +{
6.400 + if (!m_pixels)
6.401 + return 0;
6.402 + if (w<0)
6.403 + w = 0;
6.404 + if (w>=m_width)
6.405 + w = m_width-1;
6.406 + if (h<0)
6.407 + h = 0;
6.408 + if (h>=m_height)
6.409 + h = m_height-1;
6.410 + return (unsigned char*)m_pixels + ((h*m_width+w)*(m_pixelDepth>>3));
6.411 +}
6.412 +
6.413 +void Image::smooth()
6.414 +{
6.415 + printf("Image::Smooth() not implemented yet!\n");
6.416 +#if 0
6.417 +// the convolution applied to the image:
6.418 +// 0, 0, 1, 1, 1, 0, 0,
6.419 +// 0, 1, 2, 4, 2, 1, 0,
6.420 +// 1, 2, 4, 16,4, 2, 1,
6.421 +// 1, 4, 16,64,16,4, 1
6.422 +// 1, 2, 4, 16,4, 2, 1
6.423 +// 0, 1, 2, 4, 2, 1, 0
6.424 +// 0, 0, 1, 1, 1, 0, 0
6.425 +
6.426 + if (!m_pixels) return;
6.427 + byte *buf = (byte*) malloc(m_width*m_height*m_pixelDepth/8);
6.428 + int accum;
6.429 + for (int i=0; i<m_pixelDepth/8; i++)
6.430 + {
6.431 + for (int w = 0; w<m_width; w++)
6.432 + for (int h=0; h<m_height; h++)
6.433 + {
6.434 + accum = 64*GetPixel(w, h)[i] +
6.435 + 16*GetPixel(w+1, h)[i] +
6.436 + 16*GetPixel(w+1, h+1)[i] +
6.437 + 16*GetPixel(w, h+1)[i] +
6.438 + 16*GetPixel(w+1, h+1)[i] +
6.439 + 4*GetPixel(w+1, h+1)[i] +
6.440 + 4*GetPixel(w+1, h-1)[i] +
6.441 + 4*GetPixel(w-1, h-1)[i] +
6.442 + 4*GetPixel(w-1, h+1)[i] +
6.443 + 4*GetPixel(w+2, h)[i] +
6.444 + 4*GetPixel(w-2, h)[i] +
6.445 + 4*GetPixel(w, h+2)[i] +
6.446 + 4*GetPixel(w, h-2)[i] +
6.447 + 2*GetPixel(w+1, h+2)[i] +
6.448 + 2*GetPixel(w-1, h+2)[i] +
6.449 + 2*GetPixel(w+2, h+1)[i] +
6.450 + 2*GetPixel(w-2, h+1)[i] +
6.451 + 2*GetPixel(w+1, h-2)[i] +
6.452 + 2*GetPixel(w-1, h-2)[i] +
6.453 + 2*GetPixel(w+2, h-1)[i] +
6.454 + 2*GetPixel(w-2, h-1)[i] +
6.455 + GetPixel(w+3, h)[i] +
6.456 + GetPixel(w-3, h)[i] +
6.457 + GetPixel(w+3, h+1)[i] +
6.458 + GetPixel(w-3, h+1)[i] +
6.459 + GetPixel(w+3, h-1)[i] +
6.460 + GetPixel(w-3, h-1)[i] +
6.461 + GetPixel(w, h+3)[i] +
6.462 + GetPixel(w, h-3)[i] +
6.463 + GetPixel(w+1, h+3)[i] +
6.464 + GetPixel(w+1, h-3)[i] +
6.465 + GetPixel(w-1, h+3)[i] +
6.466 + GetPixel(w-1, h-3)[i] +
6.467 + GetPixel(w+2, h+2)[i] +
6.468 + GetPixel(w+2, h-2)[i] +
6.469 + GetPixel(w-2, h+2)[i] +
6.470 + GetPixel(w-2, h-2)[i];
6.471 +
6.472 + buf[(h*m_width+w)*m_pixelDepth/8+i] = (byte)(accum/192);
6.473 +
6.474 + }
6.475 + }
6.476 + free(m_pixels);
6.477 + m_pixels = buf;
6.478 +#endif
6.479 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/source/doris/dorisimage.h Wed Nov 04 00:45:28 2009 +0000
7.3 @@ -0,0 +1,116 @@
7.4 +/*
7.5 + Copyright (c) 1999-2001 Lev Povalahev
7.6 +
7.7 + Notes about License copied from http://www.uni-karlsruhe.de/~uli2/index.html :-
7.8 +
7.9 + The source code which is written by me is available under the modified BSD lisence.
7.10 + You can download, modify, redistribute the code, for both free and commercial use.
7.11 + However you are required to mention the copyright holder, me. Every file should
7.12 + contain a copyright notice, just make sure you don't remove it, and you basically
7.13 + can do what you want with this code. I'm not responsible for any problems or damage
7.14 + my code may cause. This license only applies to my code. I'm also not responsible
7.15 + for any problems may be caused by the code contributed by others.
7.16 +
7.17 + This code originates from: http://www.uni-karlsruhe.de/~uli2/index.html
7.18 + Modified by Nick Trout 2002.
7.19 +
7.20 + $Id$
7.21 +*/
7.22 +
7.23 +#ifndef DORISIMAGE_H
7.24 +#define DORISIMAGE_H
7.25 +
7.26 +#include <stdio.h>
7.27 +
7.28 +#ifndef gllbuffer_h
7.29 +typedef unsigned char GLLbuffer;
7.30 +#endif
7.31 +
7.32 +
7.33 +// Simple FILE wrapper class
7.34 +class FileReader
7.35 +{
7.36 + FILE *m_file;
7.37 +public:
7.38 + FileReader(FILE *f) : m_file(f) {}
7.39 + bool Read(void *ptr, unsigned int size, unsigned int count)
7.40 + {
7.41 + return fread(ptr, size, count, m_file) == size*count;
7.42 + }
7.43 + char ReadChar()
7.44 + {
7.45 + return fgetc(m_file);
7.46 + }
7.47 + short ReadShort()
7.48 + {
7.49 + short s;
7.50 + fread(&s, sizeof(short), 1, m_file);
7.51 + return s;
7.52 + }
7.53 + void Seek(int i)
7.54 + {
7.55 + fseek(m_file,i,SEEK_CUR);
7.56 + }
7.57 +};
7.58 +
7.59 +
7.60 +class Image
7.61 +{
7.62 + friend bool Image_LoadTga(Image &img, FileReader &s);
7.63 + friend bool Image_LoadJpeg(Image &img, const char *filename);
7.64 +
7.65 +public:
7.66 + enum ImageType { ImageUndefined, ImageRGB, ImageRGBA, ImageGrayscale };
7.67 +
7.68 + Image();
7.69 + virtual ~Image();
7.70 +
7.71 + bool load(const char *filename);
7.72 + void unload();
7.73 +
7.74 + /** returns the number of alpha bits in the image */
7.75 + int getAlphaBits();
7.76 + /** returns the pointer to the pixel buffer */
7.77 + GLLbuffer* getPixels();
7.78 + /** returns the height of the image */
7.79 + int getHeight();
7.80 + /** returns the width of the image */
7.81 + int getWidth();
7.82 + /** returns the pixel depth */
7.83 + int getPixelDepth();
7.84 + /** returns the image type */
7.85 + ImageType getImageType();
7.86 +
7.87 + // returns a pixel at a given position
7.88 + inline unsigned char* getPixel(int w, int h);
7.89 +
7.90 + // converts the image 8 bit greyscale image
7.91 + void greyscale();
7.92 + // converts teh image to the normal map as needed by per-pixel lighting
7.93 + void convertToNormalMap();
7.94 + // scales the normal map down by 1/2 (used for mipmapping)
7.95 + void scaleDownNormalMap();
7.96 + // smoothes the image
7.97 + void smooth();
7.98 +
7.99 +protected: // Protected attributes
7.100 +
7.101 + /** this is the pixel buffer -> the image */
7.102 + //unsigned char *m_pixels;
7.103 + GLLbuffer *m_pixels;
7.104 +
7.105 + /** the pixel depth of the image, including the alpha bits */
7.106 + int m_pixelDepth;
7.107 + /** the depth of the alpha bitplane */
7.108 + int m_alphaBits;
7.109 + /** the image height */
7.110 + int m_height;
7.111 + /** the width of the image */
7.112 + int m_width;
7.113 + /** image type, either rgb, rgba or greyscale */
7.114 + ImageType m_type;
7.115 +};
7.116 +
7.117 +#endif
7.118 +
7.119 +
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/source/doris/dorisjpg.cpp Wed Nov 04 00:45:28 2009 +0000
8.3 @@ -0,0 +1,295 @@
8.4 +/*
8.5 + Purpose: Doris JPEG handling Code.
8.6 +
8.7 + Doris is free software; you can redistribute it and/or modify
8.8 + it under the terms of the GNU General Public License as published by
8.9 + the Free Software Foundation; either version 2 of the License, or
8.10 + (at your option) any later version.
8.11 +
8.12 + Doris is distributed in the hope that it will be useful,
8.13 + but WITHOUT ANY WARRANTY; without even the implied warranty of
8.14 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8.15 + GNU General Public License for more details.
8.16 +
8.17 + You should have received a copy of the GNU General Public License
8.18 + along with Doris; if not, write to the Free Software
8.19 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8.20 +
8.21 + $Id$
8.22 +*/
8.23 +
8.24 +#include <string.h>
8.25 +#include <setjmp.h>
8.26 +#include "dorisjpg.h"
8.27 +extern "C" {
8.28 +#include "jpeglib.h"
8.29 +}
8.30 +
8.31 +// The following code originates from "example.c" in the IJG jpeg-6b library.
8.32 +
8.33 +
8.34 +/******************** JPEG DECOMPRESSION SAMPLE INTERFACE *******************/
8.35 +
8.36 +/* This half of the example shows how to read data from the JPEG decompressor.
8.37 + * It's a bit more refined than the above, in that we show:
8.38 + * (a) how to modify the JPEG library's standard error-reporting behavior;
8.39 + * (b) how to allocate workspace using the library's memory manager.
8.40 + *
8.41 + * Just to make this example a little different from the first one, we'll
8.42 + * assume that we do not intend to put the whole image into an in-memory
8.43 + * buffer, but to send it line-by-line someplace else. We need a one-
8.44 + * scanline-high JSAMPLE array as a work buffer, and we will let the JPEG
8.45 + * memory manager allocate it for us. This approach is actually quite useful
8.46 + * because we don't need to remember to deallocate the buffer separately: it
8.47 + * will go away automatically when the JPEG object is cleaned up.
8.48 + */
8.49 +
8.50 +
8.51 +/*
8.52 + * ERROR HANDLING:
8.53 + *
8.54 + * The JPEG library's standard error handler (jerror.c) is divided into
8.55 + * several "methods" which you can override individually. This lets you
8.56 + * adjust the behavior without duplicating a lot of code, which you might
8.57 + * have to update with each future release.
8.58 + *
8.59 + * Our example here shows how to override the "error_exit" method so that
8.60 + * control is returned to the library's caller when a fatal error occurs,
8.61 + * rather than calling exit() as the standard error_exit method does.
8.62 + *
8.63 + * We use C's setjmp/longjmp facility to return control. This means that the
8.64 + * routine which calls the JPEG library must first execute a setjmp() call to
8.65 + * establish the return point. We want the replacement error_exit to do a
8.66 + * longjmp(). But we need to make the setjmp buffer accessible to the
8.67 + * error_exit routine. To do this, we make a private extension of the
8.68 + * standard JPEG error handler object. (If we were using C++, we'd say we
8.69 + * were making a subclass of the regular error handler.)
8.70 + *
8.71 + * Here's the extended error handler struct:
8.72 + */
8.73 +
8.74 +struct my_error_mgr {
8.75 + struct jpeg_error_mgr pub; /* "public" fields */
8.76 +
8.77 + jmp_buf setjmp_buffer; /* for return to caller */
8.78 +};
8.79 +
8.80 +typedef struct my_error_mgr * my_error_ptr;
8.81 +
8.82 +/*
8.83 + * Here's the routine that will replace the standard error_exit method:
8.84 + */
8.85 +
8.86 +METHODDEF(void)
8.87 +my_error_exit (j_common_ptr cinfo)
8.88 +{
8.89 + /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */
8.90 + my_error_ptr myerr = (my_error_ptr) cinfo->err;
8.91 +
8.92 + /* Always display the message. */
8.93 + /* We could postpone this until after returning, if we chose. */
8.94 + (*cinfo->err->output_message) (cinfo);
8.95 +
8.96 + /* Return control to the setjmp point */
8.97 + longjmp(myerr->setjmp_buffer, 1);
8.98 +}
8.99 +
8.100 +
8.101 +/*
8.102 + * Sample routine for JPEG decompression. We assume that the source file name
8.103 + * is passed in. We want to return 1 on success, 0 on error.
8.104 +GLOBAL(int)
8.105 +read_JPEG_file (char * filename)
8.106 + */
8.107 +
8.108 +bool Image_LoadJpeg(Image &image, const char *filename)
8.109 +{
8.110 + /* This struct contains the JPEG decompression parameters and pointers to
8.111 + * working space (which is allocated as needed by the JPEG library).
8.112 + */
8.113 + struct jpeg_decompress_struct cinfo;
8.114 + /* We use our private extension JPEG error handler.
8.115 + * Note that this struct must live as long as the main JPEG parameter
8.116 + * struct, to avoid dangling-pointer problems.
8.117 + */
8.118 + struct my_error_mgr jerr;
8.119 + /* More stuff */
8.120 + FILE * infile; /* source file */
8.121 + JSAMPARRAY buffer; /* Output row buffer */
8.122 + int row_stride; /* physical row width in output buffer */
8.123 +
8.124 + /* In this example we want to open the input file before doing anything else,
8.125 + * so that the setjmp() error recovery below can assume the file is open.
8.126 + * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that
8.127 + * requires it in order to read binary files.
8.128 + */
8.129 +
8.130 + if ((infile = fopen(filename, "rb")) == NULL) {
8.131 + fprintf(stderr, "Doris JPEG reader: Can't open %s\n", filename);
8.132 + return false;
8.133 + }
8.134 +
8.135 + /* Step 1: allocate and initialize JPEG decompression object */
8.136 +
8.137 + /* We set up the normal JPEG error routines, then override error_exit. */
8.138 + cinfo.err = jpeg_std_error(&jerr.pub);
8.139 + jerr.pub.error_exit = my_error_exit;
8.140 + /* Establish the setjmp return context for my_error_exit to use. */
8.141 + if (setjmp(jerr.setjmp_buffer)) {
8.142 + /* If we get here, the JPEG code has signaled an error.
8.143 + * We need to clean up the JPEG object, close the input file, and return.
8.144 + */
8.145 + jpeg_destroy_decompress(&cinfo);
8.146 + fclose(infile);
8.147 + return false;
8.148 + }
8.149 + /* Now we can initialize the JPEG decompression object. */
8.150 + jpeg_create_decompress(&cinfo);
8.151 +
8.152 + /* Step 2: specify data source (eg, a file) */
8.153 +
8.154 + jpeg_stdio_src(&cinfo, infile);
8.155 +
8.156 + /* Step 3: read file parameters with jpeg_read_header() */
8.157 +
8.158 + (void) jpeg_read_header(&cinfo, TRUE);
8.159 + /* We can ignore the return value from jpeg_read_header since
8.160 + * (a) suspension is not possible with the stdio data source, and
8.161 + * (b) we passed TRUE to reject a tables-only JPEG file as an error.
8.162 + * See libjpeg.doc for more info.
8.163 + */
8.164 +
8.165 + // Set our Doris Image info:
8.166 + // Image type:
8.167 + image.m_type = Image::ImageRGB;
8.168 + image.m_pixelDepth = 24;
8.169 + image.m_alphaBits = 0;
8.170 +
8.171 + /*
8.172 + The output colour space might not necessarily be RGB. i.e from
8.173 + libjpeg.doc (NDT) :-
8.174 +
8.175 + J_COLOR_SPACE out_color_space
8.176 + Output color space. jpeg_read_header() sets an appropriate default
8.177 + based on jpeg_color_space; typically it will be RGB or grayscale.
8.178 + The application can change this field to request output in a different
8.179 + colorspace. For example, set it to JCS_GRAYSCALE to get grayscale
8.180 + output from a color file. (This is useful for previewing: grayscale
8.181 + output is faster than full color since the color components need not
8.182 + be processed.) Note that not all possible color space transforms are
8.183 + currently implemented; you may need to extend jdcolor.c if you want an
8.184 + unusual conversion.
8.185 + */
8.186 + cinfo.out_color_space = JCS_RGB;
8.187 +
8.188 + // Image size:
8.189 + image.m_width = cinfo.image_width;
8.190 + image.m_height = cinfo.image_height;
8.191 +
8.192 + unsigned int dorisbuffsize = image.m_width*image.m_height*(image.m_pixelDepth/8);
8.193 + image.m_pixels = new unsigned char[dorisbuffsize];
8.194 +
8.195 +
8.196 + /* Step 4: set parameters for decompression */
8.197 +
8.198 + /* In this example, we don't need to change any of the defaults set by
8.199 + * jpeg_read_header(), so we do nothing here.
8.200 + */
8.201 +
8.202 + /* Step 5: Start decompressor */
8.203 +
8.204 + (void) jpeg_start_decompress(&cinfo);
8.205 + /* We can ignore the return value since suspension is not possible
8.206 + * with the stdio data source.
8.207 + */
8.208 +
8.209 + /* We may need to do some setup of our own at this point before reading
8.210 + * the data. After jpeg_start_decompress() we have the correct scaled
8.211 + * output image dimensions available, as well as the output colormap
8.212 + * if we asked for color quantization.
8.213 + * In this example, we need to make an output work buffer of the right size.
8.214 + */
8.215 + /* JSAMPLEs per row in output buffer */
8.216 + row_stride = cinfo.output_width * cinfo.output_components;
8.217 + /* Make a one-row-high sample array that will go away when done with image */
8.218 + buffer = (*cinfo.mem->alloc_sarray)
8.219 + ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
8.220 +