Просмотр исходного кода

Started on updating SDLCore

Moved RPI files to build/rpi, created a Makefile in build/linux for core, ui, template and the ide, updated the SDLCore to new renderer, fix getMouseDelta and warpCursor on Linux.
Joachim Meyer 10 лет назад
Родитель
Сommit
7e64dc2022

+ 5 - 0
.gitignore

@@ -1,9 +1,11 @@
 # Created by https://www.gitignore.io
 
 *.o
+*.do
 build/linux/TemplateApp/PolycodeTemplate
 build/linux/TemplateApp/default
 build/linux/TemplateApp/default.pak
+build/linux/Studio/*
 
 docs/cldoc
 
@@ -90,6 +92,9 @@ bld/
 # Visual Studo 2015 cache/options directory
 .vs/
 
+# KDev Files
+*.kdev*
+
 # MSTest test Results
 [Tt]est[Rr]esult*/
 [Bb]uild[Ll]og.*

Разница между файлами не показана из-за своего большого размера
+ 1 - 0
build/linux/Makefile


+ 11 - 0
build/linux/Studio/main.cpp

@@ -0,0 +1,11 @@
+#include "Polycode.h"
+#include "polycode/view/linux/PolycodeView.h"
+#include "polycode/ide/PolycodeIDEApp.h"
+
+int main(int argc, char *argv[]) {
+	PolycodeView *view = new PolycodeView("Polycode", true);
+	PolycodeIDEApp *app = new PolycodeIDEApp(view);
+	while(app->Update()) {}
+	app->saveConfigFile();
+	return 0;
+}

+ 2 - 2
build/linux/TemplateApp/PolycodeTemplate.cpp

@@ -1,8 +1,8 @@
 #include "PolycodeTemplateApp.h"
-
+#include "polycode/view/linux/PolycodeView.h"
 
 int main(int argc, char **argv) {
-	PolycodeView *view = new PolycodeView();
+	PolycodeView *view = new PolycodeView("Polycode Template");
 	PolycodeTemplateApp *app = new PolycodeTemplateApp(view);
 	while(app->Update()) {
 	}

+ 13 - 14
build/linux/TemplateApp/PolycodeTemplateApp.cpp

@@ -8,7 +8,7 @@
 PolycodeTemplateApp::PolycodeTemplateApp(PolycodeView *view) {
     core = new POLYCODE_CORE(view, 800,480,false,false, 0,0,60);
     
-  //  core->addFileSource("archive", "default.pak");
+    core->addFileSource("archive", "default.pak");
     ResourcePool *globalPool = Services()->getResourceManager()->getGlobalPool();
     globalPool->loadResourcesFromFolder("default", true);
     
@@ -42,25 +42,24 @@ PolycodeTemplateApp::PolycodeTemplateApp(PolycodeView *view) {
     
     //sound2->Play(true);
   */
-  
     Services()->getInput()->addEventListener(this, InputEvent::EVENT_KEYDOWN);
 }
 
 void PolycodeTemplateApp::handleEvent(Event *event) {
     InputEvent *inputEvent = (InputEvent*) event;
     
-    switch(inputEvent->getKey()) {
-        case KEY_z:
-            sound1->Play(true);
-        break;
-        case KEY_x:
-            sound2->Play();
-        break;
-        case KEY_c:
-            sound3->Play();
-        break;
-            
-    }
+//     switch(inputEvent->getKey()) {
+//         case KEY_z:
+//             sound1->Play(true);
+//         break;
+//         case KEY_x:
+//             sound2->Play();
+//         break;
+//         case KEY_c:
+//             sound3->Play();
+//         break;
+//             
+//     }
 }
 
 PolycodeTemplateApp::~PolycodeTemplateApp() {

Разница между файлами не показана из-за своего большого размера
+ 3 - 0
build/rpi/Makefile


+ 10 - 0
build/rpi/TemplateApp/PolycodeTemplate.cpp

@@ -0,0 +1,10 @@
+#include "PolycodeTemplateApp.h"
+
+
+int main(int argc, char **argv) {
+	PolycodeView *view = new PolycodeView();
+	PolycodeTemplateApp *app = new PolycodeTemplateApp(view);
+	while(app->Update()) {
+	}
+	return 0;
+}

+ 72 - 0
build/rpi/TemplateApp/PolycodeTemplateApp.cpp

@@ -0,0 +1,72 @@
+//
+// Polycode template. Write your code here.
+// 
+
+#include "PolycodeTemplateApp.h"
+
+
+PolycodeTemplateApp::PolycodeTemplateApp(PolycodeView *view) {
+    core = new POLYCODE_CORE(view, 800,480,false,false, 0,0,60);
+    
+  //  core->addFileSource("archive", "default.pak");
+    ResourcePool *globalPool = Services()->getResourceManager()->getGlobalPool();
+    globalPool->loadResourcesFromFolder("default", true);
+    
+	// Write your code here!
+    
+    Scene *scene = new Scene(Scene::SCENE_2D);
+    scene->useClearColor = true;
+    
+    ScenePrimitive *test = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 0.5, 0.5);
+    test->setMaterialByName("Unlit");
+    test->getShaderPass(0).shaderBinding->loadTextureForParam("diffuse", "main_icon.png");
+    scene->addChild(test);
+	test->setPositionY(0.2);
+    
+    SceneLabel *testLabel = new SceneLabel("Hello Polycode!", 32, "sans", Label::ANTIALIAS_FULL, 0.2);
+	testLabel->setPositionY(-0.2);
+    scene->addChild(testLabel);
+    
+/*
+    bgSound = new Sound("bedlayer_main.wav");
+    bgSound->Play();
+//    bgSound->setPitch(10.0);
+    
+    
+    sound1 = new Sound("marimba-lo.wav");
+    
+    sound1->setPitch(2.3);
+    
+    sound2 = new Sound("initial_touch_01.wav");
+    sound3 = new Sound("curve_02_c.wav");
+    
+    //sound2->Play(true);
+  */
+  
+    Services()->getInput()->addEventListener(this, InputEvent::EVENT_KEYDOWN);
+}
+
+void PolycodeTemplateApp::handleEvent(Event *event) {
+    InputEvent *inputEvent = (InputEvent*) event;
+    
+    switch(inputEvent->getKey()) {
+        case KEY_z:
+            sound1->Play(true);
+        break;
+        case KEY_x:
+            sound2->Play();
+        break;
+        case KEY_c:
+            sound3->Play();
+        break;
+            
+    }
+}
+
+PolycodeTemplateApp::~PolycodeTemplateApp() {
+    
+}
+
+bool PolycodeTemplateApp::Update() {
+    return core->updateAndRender();
+}

+ 27 - 0
build/rpi/TemplateApp/PolycodeTemplateApp.h

@@ -0,0 +1,27 @@
+//
+// Polycode template. Write your code here.
+//
+
+#include "Polycode.h"
+
+using namespace Polycode;
+
+class PolycodeTemplateApp : public EventHandler {
+public:
+    PolycodeTemplateApp(PolycodeView *view);
+    ~PolycodeTemplateApp();
+    
+    void handleEvent(Event *event);
+    
+    bool Update();
+    
+private:
+    
+    Sound *bgSound;
+    
+    Sound *sound1;
+    Sound *sound2;
+    Sound *sound3;
+    
+    Core *core;
+};

BIN
build/rpi/TemplateApp/main_icon.png


+ 25 - 0
include/ogg/config_types.h

@@ -0,0 +1,25 @@
+#ifndef __CONFIG_TYPES_H__
+#define __CONFIG_TYPES_H__
+
+/* these are filled in by configure */
+#define INCLUDE_INTTYPES_H 1
+#define INCLUDE_STDINT_H 1
+#define INCLUDE_SYS_TYPES_H 1
+
+#if INCLUDE_INTTYPES_H
+#  include <inttypes.h>
+#endif
+#if INCLUDE_STDINT_H
+#  include <stdint.h>
+#endif
+#if INCLUDE_SYS_TYPES_H
+#  include <sys/types.h>
+#endif
+
+typedef short ogg_int16_t;
+typedef unsigned short ogg_uint16_t;
+typedef int ogg_int32_t;
+typedef unsigned int ogg_uint32_t;
+typedef long ogg_int64_t;
+
+#endif

+ 12 - 12
include/polycode/core/PolyCore.h

@@ -298,18 +298,18 @@ namespace Polycode {
 		
 		virtual String saveFilePicker(std::vector<CoreFileExtension> extensions) = 0;
 
-        virtual void handleVideoModeChange(VideoModeChangeInfo *modeInfo) = 0;
-        virtual void flushRenderContext() = 0;
-        
-        CoreFile *openFile(const Polycode::String& fileName, const Polycode::String& opts);
-        void closeFile(CoreFile *file);
-        
-        void addFileSource(const String &type, const String &source);
-        void removeFileSource(const String &type, const String &source);
-        
-        std::vector<OSFileEntry> parseFolder(const Polycode::String& pathString, bool showHidden);
+		virtual void handleVideoModeChange(VideoModeChangeInfo *modeInfo) = 0;
+		virtual void flushRenderContext() = 0;
+		
+		CoreFile *openFile(const Polycode::String& fileName, const Polycode::String& opts);
+		void closeFile(CoreFile *file);
+		
+		void addFileSource(const String &type, const String &source);
+		void removeFileSource(const String &type, const String &source);
+		
+		std::vector<OSFileEntry> parseFolder(const Polycode::String& pathString, bool showHidden);
 
-        virtual bool systemParseFolder(const Polycode::String& pathString, bool showHidden, std::vector<OSFileEntry> &targetVector) = 0;
+		virtual bool systemParseFolder(const Polycode::String& pathString, bool showHidden, std::vector<OSFileEntry> &targetVector) = 0;
         
         
 		/**
@@ -357,7 +357,7 @@ namespace Polycode {
 			return timeSleptMs;
 		}
         
-        Number getFixedTimestep();
+		Number getFixedTimestep();
 		
 		/**
 		* Returns the total ticks elapsed since launch.

+ 7 - 5
include/polycode/core/PolyOpenGLGraphicsInterface.h

@@ -54,13 +54,15 @@ THE SOFTWARE.
 	#endif
 #else	
 	#if defined(USE_EGL)
-		#include <angle/EGL/egl.h>
-		#include <angle/EGL/eglext.h>
-		#include <angle/GLES2/gl2.h>
+		#include <EGL/egl.h>
+		#include <EGL/eglext.h>
+		#include <GLES2/gl2.h>
 	#else
-		#include <GL/gl.h>
+		#include <glew/GL/glew.h>
+		
+		/*#include <GL/gl.h>
 		#include <GL/glu.h>
-		#include <GL/glext.h>
+		#include <GL/glext.h>*/
 	#endif
 #endif
 

+ 15 - 4
include/polycode/core/PolySDLCore.h

@@ -25,6 +25,7 @@
 #include "PolyGlobals.h"
 #include "PolyCore.h"
 #include <vector>
+// #include <SDL2/SDL.h>
 
 #define POLYCODE_CORE SDLCore
 
@@ -36,6 +37,8 @@ namespace Polycode {
 
 	class _PolyExport SDLCoreMutex : public CoreMutex {
 	public:
+		void lock();
+		void unlock();
 		SDL_mutex *pMutex;
 	};
 
@@ -51,14 +54,19 @@ namespace Polycode {
 		unsigned int getTicks();
 		bool systemUpdate();
 		void Render();
+		void flushRenderContext();
+		
+		void handleVideoModeChange(VideoModeChangeInfo *modeInfo);
 		void setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, bool retinaSupport = true);
 		void createThread(Threaded *target);
 		std::vector<Rectangle> getVideoModes();
 		
+		bool systemParseFolder(const String& pathString, bool showHidden, std::vector<OSFileEntry> &targetVector);
+				
 		void setCursor(int cursorType);
 		void warpCursor(int x, int y);
-		void lockMutex(CoreMutex *mutex);
-		void unlockMutex(CoreMutex *mutex);
+		//void lockMutex(CoreMutex *mutex);
+		//void unlockMutex(CoreMutex *mutex);
 		CoreMutex *createMutex();
 		void copyStringToClipboard(const String& str);
 		String getClipboardString();
@@ -74,12 +82,15 @@ namespace Polycode {
 		String executeExternalCommand(String command, String args, String inDirectory="");
 		void openURL(String url);
 
-
 	private:
 		bool checkSpecialKeyEvents(PolyKEY key);
-
+		
 		uint32_t flags;
 		bool resizableWindow;
 		
+		String* windowTitle;
+		
+		int lastMouseX;
+		int lastMouseY;
 	};
 }

+ 1 - 1
include/polycode/ide/PolycodeIDEApp.h

@@ -25,7 +25,7 @@
 #elif defined(_WINDOWS)
 #include "polycode/ide/PolycodeWinIDEView.h"
 #else
-#include "polycode/ide/PolycodeView.h"
+#include "polycode/view/linux/PolycodeView.h"
 #endif
 
 #include "polycode/ide/PolycodeGlobals.h"

+ 16 - 0
include/polycode/view/linux/PolycodeView.h

@@ -0,0 +1,16 @@
+#pragma once
+
+#include "polycode/core/PolySDLCore.h"
+
+namespace Polycode {
+
+    class PolycodeView : public PolycodeViewBase {
+        public:
+            PolycodeView(const char *title, bool resizable = false);
+            ~PolycodeView();
+
+            String windowTitle;
+	    bool resizable;
+    };
+
+}

+ 144 - 72
src/core/PolySDLCore.cpp

@@ -20,21 +20,23 @@
  THE SOFTWARE.
 */		
 
-#include "PolySDLCore.h"
-#include "PolycodeView.h"
-#include "PolyCoreServices.h"
-#include "PolyCoreInput.h"
-#include "PolyMaterialManager.h"
-#include "PolyThreaded.h"
-
-#include "PolyGLRenderer.h"
-#include "PolyGLSLShaderModule.h"
-#include "PolyRectangle.h"
+#include "polycode/core/PolySDLCore.h"
+#include "polycode/view/linux/PolycodeView.h"
+#include "polycode/core/PolyCoreServices.h"
+#include "polycode/core/PolyCoreInput.h"
+#include "polycode/core/PolyMaterialManager.h"
+#include "polycode/core/PolyThreaded.h"
+#include "polycode/core/PolyLogger.h"
+
+#include "polycode/core/PolyOpenGLGraphicsInterface.h"
+#include "polycode/core/PolyBasicFileProvider.h"
+#include "polycode/core/PolyPhysFSFileProvider.h"
 
 #include <SDL/SDL.h>
 #include <SDL/SDL_syswm.h>
 #include <stdio.h>
 #include <limits.h>
+#include <dirent.h>
 
 #include <iostream>
 
@@ -68,6 +70,16 @@ namespace {
 using namespace Polycode;
 using std::vector;
 
+void SDLCoreMutex::lock()
+{
+	SDL_mutexP(pMutex);
+}
+
+void SDLCoreMutex::unlock() {
+	SDL_mutexV(pMutex);
+}
+
+
 long getThreadID() {
 	return (long)pthread_self();
 }
@@ -81,9 +93,12 @@ void Core::getScreenInfo(int *width, int *height, int *hz) {
 }
 
 SDLCore::SDLCore(PolycodeView *view, int _xRes, int _yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate, int monitorIndex, bool retinaSupport) : Core(_xRes, _yRes, fullScreen, vSync, aaLevel, anisotropyLevel, frameRate, monitorIndex) {
-
+  
 	this->resizableWindow = view->resizable;
 
+	fileProviders.push_back(new BasicFileProvider());
+	fileProviders.push_back(new PhysFSFileProvider());
+	
 	char *buffer = getcwd(NULL, 0);
 	defaultWorkingDirectory = String(buffer);
 	free(buffer);
@@ -92,22 +107,28 @@ SDLCore::SDLCore(PolycodeView *view, int _xRes, int _yRes, bool fullScreen, bool
 	const char *homedir = pw->pw_dir;
 	userHomeDirectory = String(homedir);
 
-	String *windowTitle = (String*)view->windowData;
-
+	windowTitle = (String*)view->windowData;
+	
 	if(resizableWindow) {
 		unsetenv("SDL_VIDEO_CENTERED");
 	} else {
 		setenv("SDL_VIDEO_CENTERED", "1", 1);
 	}
-
-	if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0) {
-	}
 	
+	int sdlerror = SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK);
+	if(sdlerror < 0) {
+	  Logger::log("SDL_Init failed! Code: %d, %s\n", sdlerror, SDL_GetError());
+	}
+	  
 	eventMutex = createMutex();
-	renderer = new OpenGLRenderer();
+	
+	renderer = new Renderer();
+	OpenGLGraphicsInterface *renderInterface = new OpenGLGraphicsInterface();
+	renderInterface->lineSmooth = true;
+	renderer->setGraphicsInterface(this, renderInterface);
 	services->setRenderer(renderer);
+	setVideoMode(xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel, retinaSupport);
 
-	setVideoMode(xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel);
 	SDL_WM_SetCaption(windowTitle->c_str(), windowTitle->c_str());
 	
 	SDL_EnableUNICODE(1);
@@ -121,6 +142,9 @@ SDLCore::SDLCore(PolycodeView *view, int _xRes, int _yRes, bool fullScreen, bool
 		SDL_JoystickOpen(i);
 		input->addJoystick(i);
 	}
+	
+	lastMouseX = 0;
+	lastMouseY = 0;
 
 #ifdef USE_X11
 	// Start listening to clipboard events.
@@ -128,30 +152,37 @@ SDLCore::SDLCore(PolycodeView *view, int _xRes, int _yRes, bool fullScreen, bool
 	//  clipboard events and respond to them)
 	init_scrap();
 #endif // USE_X11
-
-	((OpenGLRenderer*)renderer)->Init();
-	CoreServices::getInstance()->installModule(new GLSLShaderModule());	
 }
 
 void SDLCore::setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, bool retinaSupport) {
-	this->xRes = xRes;
-	this->yRes = yRes;
-	this->fullScreen = fullScreen;
-	this->aaLevel = aaLevel;
+	//renderer->Resize(xRes, yRes);
+	//CoreServices::getInstance()->getMaterialManager()->reloadProgramsAndTextures();
+	//dispatchEvent(new Event(), EVENT_CORE_RESIZE);
+	Core::setVideoMode(xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel, retinaSupport);
+}
+
+void SDLCore::handleVideoModeChange(VideoModeChangeInfo* modeInfo){
 
-	SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24);	
-	SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1);			
+	this->xRes = modeInfo->xRes;
+	this->yRes = modeInfo->yRes;
+	this->fullScreen = modeInfo->fullScreen;
+	this->aaLevel = modeInfo->aaLevel;
+	this->anisotropyLevel = modeInfo->anisotropyLevel;
+	this->vSync = modeInfo->vSync;
+	
+	SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24);
+	SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1);
 	SDL_GL_SetAttribute( SDL_GL_RED_SIZE,   8);
 	SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8);
 	SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE,  8);
 	SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8);
 	
 	if(aaLevel > 0) {
-		SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1);
-		SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, aaLevel); //0, 2, 4	
+		SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
+		SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, aaLevel); //0, 2, 4
 	} else {
-		SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 0);
-		SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 0);
+		SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
+		SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
 	}
 	
 	flags = SDL_OPENGL;
@@ -163,6 +194,10 @@ void SDLCore::setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int
 	if(resizableWindow) {
 		flags |= SDL_RESIZABLE;
 	}
+	
+// 	if(modeInfo->retinaSupport) {
+// 		flags |= SDL_WINDOW_ALLOW_HIGHDPI;
+// 	}
 /*
 	if(vSync) {
 		flags |= SDL_DOUBLEBUF;
@@ -170,14 +205,19 @@ void SDLCore::setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int
 		SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
 	} else {
 		SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0);
-		SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0);
+ -		SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0);
 	}
 */
+
 	SDL_SetVideoMode(xRes, yRes, 0, flags);
+
+	int glewcode = glewInit();
+	if (glewcode != GLEW_OK){
+	  Logger::log("glewInit failed! code: %d, %s\n", glewcode, glewGetErrorString(glewcode));
+	}
 	
-	renderer->Resize(xRes, yRes);
-	//CoreServices::getInstance()->getMaterialManager()->reloadProgramsAndTextures();
-	dispatchEvent(new Event(), EVENT_CORE_RESIZE);	
+	//setVSync(modeInfo->vSync);
+	renderer->setAnisotropyAmount(modeInfo->anisotropyLevel);
 }
 
 vector<Polycode::Rectangle> SDLCore::getVideoModes() {
@@ -254,10 +294,10 @@ unsigned int SDLCore::getTicks() {
 void SDLCore::enableMouse(bool newval) {
 	if(newval) {
 		SDL_ShowCursor(1);
-		SDL_WM_GrabInput(SDL_GRAB_OFF);
+		//SDL_WM_GrabInput(SDL_GRAB_OFF);
 	} else {
 		SDL_ShowCursor(0);
-		SDL_WM_GrabInput(SDL_GRAB_ON);
+		//SDL_WM_GrabInput(SDL_GRAB_ON);
 	}
 	Core::enableMouse(newval);
 }
@@ -307,9 +347,12 @@ bool SDLCore::checkSpecialKeyEvents(PolyKEY key) {
 }
 
 void SDLCore::Render() {
-	renderer->BeginRender();
-	services->Render();
-	renderer->EndRender();
+	renderer->beginFrame();
+	services->Render(Polycode::Rectangle(0, 0, getBackingXRes(), getBackingYRes()));
+	renderer->endFrame();
+}
+
+void SDLCore::flushRenderContext(){
 	SDL_GL_SwapBuffers();
 }
 
@@ -327,20 +370,19 @@ bool SDLCore::systemUpdate() {
 					running = false;
 				break;
 				case SDL_VIDEORESIZE:
-	if(resizableWindow) {
-		unsetenv("SDL_VIDEO_CENTERED");
-	} else {
-		setenv("SDL_VIDEO_CENTERED", "1", 1);
-	}
+					if(resizableWindow) {
+						unsetenv("SDL_VIDEO_CENTERED");
+					} else {
+						setenv("SDL_VIDEO_CENTERED", "1", 1);
+					}
 					this->xRes = event.resize.w;
 					this->yRes = event.resize.h;
 					SDL_SetVideoMode(xRes, yRes, 0, flags);
-					renderer->Resize(xRes, yRes);	
 					dispatchEvent(new Event(), EVENT_CORE_RESIZE);	
 				break;
 				case SDL_ACTIVEEVENT:
-					if(event.active.state == SDL_APPINPUTFOCUS) {
-						if(event.active.gain == 1) {
+					if(event.active.state == SDL_APPINPUTFOCUS){
+						if(event.active.gain == 1){
 							gainFocus();
 						} else {
 							loseFocus();
@@ -358,16 +400,16 @@ bool SDLCore::systemUpdate() {
 				break;
 				case SDL_KEYDOWN:
 					if(!checkSpecialKeyEvents((PolyKEY)(event.key.keysym.sym))) {
-						input->setKeyState((PolyKEY)(event.key.keysym.sym), (char)event.key.keysym.unicode, true, getTicks());
+						input->setKeyState((PolyKEY)(event.key.keysym.sym), event.key.keysym.unicode, true, getTicks());
 					}
 				break;
 				case SDL_KEYUP:
-					input->setKeyState((PolyKEY)(event.key.keysym.sym), (char)event.key.keysym.unicode, false, getTicks());
+					input->setKeyState((PolyKEY)(event.key.keysym.sym), event.key.keysym.unicode, false, getTicks());
 				break;
 				case SDL_MOUSEBUTTONDOWN:
-					if(event.button.button == SDL_BUTTON_WHEELUP) {
+					if(event.button.button == SDL_BUTTON_WHEELUP){
 						input->mouseWheelUp(getTicks());
-					} else if(event.button.button == SDL_BUTTON_WHEELDOWN) {
+					} else if (event.button.button == SDL_BUTTON_WHEELDOWN){
 						input->mouseWheelDown(getTicks());
 					} else {
 						switch(event.button.button) {
@@ -384,24 +426,23 @@ bool SDLCore::systemUpdate() {
 					}
 				break;
 				case SDL_MOUSEBUTTONUP:
-					if(event.button.button == SDL_BUTTON_WHEELUP || event.button.button == SDL_BUTTON_WHEELDOWN) {						
-					} else {
-						switch(event.button.button) {
-							case SDL_BUTTON_LEFT:
-								input->setMouseButtonState(CoreInput::MOUSE_BUTTON1, false, getTicks());
-							break;
-							case SDL_BUTTON_RIGHT:
-								input->setMouseButtonState(CoreInput::MOUSE_BUTTON2, false, getTicks());
-							break;
-							case SDL_BUTTON_MIDDLE:
-								input->setMouseButtonState(CoreInput::MOUSE_BUTTON3, false, getTicks());
-							break;
-						}
+					switch(event.button.button) {
+						case SDL_BUTTON_LEFT:
+							input->setMouseButtonState(CoreInput::MOUSE_BUTTON1, false, getTicks());
+						break;
+						case SDL_BUTTON_RIGHT:
+							input->setMouseButtonState(CoreInput::MOUSE_BUTTON2, false, getTicks());
+						break;
+						case SDL_BUTTON_MIDDLE:
+							input->setMouseButtonState(CoreInput::MOUSE_BUTTON3, false, getTicks());
+						break;
 					}
 				break;
 				case SDL_MOUSEMOTION:
-					input->setDeltaPosition(event.motion.xrel, event.motion.yrel);					
+					input->setDeltaPosition(lastMouseX - event.motion.x, lastMouseY - event.motion.y);					
 					input->setMousePosition(event.motion.x, event.motion.y, getTicks());
+					lastMouseY = event.motion.y;
+					lastMouseX = event.motion.x;
 				break;
 				default:
 					break;
@@ -418,9 +459,11 @@ void SDLCore::setCursor(int cursorType) {
 
 void SDLCore::warpCursor(int x, int y) {
 	SDL_WarpMouse(x, y);
+	lastMouseX = x;
+	lastMouseY = y;
 }
 
-void SDLCore::lockMutex(CoreMutex *mutex) {
+/*void SDLCore::lockMutex(CoreMutex *mutex) {
 	SDLCoreMutex *smutex = (SDLCoreMutex*)mutex;
 	SDL_mutexP(smutex->pMutex);
 
@@ -429,7 +472,7 @@ void SDLCore::lockMutex(CoreMutex *mutex) {
 void SDLCore::unlockMutex(CoreMutex *mutex) {
 	SDLCoreMutex *smutex = (SDLCoreMutex*)mutex;
 	SDL_mutexV(smutex->pMutex);
-}
+}*/
 
 CoreMutex *SDLCore::createMutex() {
 	SDLCoreMutex *mutex = new SDLCoreMutex();
@@ -441,6 +484,7 @@ void SDLCore::copyStringToClipboard(const String& str) {
 #ifdef USE_X11
 	put_scrap(T('T', 'E', 'X', 'T'), str.size(), str.c_str());
 #endif
+// 	SDL_SetClipboardText(str.c_str());
 }
 
 String SDLCore::getClipboardString() {
@@ -452,7 +496,14 @@ String SDLCore::getClipboardString() {
 	String rval(buffer, dstlen);
 	free(buffer);
 	return rval;
-#endif
+	#endif
+// 	String rval;
+// 	if(SDL_HasClipboardText() ==SDL_TRUE){
+// 		rval=SDL_GetClipboardText();
+// 	} else {
+// 		rval="";
+// 	}
+// 	return rval;
 }
 
 void SDLCore::createFolder(const String& folderPath) {
@@ -505,10 +556,31 @@ String SDLCore::saveFilePicker(std::vector<CoreFileExtension> extensions) {
 }
 
 void SDLCore::resizeTo(int xRes, int yRes) {
-	renderer->Resize(xRes, yRes);
+	this->xRes = xRes;
+	this->yRes = yRes;
+	dispatchEvent(new Event(), EVENT_CORE_RESIZE);
+}
+
+bool SDLCore::systemParseFolder(const String& pathString, bool showHidden, vector< OSFileEntry >& targetVector) {
+    DIR           *d;
+    struct dirent *dir;
+    
+    d = opendir(pathString.c_str());
+    if(d) {
+        while ((dir = readdir(d)) != NULL) {
+            if(dir->d_name[0] != '.' || (dir->d_name[0] == '.'  && showHidden)) {
+                if(dir->d_type == DT_DIR) {
+                    targetVector.push_back(OSFileEntry(pathString, dir->d_name, OSFileEntry::TYPE_FOLDER));
+                } else {
+                    targetVector.push_back(OSFileEntry(pathString, dir->d_name, OSFileEntry::TYPE_FILE));
+                }
+            }
+        }
+        closedir(d);
+    }
+    return true;
 }
 
-
 #ifdef USE_X11
 // SDL_scrap.c
 // Credits to Sam Lantinga for making this
@@ -947,4 +1019,4 @@ void free_cursors() {
 } // namespace
 // end X11 cursor
 
-#endif // USE_X11
+#endif // USE_X11

+ 14 - 8
src/ide/PolycodeProps.cpp

@@ -1677,9 +1677,10 @@ TargetBindingProp::TargetBindingProp(Shader *shader, Material *material, ShaderB
 	for(int i=0; i < material->getNumShaderRenderTargets(); i++) {
 		ShaderRenderTarget *target = material->getShaderRenderTarget(i);		
 		targetComboBox->addComboItem(target->id, (void*) target);
-		if(targetBinding->texture == target->texture) {
-			targetComboBox->setSelectedIndex(i);
-		}
+		//RENDERER_UPGRADE: TODO
+		//if(targetBinding->texture == target->texture) {
+		//	targetComboBox->setSelectedIndex(i);
+		//}
 	}
 	targetComboBox->addEventListener(this, UIEvent::CHANGE_EVENT);
 	propContents->addFocusChild(targetComboBox);
@@ -1731,7 +1732,8 @@ void TargetBindingProp::handleEvent(Event *event) {
 		} else {
 			textureComboBox->enabled = true;
 			textureComboBox->visible = true;
-			binding->setTextureForParam(targetBinding->name, targetBinding->texture);
+			//RENDERER_UPGRADE: TODO
+			//binding->setTextureForParam(targetBinding->name, targetBinding->texture);
 		}		
 		
 		if(typeComboBox->getSelectedIndex() == 2 || typeComboBox->getSelectedIndex() == 3) {
@@ -1750,7 +1752,8 @@ void TargetBindingProp::handleEvent(Event *event) {
 		dispatchEvent(new Event(), Event::CHANGE_EVENT);
 	} else if(event->getDispatcher() == targetComboBox && event->getEventCode() == UIEvent::CHANGE_EVENT) {
 		ShaderRenderTarget *target = (ShaderRenderTarget*)targetComboBox->getSelectedItem()->data;		
-		targetBinding->texture = target->texture;
+		//RENDERER_UPGRADE: TODO
+// 		targetBinding->texture = target->texture;
 		targetBinding->id  = target->id;
 		
 		binding->removeRenderTargetBinding(targetBinding);		
@@ -1758,7 +1761,8 @@ void TargetBindingProp::handleEvent(Event *event) {
 
 		binding->removeParam(targetBinding->name);
 		if(targetBinding->mode == RenderTargetBinding::MODE_IN) {
-			binding->setTextureForParam(targetBinding->name, targetBinding->texture);
+			//RENDERER_UPGRADE: TODO
+// 			binding->setTextureForParam(targetBinding->name, targetBinding->texture);
 		}
 		dispatchEvent(new Event(), Event::CHANGE_EVENT);		
 	} else if(event->getDispatcher() == textureComboBox && event->getEventCode() == UIEvent::CHANGE_EVENT) {
@@ -1768,7 +1772,8 @@ void TargetBindingProp::handleEvent(Event *event) {
 		binding->addRenderTargetBinding(targetBinding);		
 
 		binding->removeParam(targetBinding->name);
-		binding->setTextureForParam(targetBinding->name, targetBinding->texture);
+		//RENDERER_UPGRADE: TODO
+// 		binding->setTextureForParam(targetBinding->name, targetBinding->texture);
 		dispatchEvent(new Event(), Event::CHANGE_EVENT);
 	}
 }
@@ -2040,7 +2045,8 @@ void TargetBindingsSheet::handleEvent(Event *event) {
 	if(event->getDispatcher() == addButton->getButton()) {
 		RenderTargetBinding* newBinding = new RenderTargetBinding();
 		newBinding->mode = RenderTargetBinding::MODE_COLOR;
-		newBinding->texture = NULL;		
+		//RENDERER_UPGRADE: TODO
+// 		newBinding->texture = NULL;		
 		binding->addRenderTargetBinding(newBinding);				
 		refreshTargets();			
 		dispatchEvent(new Event(), Event::CHANGE_EVENT);

+ 15 - 0
src/view/linux/PolycodeView.cpp

@@ -0,0 +1,15 @@
+#include "polycode/view/linux/PolycodeView.h"
+
+namespace Polycode {
+
+    PolycodeView::PolycodeView(const char *title, bool resizable) : PolycodeViewBase() {
+        windowTitle = title;
+        windowData = &windowTitle;
+	this->resizable = resizable;
+    }
+
+    PolycodeView::~PolycodeView() {
+
+    }
+
+}

Некоторые файлы не были показаны из-за большого количества измененных файлов