Przeglądaj źródła

Merge branch 'master' into pxljm

Conflicts:
	Bindings/Contents/LUA/Include/PolycodeLUAWrappers.h
	Bindings/Contents/LUA/Source/PolycodeLUA.cpp
	Core/Contents/Include/PolyGLTexture.h
	Core/Contents/Source/PolyCore.cpp
	Core/Contents/Source/PolyRenderer.cpp
Cameron Hart 14 lat temu
rodzic
commit
cdee607137

+ 4 - 4
Bindings/Contents/LUA/API/Polycode/Core.lua

@@ -148,12 +148,12 @@ function Core:openFolderPicker()
 	end
 end
 
-function Core:setVideoModeIndex(index, fullScreen, aaLevel)
-	local retVal = Polycore.Core_setVideoModeIndex(self.__ptr, index, fullScreen, aaLevel)
+function Core:setVideoModeIndex(index, fullScreen, vSync, aaLevel, anisotropyLevel)
+	local retVal = Polycore.Core_setVideoModeIndex(self.__ptr, index, fullScreen, vSync, aaLevel, anisotropyLevel)
 end
 
-function Core:setVideoMode(xRes, yRes, fullScreen, aaLevel)
-	local retVal = Polycore.Core_setVideoMode(self.__ptr, xRes, yRes, fullScreen, aaLevel)
+function Core:setVideoMode(xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel)
+	local retVal = Polycore.Core_setVideoMode(self.__ptr, xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel)
 end
 
 function Core:resizeTo(xRes, yRes)

+ 9 - 0
Bindings/Contents/LUA/API/Polycode/Renderer.lua

@@ -388,6 +388,15 @@ function Renderer:getYRes()
 	return retVal
 end
 
+function Renderer:setAnisotropyAmount(amount)
+	local retVal = Polycore.Renderer_setAnisotropyAmount(self.__ptr, amount)
+end
+
+function Renderer:getAnisotropyAmount()
+	local retVal =  Polycore.Renderer_getAnisotropyAmount(self.__ptr)
+	return retVal
+end
+
 function Renderer:cullFrontFaces(val)
 	local retVal = Polycore.Renderer_cullFrontFaces(self.__ptr, val)
 end

+ 4 - 0
Bindings/Contents/LUA/API/Polycode/Scene.lua

@@ -185,6 +185,10 @@ function Scene:addLight(light)
 	local retVal = Polycore.Scene_addLight(self.__ptr, light.__ptr)
 end
 
+function Scene:removeLight(light)
+	local retVal = Polycore.Scene_removeLight(self.__ptr, light.__ptr)
+end
+
 function Scene:getNearestLight(pos)
 	local retVal = Polycore.Scene_getNearestLight(self.__ptr, pos.__ptr)
 	if retVal == nil then return nil end

+ 4 - 0
Bindings/Contents/LUA/API/Polycode/TweenManager.lua

@@ -24,6 +24,10 @@ function TweenManager:addTween(tween)
 	local retVal = Polycore.TweenManager_addTween(self.__ptr, tween.__ptr)
 end
 
+function TweenManager:removeTween(tween)
+	local retVal = Polycore.TweenManager_removeTween(self.__ptr, tween.__ptr)
+end
+
 function TweenManager:Update()
 	local retVal =  Polycore.TweenManager_Update(self.__ptr)
 end

Plik diff jest za duży
+ 479 - 474
Bindings/Contents/LUA/Include/PolycodeLUAWrappers.h


Plik diff jest za duży
+ 128 - 907
Bindings/Contents/LUA/Source/PolycodeLUA.cpp


+ 3 - 3
CMake/PolycodeIncludes.cmake

@@ -1,13 +1,13 @@
 # platform specific defines and include directories for win and sdl
 IF(MSVC)
     ADD_DEFINITIONS(/D_UNICODE /DUNICODE)
-    INCLUDE_DIRECTORIES(${Polycode_SOURCE_DIR}/Core/Build/MSVC/Polycore)
+    INCLUDE_DIRECTORIES("${Polycode_SOURCE_DIR}/Core/Contents/PolycodeView/Build/MSVC/Polycore")
 ELSEIF(APPLE)
     ADD_DEFINITIONS(-DGL_GLEXT_PROTOTYPES)
-    INCLUDE_DIRECTORIES("${Polycode_SOURCE_DIR}/Core/Build/Mac OS X")
+    INCLUDE_DIRECTORIES("${Polycode_SOURCE_DIR}/Core/Contents/PolycodeView/Build/Mac OS X")
 ELSE(MSVC)
     ADD_DEFINITIONS(-DGL_GLEXT_PROTOTYPES)
-    INCLUDE_DIRECTORIES(${Polycode_SOURCE_DIR}/Core/Build/Linux)
+    INCLUDE_DIRECTORIES("${Polycode_SOURCE_DIR}/Core/Contents/PolycodeView/Linux")
 ENDIF(MSVC)
 
 FIND_PACKAGE(OpenGL REQUIRED)

+ 2 - 2
Core/Contents/Include/PolyCocoaCore.h

@@ -66,13 +66,13 @@ namespace Polycode {
 	class _PolyExport CocoaCore : public Core {		
 	public:
 		
-		CocoaCore(PolycodeView *view, int xRes, int yRes, bool fullScreen, int aaLevel, int frameRate);
+		CocoaCore(PolycodeView *view, int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate);
 		virtual ~CocoaCore();
 		
 		void enableMouse(bool newval);
 		unsigned int getTicks();		
 		bool Update();		
-		void setVideoMode(int xRes, int yRes, bool fullScreen, int aaLevel);		
+		void setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel);		
 		void resizeTo(int xRes, int yRes);
 		void createThread(Threaded *target);		
 		

+ 1 - 1
Core/Contents/Include/PolyColor.h

@@ -85,7 +85,7 @@ namespace Polycode {
 			}
 			
 			bool operator != (const Color& c2) {
-				return (((int)255.0*r) != ((int)255.0*c2.r) && ((int)255.0*g) != ((int)255.0*c2.g) && ((int)255.0*b) != ((int)255.0*c2.b) && ((int)255.0*a) != ((int)255.0*c2.a));
+				return (((int)255.0*r) != ((int)255.0*c2.r) || ((int)255.0*g) != ((int)255.0*c2.g) || ((int)255.0*b) != ((int)255.0*c2.b) || ((int)255.0*a) != ((int)255.0*c2.a));
 			}
 			
 

+ 3 - 3
Core/Contents/Include/PolyCore.h

@@ -76,7 +76,7 @@ namespace Polycode {
 		* @param aaLevel Level of anti-aliasing. Possible values are 2,4 and 6.
 		* @param frameRate Frame rate that the core will update and render at.
 		*/			
-		Core(int xRes, int yRes, bool fullScreen, int aaLevel, int frameRate);
+		Core(int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate);
 		virtual ~Core();
 		
 		virtual bool Update() = 0;
@@ -229,7 +229,7 @@ namespace Polycode {
 		*/																							
 		virtual std::vector<String> openFilePicker(std::vector<CoreFileExtension> extensions, bool allowMultiple) = 0;
 		
-		void setVideoModeIndex(int index, bool fullScreen, int aaLevel);
+		void setVideoModeIndex(int index, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel);
 		
 		/**
 		* Sets a new video mode.
@@ -238,7 +238,7 @@ namespace Polycode {
 		* @param fullScreen True to launch in fullscreen, false to launch in window.
 		* @param aaLevel Level of anti-aliasing. Possible values are 2,4 and 6.
 		*/																									
-		virtual void setVideoMode(int xRes, int yRes, bool fullScreen, int aaLevel) = 0;
+		virtual void setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel) = 0;
 		
 		/**
 		* Resizes the renderer.

+ 1 - 0
Core/Contents/Include/PolyGLTexture.h

@@ -35,6 +35,7 @@ THE SOFTWARE.
 #include <OpenGL/glu.h>	
 #else
 #include <GL/gl.h>
+#include <GL/glu.h>
 #endif
 
 

+ 5 - 0
Core/Contents/Include/PolyRenderer.h

@@ -186,6 +186,9 @@ namespace Polycode {
 		int getXRes();
 		int getYRes();
 		
+		void setAnisotropyAmount(Number amount);
+		Number getAnisotropyAmount();
+		
 		virtual void cullFrontFaces(bool val) = 0;
 		
 		void clearLights();
@@ -245,6 +248,8 @@ namespace Polycode {
 		std::vector<LightInfo> getSpotLights() { return spotLights;	}
 		
 	protected:
+	
+		Number anisotropy;
 		Matrix4 currentModelMatrix;
 		LightSorter sorter;	
 	

+ 3 - 1
Core/Contents/Include/PolySDLCore.h

@@ -30,6 +30,8 @@ struct SDL_mutex;
 
 namespace Polycode {
 
+	class PolycodeView;
+
 	class _PolyExport SDLCoreMutex : public CoreMutex {
 	public:
 		SDL_mutex *pMutex;
@@ -39,7 +41,7 @@ namespace Polycode {
 		
 	public:
 		
-		SDLCore(PolycodeViewBase *view, int xRes, int yRes, bool fullScreen, int aaLevel, int frameRate);
+		SDLCore(PolycodeView *view, int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate);
 		~SDLCore();
 
 		void enableMouse(bool newval);

+ 7 - 0
Core/Contents/Include/PolyScene.h

@@ -125,6 +125,13 @@ namespace Polycode {
 		* @param light Light to add to the scene.
 		*/
 		void addLight(SceneLight *light);
+		
+		/**
+		* Removes a light from the scene.
+		* @param light Light to remove from the scene.
+		*/		
+		void removeLight(SceneLight *light);
+		
 		SceneLight *getNearestLight(Vector3 pos);
 		
 		void writeEntityMatrix(SceneEntity *entity, OSFILE *outFile);

+ 1 - 0
Core/Contents/Include/PolyTweenManager.h

@@ -33,6 +33,7 @@ namespace Polycode {
 			TweenManager();
 			~TweenManager();
 			void addTween(Tween *tween);
+			void removeTween(Tween *tween);	
 			void Update();
 		
 		private:

+ 0 - 3
Core/Contents/PolycodeView/Linux/PolycodeView.cpp

@@ -1,7 +1,4 @@
-
 #include "PolycodeView.h"
-#include <stdio.h>
-#include <stdlib.h>
 
 namespace Polycode {
 

+ 1 - 2
Core/Contents/PolycodeView/Linux/PolycodeView.h

@@ -1,7 +1,6 @@
 #pragma once
 
-#include <Polycode.h>
-#include "PolySDLCore.h"
+#include "PolyCore.h"
 
 namespace Polycode {
 

+ 13 - 5
Core/Contents/Source/PolyCocoaCore.mm

@@ -29,7 +29,7 @@ long getThreadID() {
 	return (long)pthread_self();
 }
 
-CocoaCore::CocoaCore(PolycodeView *view, int xRes, int yRes, bool fullScreen,int aaLevel, int frameRate) : Core(xRes, yRes, fullScreen,aaLevel, frameRate) {	
+CocoaCore::CocoaCore(PolycodeView *view, int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate) : Core(xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel, frameRate) {	
 	eventMutex = createMutex();
 	
 //	NSLog(@"BUNDLE: %@", [[NSBundle mainBundle] bundlePath]);
@@ -142,7 +142,7 @@ CocoaCore::CocoaCore(PolycodeView *view, int xRes, int yRes, bool fullScreen,int
 	renderer = new OpenGLRenderer();
 	services->setRenderer(renderer);	
 	//[view unlockContext];			
-	setVideoMode(xRes,yRes,fullScreen,aaLevel);		
+	setVideoMode(xRes,yRes,fullScreen, vSync, aaLevel, anisotropyLevel);		
 
 	CoreServices::getInstance()->installModule(new GLSLShaderModule());	
 
@@ -166,12 +166,13 @@ String CocoaCore::getClipboardString() {
 	
 }
 
-void CocoaCore::setVideoMode(int xRes, int yRes, bool fullScreen, int aaLevel) {
+void CocoaCore::setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int aaLeve, int anisotropyLevel) {
 	this->xRes = xRes;
 	this->yRes = yRes;
 	this->fullScreen = fullScreen;
 	this->aaLevel = aaLevel;
-	
+	renderer->setAnisotropyAmount(anisotropyLevel);
+		
 	renderer->Resize(xRes, yRes);
 //	CoreServices::getInstance()->getMaterialManager()->reloadProgramsAndTextures();	
 	dispatchEvent(new Event(), EVENT_CORE_RESIZE);	
@@ -195,7 +196,14 @@ void CocoaCore::setVideoMode(int xRes, int yRes, bool fullScreen, int aaLevel) {
 																	   nil]];
 		
 	}
-		
+	
+	GLint sync = 0;
+	if(vSync) {
+		sync =1 ;
+	} 
+	
+	[context setValues:&sync forParameter:NSOpenGLCPSwapInterval];	
+				
 	/*
 	if(aaLevel > 0) {
 		glEnable( GL_MULTISAMPLE_ARB );	

+ 3 - 3
Core/Contents/Source/PolyCore.cpp

@@ -31,7 +31,7 @@
 
 namespace Polycode {
 	
-	Core::Core(int xRes, int yRes, bool fullScreen, int aaLevel, int frameRate) : EventDispatcher() {
+	Core::Core(int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate) : EventDispatcher() {
 		services = CoreServices::getInstance();
 		input = new CoreInput();
 		services->setCore(this);
@@ -86,12 +86,12 @@ namespace Polycode {
 		return ((Number)getTicks())/1000.0f;		
 	}
 	
-	void Core::setVideoModeIndex(int index, bool fullScreen, int aaLevel) {
+	void Core::setVideoModeIndex(int index, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel) {
 		std::vector<Rectangle> resList = getVideoModes();
 		if(index >= resList.size())
 			return;
 		
-		setVideoMode(resList[index].w, resList[index].h, fullScreen, aaLevel);
+		setVideoMode(resList[index].w, resList[index].h, fullScreen, vSync, aaLevel, anisotropyLevel);
 	}
 	
 	void Core::updateCore() {

+ 16 - 6
Core/Contents/Source/PolyGLTexture.cpp

@@ -21,6 +21,7 @@
 */
 
 #include "PolyGLTexture.h"
+#include "PolyCoreServices.h"
 #include "PolyRenderer.h"
 
 using namespace Polycode;
@@ -39,6 +40,8 @@ OpenGLTexture::OpenGLTexture(unsigned int width, unsigned int height, char *text
 
 void OpenGLTexture::recreateFromImageData() {
 	
+	Number anisotropy = CoreServices::getInstance()->getRenderer()->getAnisotropyAmount();
+	
 	if(glTextureLoaded)
 		glDeleteTextures(1, &textureID);
 	
@@ -53,19 +56,26 @@ void OpenGLTexture::recreateFromImageData() {
 	}
 	switch(filteringMode) {
 		case Renderer::TEX_FILTERING_LINEAR:
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+		
+			if(anisotropy > 0) {
+				glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy);
+			}
+		
+			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+			if(textureData) {
+				gluBuild2DMipmaps(GL_TEXTURE_2D, glTextureType, width, height, glTextureType, GL_UNSIGNED_BYTE, textureData );
+			}			
 			break;
 		case Renderer::TEX_FILTERING_NEAREST:
 			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);		
+			if(textureData) {
+				glTexImage2D(GL_TEXTURE_2D, 0, glTextureType, width, height, 0, glTextureType, GL_UNSIGNED_BYTE, textureData);							
+			}			
 			break;
 	}	
 	
-	if(textureData) {
-		glTexImage2D(GL_TEXTURE_2D, 0, glTextureType, width, height, 0, glTextureType, GL_UNSIGNED_BYTE, textureData);							
-//		gluBuild2DMipmaps(GL_TEXTURE_2D, 3, glTextureType, width, height, glTextureType, GL_UNSIGNED_BYTE, textureData);
-	}
 	glTextureLoaded = true;
 }
 

+ 9 - 0
Core/Contents/Source/PolyRenderer.cpp

@@ -26,6 +26,7 @@
 using namespace Polycode;
 
 Renderer::Renderer() : currentTexture(NULL), xRes(0), yRes(0), renderMode(0), orthoMode(false), lightingEnabled(false), clearColor(0.2f, 0.2f, 0.2f, 0.0) {
+	anisotropy = 0;
 	textureFilteringMode = TEX_FILTERING_LINEAR;
 	currentMaterial = NULL;
 	numLights = 0;
@@ -169,6 +170,14 @@ void Renderer::addLight(int lightImportance, Vector3 position, Vector3 direction
 	}
 }
 
+Number Renderer::getAnisotropyAmount() {
+	return anisotropy;
+}
+
+void Renderer::setAnisotropyAmount(Number amount) {
+	anisotropy = amount;
+}
+
 const Matrix4& Renderer::getCameraMatrix() const {
 	return cameraMatrix;
 }

+ 2 - 1
Core/Contents/Source/PolySDLCore.cpp

@@ -21,6 +21,7 @@
 */		
 
 #include "PolySDLCore.h"
+#include "PolycodeView.h"
 #include "PolyCoreServices.h"
 #include "PolyCoreInput.h"
 #include "PolyMaterialManager.h"
@@ -40,7 +41,7 @@ long getThreadID() {
 	return (long)pthread_self();
 }
 
-SDLCore::SDLCore(PolycodeViewBase *view, int xRes, int yRes, bool fullScreen,int aaLevel, int frameRate) : Core(xRes, yRes, fullScreen,aaLevel, frameRate) {
+SDLCore::SDLCore(PolycodeView *view, int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate) : Core(xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel, frameRate) {
 
 	String *windowTitle = (String*)view->windowData;
 

+ 10 - 0
Core/Contents/Source/PolyScene.cpp

@@ -279,6 +279,16 @@ void Scene::addLight(SceneLight *light) {
 	addEntity(light);	
 }
 
+void Scene::removeLight(SceneLight *light) {
+	removeEntity(light);
+	for(int i=0; i < lights.size(); i++) {
+		if(lights[i] == light) {
+			lights.erase(lights.begin()+i);
+			return;
+		}		
+	}
+}
+
 SceneLight *Scene::getNearestLight(Vector3 pos) {
 	if(lights.size() > 0)
 		return lights[0];

+ 1 - 0
Core/Contents/Source/PolySceneMesh.cpp

@@ -75,6 +75,7 @@ void SceneMesh::setMesh(Mesh *mesh) {
 
 
 SceneMesh::~SceneMesh() {
+	delete mesh;
 }
 
 Mesh *SceneMesh::getMesh() {

+ 2 - 1
Core/Contents/Source/PolyTween.cpp

@@ -63,7 +63,8 @@ void Tween::setSpeed(Number speed) {
 
 Tween::~Tween() {
 	tweenTimer->removeEventListener(this, 0);
-	CoreServices::getInstance()->getTimerManager()->removeTimer(tweenTimer);
+	delete tweenTimer;
+	CoreServices::getInstance()->getTweenManager()->removeTween(this);	
 }
 
 bool Tween::isComplete() {

+ 8 - 0
Core/Contents/Source/PolyTweenManager.cpp

@@ -37,6 +37,14 @@ void TweenManager::addTween(Tween *tween) {
 	tweens.push_back(tween);
 }
 
+void TweenManager::removeTween(Tween *tween) {
+	for(int i=0;i<tweens.size();i++) {
+		if(tweens[i] == tween) {
+			tweens.erase(tweens.begin()+i);
+		}
+	}
+}
+
 void TweenManager::Update() {
 	Tween *tween;
 	for(int i=0;i<tweens.size();i++) {

+ 1 - 1
Modules/Contents/3DPhysics/Source/PolyPhysicsScene.cpp

@@ -77,7 +77,7 @@ void PhysicsScene::Update() {
 	
 	
 	Number elapsed = CoreServices::getInstance()->getCore()->getElapsed();
-	physicsWorld->stepSimulation(elapsed);	
+	physicsWorld->stepSimulation(elapsed, 7);	
 	CollisionScene::Update();
 	
 }

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików