Panagiotis Christopoulos Charitos 15 vuotta sitten
vanhempi
sitoutus
97a21a39ce
10 muutettua tiedostoa jossa 449 lisäystä ja 466 poistoa
  1. 17 3
      build/README
  2. 340 384
      build/debug/Makefile
  3. 2 2
      build/debug/gen.cfg.py
  4. 18 0
      build/download-and-build-externals.sh
  5. 21 17
      build/genmakefile.py
  6. 27 27
      src/Main.cpp
  7. 4 11
      src/Util/App.cpp
  8. 1 1
      src/Util/App.h
  9. 15 17
      src/Util/Input.cpp
  10. 4 4
      src/Util/Input.h

+ 17 - 3
build/README

@@ -8,7 +8,8 @@ build system that generates GNU makefiles.
 
 
 	AnKi requires a few up to date versions of some libraries. The libraries are:
 	AnKi requires a few up to date versions of some libraries. The libraries are:
 	- Bullet Physics
 	- Bullet Physics
-	- SDL 1.3
+	- SDL ver 1.3
+	- GLEW
 
 
 	So before generating makefiles or building AnKi you have to download from
 	So before generating makefiles or building AnKi you have to download from
 	their repositories and build the above libraries. Instructions follow:
 	their repositories and build the above libraries. Instructions follow:
@@ -39,6 +40,19 @@ build system that generates GNU makefiles.
 	5) ./autogen.sh
 	5) ./autogen.sh
 	6) ./configure
 	6) ./configure
 	7) make
 	7) make
+	
+
+1.3) GLEW
+
+	The latest GLEW provides us with OpenGL 3 and 4 extensions. Needs SVN and a 
+	Unix environment (for step 5).
+	
+	1) Go to the root AnKi path (where src, shaders and blenderscripts are)
+	2) cd ..
+	3) svn co https://glew.svn.sourceforge.net/svnroot/glew/trunk/glew glew
+	4) cd glew
+	5) make extensions
+	6) make
 
 
 
 
 2) Generating makefiles and building AnKi
 2) Generating makefiles and building AnKi
@@ -48,11 +62,11 @@ build system that generates GNU makefiles.
 	generate the makefile for the debug target (for example) do the following:
 	generate the makefile for the debug target (for example) do the following:
 
 
 	1) cd <path to anki>/build/debug
 	1) cd <path to anki>/build/debug
-	3) ../genmakefile.py
+	2) ../genmakefile.py
 	
 	
 	Now there is an updated "Makefile". To build just type:
 	Now there is an updated "Makefile". To build just type:
 	
 	
-	1) make
+	3) make
 
 
 	And the build process will begin. 
 	And the build process will begin. 
 
 

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 340 - 384
build/debug/Makefile


+ 2 - 2
build/debug/gen.cfg.py

@@ -4,10 +4,10 @@ includePaths = list(sourcePaths)
 #includePaths.extend( [ "../../../bullet_svn/src/", "/usr/include/SDL" ] )
 #includePaths.extend( [ "../../../bullet_svn/src/", "/usr/include/SDL" ] )
 includePaths.extend( [ "../../../bullet_svn/src/", "../../../SDL-hg/include", "../../glew/include" ] )
 includePaths.extend( [ "../../../bullet_svn/src/", "../../../SDL-hg/include", "../../glew/include" ] )
 
 
-precompiledHeaders = []
+precompiledHeaders = [ "../../src/Util/Common.h" ]
 executableName = "AnKi.bin"
 executableName = "AnKi.bin"
 compiler = "g++"
 compiler = "g++"
 commonFlags = ""
 commonFlags = ""
 compilerFlags = "-c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -pipe -O0 -g3 -pg -fsingle-precision-constant -D_DEBUG_ -D_TERMINAL_COLORING__ -DPLATFORM=LINUX -DREVISION=\\\"`svnversion -c ../..`\\\" "
 compilerFlags = "-c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -pipe -O0 -g3 -pg -fsingle-precision-constant -D_DEBUG_ -D_TERMINAL_COLORING__ -DPLATFORM=LINUX -DREVISION=\\\"`svnversion -c ../..`\\\" "
-precompiledHeadersFlags = "-x c++-header"
+precompiledHeadersFlags = ""
 linkerFlags = "-rdynamic -L../../../SDL-hg/build/.libs -L../../../glew/lib -L../../../bullet_svn/src/BulletSoftBody -L../../../bullet_svn/src/BulletDynamics -L../../../bullet_svn/src/BulletCollision -L../../../bullet_svn/src/LinearMath -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lSDL_image -lGLU -lSDL -Wl,-Bdynamic -lGL -ljpeg -lpng -ltiff" # a few libs are now static
 linkerFlags = "-rdynamic -L../../../SDL-hg/build/.libs -L../../../glew/lib -L../../../bullet_svn/src/BulletSoftBody -L../../../bullet_svn/src/BulletDynamics -L../../../bullet_svn/src/BulletCollision -L../../../bullet_svn/src/LinearMath -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lSDL_image -lGLU -lSDL -Wl,-Bdynamic -lGL -ljpeg -lpng -ltiff" # a few libs are now static

+ 18 - 0
build/download-and-build-externals.sh

@@ -0,0 +1,18 @@
+#! /bin/bash
+
+cd ../../
+svn checkout http://bullet.googlecode.com/svn/trunk/ bullet_svn
+cd bullet_svn
+cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release
+make
+cd ..
+hg clone http://hg.libsdl.org/SDL SDL-hg
+cd SDL-hg
+./autogen.sh
+./configure
+make
+cd ..
+svn co https://glew.svn.sourceforge.net/svnroot/glew/trunk/glew glew
+cd glew
+make extensions
+make

+ 21 - 17
build/genmakefile.py

@@ -45,7 +45,7 @@ class TargetThread( Thread ):
 		
 		
 	def run( self ):
 	def run( self ):
 		for i in self.range:
 		for i in self.range:
-			source_file = source_files[i]
+			source_file = sourceFiles[i]
 			self.out_str += getCommandOutput( compiler + " -MM " + compilerFlags + " " + source_file.cppFile + " -MT " + source_file.objFile )
 			self.out_str += getCommandOutput( compiler + " -MM " + compilerFlags + " " + source_file.cppFile + " -MT " + source_file.objFile )
 			self.out_str += "\t@echo Compiling " + source_file.cppFile + "...\n"
 			self.out_str += "\t@echo Compiling " + source_file.cppFile + "...\n"
 			self.out_str += "\t@$(CXX) $(INCPATH) $(CFLAGS) " + source_file.cppFile + " -o " + \
 			self.out_str += "\t@$(CXX) $(INCPATH) $(CFLAGS) " + source_file.cppFile + " -o " + \
@@ -117,7 +117,7 @@ exec( compile( source, inputCfgFile, "exec" ) )
 
 
 
 
 # find the cpp files
 # find the cpp files
-source_files = []
+sourceFiles = []
 regexpr = re.compile( sourceFilesRegExpr )
 regexpr = re.compile( sourceFilesRegExpr )
 for sourceDir in sourcePaths:
 for sourceDir in sourcePaths:
 	files = os.listdir( sourceDir )
 	files = os.listdir( sourceDir )
@@ -131,19 +131,23 @@ for sourceDir in sourcePaths:
 		sfile.objFile = fname_wo_ext + ".o"
 		sfile.objFile = fname_wo_ext + ".o"
 		
 		
 		# search all the source files and resolve conflicts in .o
 		# search all the source files and resolve conflicts in .o
-		for sfile1 in source_files:
+		for sfile1 in sourceFiles:
 			if sfile1.objFile == sfile.objFile:
 			if sfile1.objFile == sfile.objFile:
 				print( "There is a naming conflict between \"" + sfile1.cppFile + "\" and \"" + sfile.cppFile + "\" but dont worry." )
 				print( "There is a naming conflict between \"" + sfile1.cppFile + "\" and \"" + sfile.cppFile + "\" but dont worry." )
 				random.seed()
 				random.seed()
 				sfile.objFile = str(random.randint(1,99)) + "." + sfile.objFile;
 				sfile.objFile = str(random.randint(1,99)) + "." + sfile.objFile;
 	
 	
-		source_files.append( sfile )
+		sourceFiles.append( sfile )
 	
 	
 
 
 # now the precompiled headers
 # now the precompiled headers
-ph_files = []
+phFiles = []
 for header in precompiledHeaders:
 for header in precompiledHeaders:
-	ph_files.append( SourceFile( header ) )
+	sFile = SourceFile()
+	(fnameWoExt, ext) = os.path.splitext( header )
+	sFile.cppFile = header
+	sFile.objFile = fnameWoExt + ".gch"
+	phFiles.append( sFile )
 
 
 
 
 # build the string
 # build the string
@@ -163,18 +167,18 @@ for path in includePaths:
 masterStr += "\n"
 masterStr += "\n"
 
 
 masterStr += "SOURCES = "
 masterStr += "SOURCES = "
-for source_file in source_files:
+for source_file in sourceFiles:
 	masterStr += source_file.cppFile + " "
 	masterStr += source_file.cppFile + " "
 masterStr += "\n"
 masterStr += "\n"
 
 
 masterStr += "OBJECTS = "
 masterStr += "OBJECTS = "
-for source_file in source_files:
+for source_file in sourceFiles:
 	masterStr += source_file.objFile + " "
 	masterStr += source_file.objFile + " "
 masterStr += "\n"
 masterStr += "\n"
 
 
 masterStr += "PRECOMPILED_HEADERS = "
 masterStr += "PRECOMPILED_HEADERS = "
-for header in ph_files:
-	masterStr += header.fname + ".gch "
+for header in phFiles:
+	masterStr += header.objFile
 masterStr += "\n\n"
 masterStr += "\n\n"
 
 
 masterStr += "all: $(PRECOMPILED_HEADERS) $(SOURCES) $(EXECUTABLE)\n\n"
 masterStr += "all: $(PRECOMPILED_HEADERS) $(SOURCES) $(EXECUTABLE)\n\n"
@@ -185,17 +189,17 @@ masterStr += "\t@$(CXX) $(OBJECTS) $(LFLAGS) -o $(EXECUTABLE)\n"
 masterStr += "\t@echo All Done!\n\n"
 masterStr += "\t@echo All Done!\n\n"
 
 
 
 
-for header in ph_files:
-	dependStr = getCommandOutput( compiler + " -MM " + compilerFlags + " " + precompiledHeaders_flags + " " + header.path + "/" + header.fname )
-	masterStr += dependStr.replace( header.fname_wo_ext + ".o", header.fname + ".gch" )
-	masterStr += "\t@echo Pre-compiling header " + header.fname + "...\n"
-	masterStr += "\t@$(CXX) $(INCPATH) $(PHFLAGS) " + header.path + "/" + header.fname + "\n\n"
+for header in phFiles:
+	dependStr = getCommandOutput( compiler + " -MM " + compilerFlags + " " + precompiledHeadersFlags + " " + header.cppFile )
+	#masterStr += dependStr.replace( header.fname_wo_ext + ".o", header.fname + ".gch" )
+	masterStr += "\t@echo Pre-compiling header " + header.cppFile + "...\n"
+	masterStr += "\t@$(CXX) $(INCPATH) $(PHFLAGS) " + header.objFile + "\n\n"
 
 
 
 
 # write source file target
 # write source file target
 threadsNum = os.sysconf('SC_NPROCESSORS_ONLN')
 threadsNum = os.sysconf('SC_NPROCESSORS_ONLN')
 print( "I will invoke %d threads to make the dependencies..." % threadsNum )
 print( "I will invoke %d threads to make the dependencies..." % threadsNum )
-num = len(source_files);
+num = len(sourceFiles);
 itemsPerThread = num // threadsNum;
 itemsPerThread = num // threadsNum;
 
 
 for i in range(0, threadsNum):
 for i in range(0, threadsNum):
@@ -214,7 +218,7 @@ for thread in threadList:
 for thread in threadList:
 for thread in threadList:
 	masterStr += thread.out_str
 	masterStr += thread.out_str
 
 
-#for source_file in source_files:	
+#for source_file in sourceFiles:	
 	#masterStr += source_file.fname_wo_ext + ".o: " + source_file.path + source_file.fname_wo_ext + ".cpp"
 	#masterStr += source_file.fname_wo_ext + ".o: " + source_file.path + source_file.fname_wo_ext + ".cpp"
 	#masterStr += getCommandOutput( compiler + " -M " + compilerFlags + " " + source_file.path + "/" + source_file.fname )
 	#masterStr += getCommandOutput( compiler + " -M " + compilerFlags + " " + source_file.path + "/" + source_file.fname )
 	#masterStr += "\t@echo Compiling " + source_file.fname + "...\n"
 	#masterStr += "\t@echo Compiling " + source_file.fname + "...\n"

+ 27 - 27
src/Main.cpp

@@ -302,26 +302,26 @@ int main( int argc, char* argv[] )
 		// move the camera
 		// move the camera
 		static SceneNode* mover = app->getActiveCam();
 		static SceneNode* mover = app->getActiveCam();
 
 
-		if( I::keys[ SDLK_1 ] ) mover = app->getActiveCam();
-		if( I::keys[ SDLK_2 ] ) mover = point_lights[0];
-		if( I::keys[ SDLK_3 ] ) mover = spot_lights[0];
-		if( I::keys[ SDLK_4 ] ) mover = point_lights[1];
-		if( I::keys[ SDLK_5 ] ) mover = spot_lights[1];
-		if( I::keys[ SDLK_6 ] ) mover = partEmitter;
-		if( I::keys[ SDLK_m ] == 1 ) I::warpMouse = !I::warpMouse;
-
-		if( I::keys[SDLK_a] ) mover->moveLocalX( -dist );
-		if( I::keys[SDLK_d] ) mover->moveLocalX( dist );
-		if( I::keys[SDLK_LSHIFT] ) mover->moveLocalY( dist );
-		if( I::keys[SDLK_SPACE] ) mover->moveLocalY( -dist );
-		if( I::keys[SDLK_w] ) mover->moveLocalZ( -dist );
-		if( I::keys[SDLK_s] ) mover->moveLocalZ( dist );
+		if( I::keys[ SDL_SCANCODE_1 ] ) mover = app->getActiveCam();
+		if( I::keys[ SDL_SCANCODE_2 ] ) mover = point_lights[0];
+		if( I::keys[ SDL_SCANCODE_3 ] ) mover = spot_lights[0];
+		if( I::keys[ SDL_SCANCODE_4 ] ) mover = point_lights[1];
+		if( I::keys[ SDL_SCANCODE_5 ] ) mover = spot_lights[1];
+		if( I::keys[ SDL_SCANCODE_6 ] ) mover = partEmitter;
+		if( I::keys[ SDL_SCANCODE_M ] == 1 ) I::warpMouse = !I::warpMouse;
+
+		if( I::keys[ SDL_SCANCODE_A ] ) mover->moveLocalX( -dist );
+		if( I::keys[ SDL_SCANCODE_D ] ) mover->moveLocalX( dist );
+		if( I::keys[ SDL_SCANCODE_LSHIFT ] ) mover->moveLocalY( dist );
+		if( I::keys[ SDL_SCANCODE_SPACE ] ) mover->moveLocalY( -dist );
+		if( I::keys[ SDL_SCANCODE_W ] ) mover->moveLocalZ( -dist );
+		if( I::keys[ SDL_SCANCODE_S ] ) mover->moveLocalZ( dist );
 		if( !I::warpMouse )
 		if( !I::warpMouse )
 		{
 		{
-			if( I::keys[SDLK_UP] ) mover->rotateLocalX( ang );
-			if( I::keys[SDLK_DOWN] ) mover->rotateLocalX( -ang );
-			if( I::keys[SDLK_LEFT] ) mover->rotateLocalY( ang );
-			if( I::keys[SDLK_RIGHT] ) mover->rotateLocalY( -ang );
+			if( I::keys[ SDL_SCANCODE_UP ] ) mover->rotateLocalX( ang );
+			if( I::keys[ SDL_SCANCODE_DOWN ] ) mover->rotateLocalX( -ang );
+			if( I::keys[ SDL_SCANCODE_LEFT ] ) mover->rotateLocalY( ang );
+			if( I::keys[ SDL_SCANCODE_RIGHT ] ) mover->rotateLocalY( -ang );
 		}
 		}
 		else
 		else
 		{
 		{
@@ -329,15 +329,15 @@ int main( int argc, char* argv[] )
 			mover->rotateLocalX( ang * I::mouseVelocity.y * accel );
 			mover->rotateLocalX( ang * I::mouseVelocity.y * accel );
 			mover->rotateLocalY( -ang * I::mouseVelocity.x * accel );
 			mover->rotateLocalY( -ang * I::mouseVelocity.x * accel );
 		}
 		}
-		if( I::keys[SDLK_q] ) mover->rotateLocalZ( ang );
-		if( I::keys[SDLK_e] ) mover->rotateLocalZ( -ang );
-		if( I::keys[SDLK_PAGEUP] ) mover->getLocalTransform().getScale() += scale ;
-		if( I::keys[SDLK_PAGEDOWN] ) mover->getLocalTransform().getScale() -= scale ;
+		if( I::keys[ SDL_SCANCODE_Q ] ) mover->rotateLocalZ( ang );
+		if( I::keys[ SDL_SCANCODE_E ] ) mover->rotateLocalZ( -ang );
+		if( I::keys[ SDL_SCANCODE_PAGEUP ] ) mover->getLocalTransform().getScale() += scale ;
+		if( I::keys[ SDL_SCANCODE_PAGEDOWN ] ) mover->getLocalTransform().getScale() -= scale ;
 
 
-		if( I::keys[SDLK_k] ) app->getActiveCam()->lookAtPoint( point_lights[0]->getWorldTransform().getOrigin() );
+		if( I::keys[ SDL_SCANCODE_K ] ) app->getActiveCam()->lookAtPoint( point_lights[0]->getWorldTransform().getOrigin() );
 
 
 
 
-		if( I::keys[SDLK_o] == 1 )
+		if( I::keys[ SDL_SCANCODE_O ] == 1 )
 		{
 		{
 			btRigidBody* body = static_cast<btRigidBody*>( boxes[0] );
 			btRigidBody* body = static_cast<btRigidBody*>( boxes[0] );
 			//body->getMotionState()->setWorldTransform( toBt( Mat4( Vec3(0.0, 10.0, 0.0), Mat3::getIdentity(), 1.0 ) ) );
 			//body->getMotionState()->setWorldTransform( toBt( Mat4( Vec3(0.0, 10.0, 0.0), Mat3::getIdentity(), 1.0 ) ) );
@@ -372,9 +372,9 @@ int main( int argc, char* argv[] )
 		/*Ui::printf( "Mover: Pos(%.2f %.2f %.2f) Angs(%.2f %.2f %.2f)", mover->translationWspace.x, mover->translationWspace.y, mover->translationWspace.z,
 		/*Ui::printf( "Mover: Pos(%.2f %.2f %.2f) Angs(%.2f %.2f %.2f)", mover->translationWspace.x, mover->translationWspace.y, mover->translationWspace.z,
 								 toDegrees(Euler(mover->rotationWspace).x), toDegrees(Euler(mover->rotationWspace).y), toDegrees(Euler(mover->rotationWspace).z) );*/
 								 toDegrees(Euler(mover->rotationWspace).x), toDegrees(Euler(mover->rotationWspace).y), toDegrees(Euler(mover->rotationWspace).z) );*/
 
 
-		if( I::keys[SDLK_ESCAPE] ) break;
-		if( I::keys[SDLK_F11] ) app->togleFullScreen();
-		if( I::keys[SDLK_F12] == 1 ) R::takeScreenshot("gfx/screenshot.jpg");
+		if( I::keys[SDL_SCANCODE_ESCAPE] ) break;
+		if( I::keys[SDL_SCANCODE_F11] ) app->togleFullScreen();
+		if( I::keys[SDL_SCANCODE_F12] == 1 ) R::takeScreenshot("gfx/screenshot.jpg");
 
 
 
 
 		/*char str[128];
 		/*char str[128];

+ 4 - 11
src/Util/App.cpp

@@ -24,6 +24,7 @@ App::App( int /*argc*/, char* /*argv*/[] )
 	/*windowW = 1440;
 	/*windowW = 1440;
 	windowH = 900;*/
 	windowH = 900;*/
 
 
+	terminalColoringEnabled = true;
 
 
 	timerTick = 1000/40; // in ms. 1000/Hz
 	timerTick = 1000/40; // in ms. 1000/Hz
 	time = 0;
 	time = 0;
@@ -50,6 +51,9 @@ void App::initWindow()
 		ERROR( "Failed to obtain the video driver name" );
 		ERROR( "Failed to obtain the video driver name" );
 	}
 	}
 
 
+	// Chose GL ver
+	SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
+	SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 1 );
 
 
 	// get desktop size
 	// get desktop size
 	const SDL_VideoInfo* info = SDL_GetVideoInfo();
 	const SDL_VideoInfo* info = SDL_GetVideoInfo();
@@ -77,17 +81,6 @@ void App::initWindow()
 	// set the surface
 	// set the surface
 	mainSurf = SDL_SetVideoMode( windowW, windowH, 24, SDL_HWSURFACE | SDL_OPENGL );
 	mainSurf = SDL_SetVideoMode( windowW, windowH, 24, SDL_HWSURFACE | SDL_OPENGL );
 
 
-	// move the window
-#ifdef WIN32
-	SDL_SysWMinfo i;
-	SDL_VERSION( &i.version );
-	if( SDL_GetWMInfo(&i) )
-	{
-		HWND hwnd = i.window;
-		SetWindowPos( hwnd, HWND_TOP, 10, 25, w, h, NULL );
-	}
-#endif
-
 	SDL_WM_SetCaption( "AnKi Engine", NULL );
 	SDL_WM_SetCaption( "AnKi Engine", NULL );
 
 
 
 

+ 1 - 1
src/Util/App.h

@@ -14,6 +14,7 @@ class App
 	PROPERTY_R( uint, desktopH, getDesktopHeight ) ///< @ref PROPERTY_R : The desktop height at App initialization
 	PROPERTY_R( uint, desktopH, getDesktopHeight ) ///< @ref PROPERTY_R : The desktop height at App initialization
 	PROPERTY_R( uint, windowW, getWindowWidth ) ///< @ref PROPERTY_R : The main window width
 	PROPERTY_R( uint, windowW, getWindowWidth ) ///< @ref PROPERTY_R : The main window width
 	PROPERTY_R( uint, windowH, getWindowHeight ) ///< @ref PROPERTY_R : The main window height
 	PROPERTY_R( uint, windowH, getWindowHeight ) ///< @ref PROPERTY_R : The main window height
+	PROPERTY_R( bool, terminalColoringEnabled, isTerminalColoringEnabled ) ///< @ref PROPERTY_R : Terminal coloring for Unix terminals. Default is enabled
 
 
 	PROPERTY_RW( class Scene*, scene, setScene, getScene ) ///< @ref PROPERTY_RW : Pointer to the current scene
 	PROPERTY_RW( class Scene*, scene, setScene, getScene ) ///< @ref PROPERTY_RW : Pointer to the current scene
 	PROPERTY_RW( class Camera*, activeCam, setActiveCam, getActiveCam ) ///< @ref PROPERTY_RW : Pointer to the current camera
 	PROPERTY_RW( class Camera*, activeCam, setActiveCam, getActiveCam ) ///< @ref PROPERTY_RW : Pointer to the current camera
@@ -24,7 +25,6 @@ class App
 		class SDL_Surface* mainSurf; ///< SDL stuff
 		class SDL_Surface* mainSurf; ///< SDL stuff
 		class SDL_Surface* iconImage; ///< SDL stuff
 		class SDL_Surface* iconImage; ///< SDL stuff
 
 
-
 	public:
 	public:
 		uint timerTick;
 		uint timerTick;
 
 

+ 15 - 17
src/Util/Input.cpp

@@ -1,3 +1,4 @@
+#include <SDL.h>
 #include "Input.h"
 #include "Input.h"
 #include "Renderer.h"
 #include "Renderer.h"
 
 
@@ -6,31 +7,28 @@ namespace I {
 
 
 
 
 
 
-/*
-=======================================================================================================================================
-data vars                                                                                                                             =
-=======================================================================================================================================
-*/
-Vec<short> keys( 1024 );  // shows the current key state. 0: unpressed, 1: pressed once, n is >1: kept pressed 'n' times continucely
-short mouseBtns [8];    // mouse btns. Supporting 3 btns & wheel. Works the same as above
-Vec2 mousePosNdc;    // the coords are in the ndc space
-Vec2 mousePos;        // the coords are in the window space
+//=====================================================================================================================================
+// VARS                                                                                                                               =
+//=====================================================================================================================================
+Vec<short> keys( SDL_NUM_SCANCODES, 0 );
+Vec<short> mouseBtns( 8, 0 );
+Vec2 mousePosNdc;
+Vec2 mousePos;
 Vec2 mouseVelocity;
 Vec2 mouseVelocity;
 
 
 bool warpMouse = false;
 bool warpMouse = false;
 bool hideCursor = true;
 bool hideCursor = true;
 
 
 
 
-/*
-=======================================================================================================================================
-reset                                                                                                                                 =
-=======================================================================================================================================
-*/
+//=====================================================================================================================================
+// reset                                                                                                                              =
+//=====================================================================================================================================
 void reset( void )
 void reset( void )
 {
 {
 	DEBUG_ERR( keys.size() < 1 );
 	DEBUG_ERR( keys.size() < 1 );
+	DEBUG_ERR( mouseBtns.size() < 1 );
 	memset( &keys[0], 0, keys.size()*sizeof(short) );
 	memset( &keys[0], 0, keys.size()*sizeof(short) );
-	memset(mouseBtns, 0, sizeof(mouseBtns) );
+	memset( &mouseBtns[0], 0, mouseBtns.size()*sizeof(short) );
 	mousePosNdc.setZero();
 	mousePosNdc.setZero();
 	mouseVelocity.setZero();
 	mouseVelocity.setZero();
 }
 }
@@ -65,11 +63,11 @@ void handleEvents()
 		switch( event_.type )
 		switch( event_.type )
 		{
 		{
 			case SDL_KEYDOWN:
 			case SDL_KEYDOWN:
-				keys[event_.key.keysym.sym] = 1;
+				keys[event_.key.keysym.scancode] = 1;
 				break;
 				break;
 
 
 			case SDL_KEYUP:
 			case SDL_KEYUP:
-				keys[event_.key.keysym.sym] = 0;
+				keys[event_.key.keysym.scancode] = 0;
 				break;
 				break;
 
 
 			case SDL_MOUSEBUTTONDOWN:
 			case SDL_MOUSEBUTTONDOWN:

+ 4 - 4
src/Util/Input.h

@@ -1,7 +1,7 @@
 #ifndef _INPUT_H_
 #ifndef _INPUT_H_
 #define _INPUT_H_
 #define _INPUT_H_
 
 
-#include <SDL.h>
+#include <SDL_scancode.h>
 #include "Common.h"
 #include "Common.h"
 #include "App.h"
 #include "App.h"
 #include "Math.h"
 #include "Math.h"
@@ -13,12 +13,12 @@ extern void reset();
 extern void handleEvents();
 extern void handleEvents();
 
 
 // keys and btns
 // keys and btns
-extern Vec<short> keys;  ///< Shows the current key state. 0: unpressed, 1: pressed once, n is >1: kept pressed 'n' times continucely
-extern short mouseBtns [];    ///< Mouse btns. Supporting 3 btns & wheel. Works the same as above
+extern Vec<short> keys;  ///< Shows the current key state. 0: unpressed, 1: pressed once, n is >1: kept pressed 'n' times continuously
+extern Vec<short> mouseBtns;    ///< Mouse btns. Supporting 3 btns & wheel. Works the same as above
 
 
 // mouse stuff
 // mouse stuff
 extern Vec2 mousePosNdc; ///< The coords are in the NDC space
 extern Vec2 mousePosNdc; ///< The coords are in the NDC space
-extern Vec2 mousePos;     ///< The coords are in the window space. (0,0) is in the uper left corner
+extern Vec2 mousePos;     ///< The coords are in the window space. (0,0) is in the upper left corner
 extern Vec2 mouseVelocity;
 extern Vec2 mouseVelocity;
 extern bool warpMouse;
 extern bool warpMouse;
 extern bool hideCursor;
 extern bool hideCursor;

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä