Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -Naur irrlicht-code-5600-trunk/include/EDeviceTypes.h irrlicht-glfw/include/EDeviceTypes.h
- --- irrlicht-code-5600-trunk/include/EDeviceTypes.h 2012-10-01 01:38:54.000000000 +0200
- +++ irrlicht-glfw/include/EDeviceTypes.h 2018-01-22 05:08:52.000000000 +0100
- @@ -34,6 +34,11 @@
- in by defining the IRR_USE_SDL_DEVICE macro in IrrCompileConfig.h */
- EIDT_SDL,
- + //! A device which uses GLFW3
- + /** The GLFW3 device works under all platforms supported by GLFW3 but first must be compiled
- + in by defining the IRR_USE_GLFW3_DEVICE macro in IrrCompileConfig.h */
- + EIDT_GLFW3,
- +
- //! A device for raw framebuffer access
- /** Best used with embedded devices and mobile systems.
- Does not need X11 or other graphical subsystems.
- diff -Naur irrlicht-code-5600-trunk/include/IEventReceiver.h irrlicht-glfw/include/IEventReceiver.h
- --- irrlicht-code-5600-trunk/include/IEventReceiver.h 2017-11-17 16:16:43.000000000 +0100
- +++ irrlicht-glfw/include/IEventReceiver.h 2018-01-22 05:09:10.917939026 +0100
- @@ -40,7 +40,7 @@
- They take the same path as mouse events.
- Windows, SDL: Implemented.
- Linux: Implemented, with POV hat issues.
- - MacOS / Other: Not yet implemented.
- + GLFW3, MacOS / Other: Not yet implemented.
- */
- EET_JOYSTICK_INPUT_EVENT,
- diff -Naur irrlicht-code-5600-trunk/include/IrrCompileConfig.h irrlicht-glfw/include/IrrCompileConfig.h
- --- irrlicht-code-5600-trunk/include/IrrCompileConfig.h 2017-11-28 22:54:18.000000000 +0100
- +++ irrlicht-glfw/include/IrrCompileConfig.h 2018-01-22 05:18:32.000000000 +0100
- @@ -31,6 +31,7 @@
- //! _IRR_COMPILE_WITH_OSX_DEVICE_ for Cocoa native windowing on OSX
- //! _IRR_COMPILE_WITH_X11_DEVICE_ for Linux X11 based device
- //! _IRR_COMPILE_WITH_SDL_DEVICE_ for platform independent SDL framework
- +//! _IRR_COMPILE_WITH_GLFW3_DEVICE_ for platform independent GLFW3 framework
- //! _IRR_COMPILE_WITH_CONSOLE_DEVICE_ for no windowing system, used as a fallback
- //! _IRR_COMPILE_WITH_FB_DEVICE_ for framebuffer systems
- @@ -47,6 +48,12 @@
- #undef _IRR_COMPILE_WITH_SDL_DEVICE_
- #endif
- +//! Uncomment this line to compile with the GLFW3 device
- +#define _IRR_COMPILE_WITH_GLFW3_DEVICE_
- +#ifdef NO_IRR_COMPILE_WITH_GLFW3_DEVICE_
- +#undef _IRR_COMPILE_WITH_GLFW3_DEVICE_
- +#endif
- +
- //! Comment this line to compile without the fallback console device.
- #define _IRR_COMPILE_WITH_CONSOLE_DEVICE_
- #ifdef NO_IRR_COMPILE_WITH_CONSOLE_DEVICE_
- diff -Naur irrlicht-code-5600-trunk/include/SIrrCreationParameters.h irrlicht-glfw/include/SIrrCreationParameters.h
- --- irrlicht-code-5600-trunk/include/SIrrCreationParameters.h 2016-08-13 14:50:06.000000000 +0200
- +++ irrlicht-glfw/include/SIrrCreationParameters.h 2018-01-22 05:13:02.000000000 +0100
- @@ -90,6 +90,7 @@
- EIDT_COCOA is only available on Mac OSX,
- EIDT_X11 is available on Linux, Solaris, BSD and other operating systems which use X11,
- EIDT_SDL is available on most systems if compiled in,
- + EIDT_GLFW3 is available on most systems if compiled in,
- EIDT_CONSOLE is usually available but can only render to text,
- EIDT_BEST will select the best available device for your operating system.
- Default: EIDT_BEST. */
- diff -Naur irrlicht-code-5600-trunk/source/Irrlicht/CIrrDeviceGLFW3.cpp irrlicht-glfw/source/Irrlicht/CIrrDeviceGLFW3.cpp
- --- irrlicht-code-5600-trunk/source/Irrlicht/CIrrDeviceGLFW3.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ irrlicht-glfw/source/Irrlicht/CIrrDeviceGLFW3.cpp 2018-01-22 20:40:34.453904562 +0100
- @@ -0,0 +1,785 @@
- +// Copyright (C) 2002-2012 Nikolaus Gebhardt
- +// This file is part of the "Irrlicht Engine".
- +// For conditions of distribution and use, see copyright notice in irrlicht.h
- +
- +#include "IrrCompileConfig.h"
- +
- +#ifdef _IRR_COMPILE_WITH_GLFW3_DEVICE_
- +
- +#include "CIrrDeviceGLFW3.h"
- +#include "IEventReceiver.h"
- +#include "irrList.h"
- +#include "os.h"
- +#include "CTimer.h"
- +#include "irrString.h"
- +#include "Keycodes.h"
- +#include "COSOperator.h"
- +#include <stdio.h>
- +#include <stdlib.h>
- +#include <iostream>
- +#include "SIrrCreationParameters.h"
- +
- +static int GLFW3DeviceInstances = 0;
- +
- +namespace irr
- +{
- + namespace video
- + {
- + #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
- + IVideoDriver* createDirectX9Driver(const irr::SIrrlichtCreationParameters& params,
- + io::IFileSystem* io, HWND window);
- + #endif
- +
- + #ifdef _IRR_COMPILE_WITH_OPENGL_
- + IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
- + io::IFileSystem* io, CIrrDeviceGLFW3* device);
- + #endif
- + } // end namespace video
- +
- +} // end namespace irr
- +
- +
- +namespace irr
- +{
- +
- +//! constructor
- +CIrrDeviceGLFW3::CIrrDeviceGLFW3(const SIrrlichtCreationParameters& param)
- + : CIrrDeviceStub(param),
- + window((GLFWwindow*)param.WindowId),
- + MouseX(0), MouseY(0), MouseButtonStates(0),
- + Width(param.WindowSize.Width), Height(param.WindowSize.Height),
- + Resizable(false), WindowHasFocus(false), WindowMinimized(false)
- +{
- + #ifdef _DEBUG
- + setDebugName("CIrrDeviceGLFW3");
- + #endif
- +
- + if ( ++GLFW3DeviceInstances == 1 )
- + {
- + if (glfwInit() == GLFW_FALSE){
- + os::Printer::log("Unable to initialize GLFW3!");
- + Close = true;
- + }
- +
- + glfwSetTime(0);
- +
- + //glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
- + //glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
- +
- + //glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
- + //glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
- + }
- +
- + int major, minor, rev;
- + glfwGetVersion(&major,&minor,&rev);
- +
- + core::stringc GLFW3version = "GLFW3 Version ";
- + GLFW3version += major;
- + GLFW3version += ".";
- + GLFW3version += minor;
- + GLFW3version += ".";
- + GLFW3version += rev;
- +
- + Operator = new COSOperator(GLFW3version);
- + if ( GLFW3DeviceInstances == 1 )
- + {
- + os::Printer::log(GLFW3version.c_str(), ELL_INFORMATION);
- + }
- +
- + // create keymap
- + createKeyMap();
- +
- + // enable key to character translation (UNICODE)
- + // typedef void(* GLFWcharfun) (GLFWwindow *, unsigned int)
- +
- + if ( CreationParams.Fullscreen ) {
- + // Fullscreen ( http://www.glfw.org/docs/latest/window_guide.html#window_full_screen )
- + }
- +
- + // create window
- + if (CreationParams.DriverType == video::EDT_OPENGL)
- + {
- + // create the window, only if we do not use the null device
- + createWindow();
- + }
- + else
- + {
- + os::Printer::log("GLFW3 only works with OpenGL!");
- + Close = true;
- + }
- +
- + // create cursor control
- + CursorControl = new CCursorControl(this);
- +
- + // create driver
- + createDriver();
- +
- + if (VideoDriver)
- + createGUIAndScene();
- +}
- +
- +
- +//! destructor
- +CIrrDeviceGLFW3::~CIrrDeviceGLFW3()
- +{
- + if ( --GLFW3DeviceInstances == 0 )
- + {
- +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
- + //ToDo
- +#endif
- + glfwTerminate();
- +
- + os::Printer::log("Quit GLFW3", ELL_INFORMATION);
- + }
- +}
- +
- +
- +bool CIrrDeviceGLFW3::createWindow()
- +{
- + if ( Close )
- + return false;
- +
- + if (CreationParams.DriverType == video::EDT_OPENGL)
- + {
- + if (CreationParams.Bits==16)
- + {
- + glfwWindowHint(GLFW_RED_BITS, 4);
- + glfwWindowHint(GLFW_GREEN_BITS, 4);
- + glfwWindowHint(GLFW_BLUE_BITS, 4);
- + glfwWindowHint(GLFW_ALPHA_BITS, CreationParams.WithAlphaChannel?1:0);
- + }
- + else
- + {
- + glfwWindowHint(GLFW_RED_BITS, 8);
- + glfwWindowHint(GLFW_GREEN_BITS, 8);
- + glfwWindowHint(GLFW_BLUE_BITS, 8);
- + glfwWindowHint(GLFW_ALPHA_BITS, CreationParams.WithAlphaChannel?8:0);
- + }
- +
- + glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
- + glfwWindowHint(GLFW_STENCIL_BITS, CreationParams.Stencilbuffer?8:0);
- + glfwWindowHint(GLFW_DEPTH_BITS, CreationParams.ZBufferBits?CreationParams.ZBufferBits:24);
- +
- + if (CreationParams.Doublebuffer)
- + glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE);
- +
- + if (CreationParams.Stereobuffer)
- + glfwWindowHint(GLFW_STEREO, GLFW_TRUE);
- +
- + if (CreationParams.AntiAlias>1)
- + glfwWindowHint(GLFW_SAMPLES, CreationParams.AntiAlias);
- + else
- + glfwWindowHint(GLFW_SAMPLES, GLFW_DONT_CARE);
- +
- + if (window == nullptr && CreationParams.AntiAlias>1)
- + {
- + while (--CreationParams.AntiAlias>1)
- + {
- + glfwWindowHint(GLFW_SAMPLES, CreationParams.AntiAlias);
- + window = glfwCreateWindow(Width, Height, "Irrlicht GLFW3 window", nullptr, nullptr);
- + if (window)
- + break;
- + }
- + if (window == nullptr)
- + {
- + glfwWindowHint(GLFW_SAMPLES, GLFW_DONT_CARE);
- + window = glfwCreateWindow(Width, Height, "Irrlicht GLFW3 window", nullptr, nullptr);
- + if (window)
- + os::Printer::log("AntiAliasing disabled due to lack of support!" );
- + }
- + }
- + else if (window == nullptr && CreationParams.AntiAlias <= 1)
- + {
- + window = glfwCreateWindow(Width, Height, "Irrlicht GLFW3 window", nullptr, nullptr);
- + }
- +
- + if (window == nullptr) {
- + os::Printer::log("Unable to initialize GLFW3 window!");
- + glfwTerminate();
- + return false;
- + } else {
- + glfwMakeContextCurrent(window);
- +
- + glClearColor(0.2f, 0.25f, 0.3f, 1.0f);
- + glClear(GL_COLOR_BUFFER_BIT);
- +
- + int width, height;
- + glfwGetFramebufferSize(window, &width, &height);
- + glViewport(0, 0, width, height);
- + glfwSwapInterval(0);
- + glfwSwapBuffers(window);
- +
- + if (!CreationParams.IgnoreInput){
- + glfwSetWindowUserPointer(window, this);
- +
- + glfwSetCursorPosCallback(window,
- + [](GLFWwindow *w, double x, double y) {
- +
- + CIrrDeviceGLFW3 *obj = (CIrrDeviceGLFW3*)glfwGetWindowUserPointer(w);
- +
- + obj->irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
- + obj->irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
- + obj->MouseX = obj->irrevent.MouseInput.X = x;
- + obj->MouseY = obj->irrevent.MouseInput.Y = y;
- + obj->irrevent.MouseInput.ButtonStates = obj->MouseButtonStates;
- +
- + obj->postEventFromUser(obj->irrevent);
- + }
- + );
- +
- + glfwSetMouseButtonCallback(window,
- + [](GLFWwindow *w, int button, int action, int modifiers) {
- +
- + CIrrDeviceGLFW3 *obj = (CIrrDeviceGLFW3*)glfwGetWindowUserPointer(w);
- +
- + if (action == GLFW_PRESS){
- + switch(button){
- + case GLFW_MOUSE_BUTTON_LEFT:
- + obj->irrevent.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN;
- + obj->MouseButtonStates |= irr::EMBSM_LEFT;
- + break;
- + case GLFW_MOUSE_BUTTON_RIGHT:
- + obj->irrevent.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN;
- + obj->MouseButtonStates |= irr::EMBSM_RIGHT;
- + break;
- + case GLFW_MOUSE_BUTTON_MIDDLE:
- + obj->irrevent.MouseInput.Event = irr::EMIE_MMOUSE_PRESSED_DOWN;
- + obj->MouseButtonStates |= irr::EMBSM_MIDDLE;
- + break;
- + }
- + } else if (action == GLFW_RELEASE){
- + switch(button){
- + case GLFW_MOUSE_BUTTON_LEFT:
- + obj->irrevent.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP;
- + obj->MouseButtonStates &= !irr::EMBSM_LEFT;
- + break;
- + case GLFW_MOUSE_BUTTON_RIGHT:
- + obj->irrevent.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP;
- + obj->MouseButtonStates &= !irr::EMBSM_RIGHT;
- + break;
- + case GLFW_MOUSE_BUTTON_MIDDLE:
- + obj->irrevent.MouseInput.Event = irr::EMIE_MMOUSE_LEFT_UP;
- + obj->MouseButtonStates &= !irr::EMBSM_MIDDLE;
- + break;
- + }
- + }
- +
- + obj->irrevent.MouseInput.ButtonStates = obj->MouseButtonStates;
- +
- + if (obj->irrevent.MouseInput.Event != irr::EMIE_MOUSE_MOVED)
- + {
- + obj->postEventFromUser(obj->irrevent);
- +
- + if ( obj->irrevent.MouseInput.Event >= EMIE_LMOUSE_PRESSED_DOWN && obj->irrevent.MouseInput.Event <= EMIE_MMOUSE_PRESSED_DOWN )
- + {
- + u32 clicks = obj->checkSuccessiveClicks(obj->irrevent.MouseInput.X, obj->irrevent.MouseInput.Y, obj->irrevent.MouseInput.Event);
- + if ( clicks == 2 )
- + {
- + obj->irrevent.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_DOUBLE_CLICK + obj->irrevent.MouseInput.Event-EMIE_LMOUSE_PRESSED_DOWN);
- + obj->postEventFromUser(obj->irrevent);
- + }
- + else if ( clicks == 3 )
- + {
- + obj->irrevent.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_TRIPLE_CLICK + obj->irrevent.MouseInput.Event-EMIE_LMOUSE_PRESSED_DOWN);
- + obj->postEventFromUser(obj->irrevent);
- + }
- + }
- + }
- + }
- + );
- +
- + glfwSetScrollCallback(window,
- + [](GLFWwindow *w, double x, double y) {
- + CIrrDeviceGLFW3 *obj = (CIrrDeviceGLFW3*)glfwGetWindowUserPointer(w);
- + if (y < 0){
- + obj->irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL;
- + obj->irrevent.MouseInput.Wheel = 1.0f;
- + }
- + else
- + {
- + obj->irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL;
- + obj->irrevent.MouseInput.Wheel = -1.0f;
- + }
- + }
- + );
- +
- + glfwSetCharModsCallback(window,
- + [](GLFWwindow *w, unsigned int codepoint, int mods) {
- + CIrrDeviceGLFW3 *obj = (CIrrDeviceGLFW3*)glfwGetWindowUserPointer(w);
- + SKeyMap mp;
- + mp.GLFW3Key = codepoint;
- + s32 idx = obj->KeyMap.binary_search(mp);
- +
- + EKEY_CODE key;
- + if (idx == -1)
- + key = (EKEY_CODE)0;
- + else
- + key = (EKEY_CODE)obj->KeyMap[idx].Win32Key;
- +
- + obj->irrevent.EventType = irr::EET_KEY_INPUT_EVENT;
- + obj->irrevent.KeyInput.Char = codepoint;
- + obj->irrevent.KeyInput.Key = key;
- + obj->irrevent.KeyInput.PressedDown = true;
- + obj->irrevent.KeyInput.Shift = (mods == GLFW_MOD_SHIFT);
- + obj->irrevent.KeyInput.Control = (mods == GLFW_MOD_CONTROL);
- + obj->postEventFromUser(obj->irrevent);
- + }
- + );
- +
- + glfwSetWindowFocusCallback(window,
- + [](GLFWwindow *w, int focused) {
- + CIrrDeviceGLFW3 *obj = (CIrrDeviceGLFW3*)glfwGetWindowUserPointer(w);
- + obj->WindowHasFocus = (focused == GLFW_TRUE);
- + }
- + );
- +
- + glfwSetWindowIconifyCallback(window,
- + [](GLFWwindow *w, int iconified) {
- + CIrrDeviceGLFW3 *obj = (CIrrDeviceGLFW3*)glfwGetWindowUserPointer(w);
- + obj->WindowMinimized = (iconified == GLFW_TRUE);
- + }
- + );
- +
- + glfwSetWindowSizeCallback(window,
- + [](GLFWwindow *win, int w, int h) {
- + CIrrDeviceGLFW3 *obj = (CIrrDeviceGLFW3*)glfwGetWindowUserPointer(win);
- + if ((w != (int)obj->Width) || (h != (int)obj->Height))
- + {
- + obj->Width = w;
- + obj->Height = h;
- + if (obj->VideoDriver)
- + obj->VideoDriver->OnResize(core::dimension2d<u32>(obj->Width, obj->Height));
- + }
- + }
- + );
- +
- + glfwSetWindowCloseCallback(window,
- + [](GLFWwindow *w) {
- + CIrrDeviceGLFW3 *obj = (CIrrDeviceGLFW3*)glfwGetWindowUserPointer(w);
- + obj->Close = true;
- + }
- + );
- +
- + #if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
- + //ToDo: joystick
- + #endif
- + }
- +
- + return true;
- + }
- + } else {
- + os::Printer::log("Only OpenGL is supported!");
- + return false;
- + }
- +}
- +
- +
- +//! create the driver
- +void CIrrDeviceGLFW3::createDriver()
- +{
- + switch(CreationParams.DriverType)
- + {
- + case video::DEPRECATED_EDT_DIRECT3D8_NO_LONGER_EXISTS:
- + os::Printer::log("DIRECT3D8 Driver is no longer supported in Irrlicht. Try another one.", ELL_ERROR);
- + break;
- +
- + case video::EDT_DIRECT3D9:
- + #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
- + os::Printer::log("Only OpenGL is supported!");
- + #else
- + os::Printer::log("DIRECT3D9 Driver was not compiled into this dll. Try another one.", ELL_ERROR);
- + #endif // _IRR_COMPILE_WITH_DIRECT3D_9_
- +
- + break;
- +
- + case video::EDT_SOFTWARE:
- + #ifdef _IRR_COMPILE_WITH_SOFTWARE_
- + os::Printer::log("Only OpenGL is supported!");
- + #else
- + os::Printer::log("No Software driver support compiled in.", ELL_ERROR);
- + #endif
- + break;
- +
- + case video::EDT_BURNINGSVIDEO:
- + #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
- + os::Printer::log("Only OpenGL is supported!");
- + #else
- + os::Printer::log("Burning's video driver was not compiled in.", ELL_ERROR);
- + #endif
- + break;
- +
- + case video::EDT_OPENGL:
- + #ifdef _IRR_COMPILE_WITH_OPENGL_
- + VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, this);
- + #else
- + os::Printer::log("No OpenGL support compiled in.", ELL_ERROR);
- + #endif
- + break;
- +
- + case video::EDT_NULL:
- + VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
- + break;
- +
- + default:
- + os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR);
- + break;
- + }
- +}
- +
- +
- +//! runs the device. Returns false if device wants to be deleted
- +bool CIrrDeviceGLFW3::run()
- +{
- + os::Timer::tick();
- +
- + glfwPollEvents();
- +
- + /*
- + irrevent.EventType = irr::EET_USER_EVENT;
- + irrevent.UserEvent.UserData1 = reinterpret_cast<uintptr_t>(SDL_event.user.data1);
- + irrevent.UserEvent.UserData2 = reinterpret_cast<uintptr_t>(SDL_event.user.data2);
- +
- + postEventFromUser(irrevent);
- + */
- +
- + return !Close;
- +}
- +
- +//! Activate any joysticks, and generate events for them.
- +bool CIrrDeviceGLFW3::activateJoysticks(core::array<SJoystickInfo> & joystickInfo)
- +{
- +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
- + return true;
- +#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
- + return false;
- +}
- +
- +
- +
- +//! pause execution temporarily
- +void CIrrDeviceGLFW3::yield()
- +{
- + glfwWaitEventsTimeout(0.1);
- +}
- +
- +
- +//! pause execution for a specified time
- +void CIrrDeviceGLFW3::sleep(u32 timeMs, bool pauseTimer)
- +{
- + const bool wasStopped = Timer ? Timer->isStopped() : true;
- + if (pauseTimer && !wasStopped)
- + Timer->stop();
- +
- + glfwWaitEventsTimeout(timeMs/1000);
- +
- + if (pauseTimer && !wasStopped)
- + Timer->start();
- +}
- +
- +
- +//! sets the caption of the window
- +void CIrrDeviceGLFW3::setWindowCaption(const wchar_t* text)
- +{
- + core::stringc textc = text;
- + glfwSetWindowTitle(window, textc.c_str( ));
- +}
- +
- +
- +//! presents a surface in the client area
- +bool CIrrDeviceGLFW3::present(video::IImage* surface, void* windowId, core::rect<s32>* srcClip)
- +{
- + GLFWwindow *w = (GLFWwindow*)windowId;
- +
- + if (!w) w = window;
- +
- + glfwSwapBuffers(w);
- +
- + std::cout << "Aqui estoy" << std::endl;
- +
- + return true;
- +}
- +
- +
- +//! notifies the device that it should close itself
- +void CIrrDeviceGLFW3::closeDevice()
- +{
- + Close = true;
- +}
- +
- +
- +//! \return Pointer to a list with all video modes supported
- +video::IVideoModeList* CIrrDeviceGLFW3::getVideoModeList()
- +{
- + if (!VideoModeList->getVideoModeCount())
- + {
- + int count;
- + const GLFWvidmode* modes = glfwGetVideoModes(glfwGetPrimaryMonitor(), &count);
- +
- + for (int i=0; i<count; i++){
- + VideoModeList->addMode(core::dimension2d<u32>(modes[i].width, modes[i].height), modes[i].redBits+modes[i].blueBits+modes[i].greenBits);
- +
- + }
- + }
- +
- + return VideoModeList;
- +}
- +
- +
- +//! Sets if the window should be resizable in windowed mode.
- +void CIrrDeviceGLFW3::setResizable(bool resize)
- +{
- + if (resize != Resizable)
- + {
- + if (resize)
- + glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
- + else
- + glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
- + //Screen = SDL_SetVideoMode( 0, 0, 0, SDL_Flags );
- + Resizable = resize;
- + }
- +}
- +
- +
- +//! Minimizes window if possible
- +void CIrrDeviceGLFW3::minimizeWindow()
- +{
- + glfwIconifyWindow(window);
- +}
- +
- +
- +//! Maximize window
- +void CIrrDeviceGLFW3::maximizeWindow()
- +{
- + glfwMaximizeWindow(window);
- +}
- +
- +//! Get the position of this window on screen
- +core::position2di CIrrDeviceGLFW3::getWindowPosition()
- +{
- + int x, y;
- + glfwGetWindowPos (window, &x, &y);
- + return core::position2di(x, y);
- +}
- +
- +
- +//! Restore original window size
- +void CIrrDeviceGLFW3::restoreWindow()
- +{
- + glfwRestoreWindow(window);
- +}
- +
- +
- +//! returns if window is active. if not, nothing need to be drawn
- +bool CIrrDeviceGLFW3::isWindowActive() const
- +{
- + return (WindowHasFocus && !WindowMinimized);
- +}
- +
- +
- +//! returns if window has focus.
- +bool CIrrDeviceGLFW3::isWindowFocused() const
- +{
- + return WindowHasFocus;
- +}
- +
- +
- +//! returns if window is minimized.
- +bool CIrrDeviceGLFW3::isWindowMinimized() const
- +{
- + return WindowMinimized;
- +}
- +
- +
- +//! Set the current Gamma Value for the Display
- +bool CIrrDeviceGLFW3::setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast )
- +{
- + //glfwSetGammaRamp (glfwGetPrimaryMonitor(), new GLFWgammaramp(red, green, blue, ¿?));
- + return false;
- +}
- +
- +//! Get the current Gamma Value for the Display
- +bool CIrrDeviceGLFW3::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast )
- +{
- +/* GLFWgammaramp *ramp = glfwGetGammaRamp(glfwGetPrimaryMonitor());
- + brightness = 0.f;
- + contrast = 0.f;
- + return (SDL_GetGamma(&ramp.red, &ramp.green, &ramp.blue) != -1);*/
- + return false;
- +}
- +
- +//! returns color format of the window.
- +video::ECOLOR_FORMAT CIrrDeviceGLFW3::getColorFormat() const
- +{
- + if (window)
- + {
- + const GLFWvidmode* mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
- + if ((mode->redBits+mode->blueBits+mode->greenBits)==16)
- + {
- + return video::ECF_R5G6B5;
- + }
- + else
- + {
- + return video::ECF_R8G8B8;
- + }
- + }
- + else
- + return CIrrDeviceStub::getColorFormat();
- +}
- +
- +
- +void CIrrDeviceGLFW3::createKeyMap()
- +{
- + // I don't know if this is the best method to create
- + // the lookuptable, but I'll leave it like that until
- + // I find a better version.
- +
- + KeyMap.reallocate(105);
- +
- + // buttons missing
- +
- + KeyMap.push_back(SKeyMap(GLFW_KEY_BACKSPACE, KEY_BACK));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_TAB , KEY_TAB));
- + //KeyMap.push_back(SKeyMap(SDLK_CLEAR, KEY_CLEAR));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_ENTER, KEY_RETURN));
- +
- + // combined modifiers missing
- +
- + KeyMap.push_back(SKeyMap(GLFW_KEY_PAUSE, KEY_PAUSE));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_CAPS_LOCK, KEY_CAPITAL));
- +
- + // asian letter keys missing
- +
- + KeyMap.push_back(SKeyMap(GLFW_KEY_ESCAPE , KEY_ESCAPE));
- +
- + // asian letter keys missing
- +
- + KeyMap.push_back(SKeyMap(GLFW_KEY_SPACE, KEY_SPACE));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_PAGE_UP, KEY_PRIOR));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_PAGE_DOWN, KEY_NEXT));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_END , KEY_END));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_HOME , KEY_HOME));
- +
- + KeyMap.push_back(SKeyMap(GLFW_KEY_LEFT , KEY_LEFT));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_UP, KEY_UP));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_RIGHT, KEY_RIGHT));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_DOWN, KEY_DOWN));
- +
- + // select missing
- +
- + //KeyMap.push_back(SKeyMap(SDLK_PRINT, KEY_PRINT));
- +
- + // execute missing
- +
- + KeyMap.push_back(SKeyMap(GLFW_KEY_PRINT_SCREEN, KEY_SNAPSHOT));
- +
- + KeyMap.push_back(SKeyMap(GLFW_KEY_INSERT, KEY_INSERT));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_DELETE , KEY_DELETE));
- + //KeyMap.push_back(SKeyMap(SDLK_HELP, KEY_HELP));
- +
- + KeyMap.push_back(SKeyMap(GLFW_KEY_0, KEY_KEY_0));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_1, KEY_KEY_1));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_2, KEY_KEY_2));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_3, KEY_KEY_3));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_4, KEY_KEY_4));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_5, KEY_KEY_5));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_6, KEY_KEY_6));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_7, KEY_KEY_7));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_8, KEY_KEY_8));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_9, KEY_KEY_9));
- +
- + KeyMap.push_back(SKeyMap(GLFW_KEY_A, KEY_KEY_A));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_B, KEY_KEY_B));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_C, KEY_KEY_C));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_D, KEY_KEY_D));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_E, KEY_KEY_E));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_F, KEY_KEY_F));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_G, KEY_KEY_G));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_H, KEY_KEY_H));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_I, KEY_KEY_I));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_J, KEY_KEY_J));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_K, KEY_KEY_K));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_L, KEY_KEY_L));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_M, KEY_KEY_M));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_N, KEY_KEY_N));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_O, KEY_KEY_O));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_P, KEY_KEY_P));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_Q, KEY_KEY_Q));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_R, KEY_KEY_R));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_S, KEY_KEY_S));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_T, KEY_KEY_T));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_U, KEY_KEY_U));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_V, KEY_KEY_V));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_W, KEY_KEY_W));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_X, KEY_KEY_X));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_Y, KEY_KEY_Y));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_Z, KEY_KEY_Z));
- +
- + KeyMap.push_back(SKeyMap(GLFW_KEY_LEFT_SUPER , KEY_LWIN));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_RIGHT_SUPER , KEY_RWIN));
- +
- + // apps missing
- +
- + KeyMap.push_back(SKeyMap(GLFW_KEY_MENU , KEY_SLEEP)); //??
- +
- + KeyMap.push_back(SKeyMap(GLFW_KEY_KP_0, KEY_NUMPAD0));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_KP_1, KEY_NUMPAD1));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_KP_2, KEY_NUMPAD2));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_KP_3, KEY_NUMPAD3));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_KP_4, KEY_NUMPAD4));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_KP_5, KEY_NUMPAD5));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_KP_6, KEY_NUMPAD6));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_KP_7, KEY_NUMPAD7));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_KP_8, KEY_NUMPAD8));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_KP_9, KEY_NUMPAD9));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_KP_MULTIPLY, KEY_MULTIPLY));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_KP_ADD, KEY_ADD));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_KP_SUBTRACT, KEY_SUBTRACT));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_KP_DECIMAL, KEY_DECIMAL));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_KP_DIVIDE , KEY_DIVIDE));
- +// KeyMap.push_back(SKeyMap(SDLK_KP_, KEY_SEPARATOR));
- +
- + KeyMap.push_back(SKeyMap(GLFW_KEY_F1 , KEY_F1));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_F2 , KEY_F2));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_F3 , KEY_F3));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_F4 , KEY_F4));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_F5 , KEY_F5));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_F6 , KEY_F6));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_F7 , KEY_F7));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_F8 , KEY_F8));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_F9 , KEY_F9));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_F10 , KEY_F10));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_F11 , KEY_F11));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_F12 , KEY_F12));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_F13 , KEY_F13));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_F14 , KEY_F14));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_F15 , KEY_F15));
- +
- + // no higher F-keys
- +
- + KeyMap.push_back(SKeyMap(GLFW_KEY_NUM_LOCK, KEY_NUMLOCK));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_SCROLL_LOCK, KEY_SCROLL));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_LEFT_SHIFT, KEY_LSHIFT));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_RIGHT_SHIFT, KEY_RSHIFT));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_LEFT_CONTROL, KEY_LCONTROL));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_RIGHT_CONTROL, KEY_RCONTROL));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_LEFT_ALT, KEY_LMENU));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_RIGHT_ALT, KEY_RMENU));
- +
- + //KeyMap.push_back(SKeyMap(SDLK_PLUS, KEY_PLUS));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_COMMA, KEY_COMMA));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_MINUS, KEY_MINUS));
- + KeyMap.push_back(SKeyMap(GLFW_KEY_PERIOD , KEY_PERIOD));
- +
- + // some special keys missing
- +
- + KeyMap.sort();
- +}
- +
- +GLFWwindow *CIrrDeviceGLFW3::getWindow(){
- + return window;
- +}
- +
- +} // end namespace irr
- +
- +#endif // _IRR_COMPILE_WITH_GLFW3_DEVICE_
- +
- diff -Naur irrlicht-code-5600-trunk/source/Irrlicht/CIrrDeviceGLFW3.h irrlicht-glfw/source/Irrlicht/CIrrDeviceGLFW3.h
- --- irrlicht-code-5600-trunk/source/Irrlicht/CIrrDeviceGLFW3.h 1970-01-01 01:00:00.000000000 +0100
- +++ irrlicht-glfw/source/Irrlicht/CIrrDeviceGLFW3.h 2018-01-22 15:54:04.000000000 +0100
- @@ -0,0 +1,273 @@
- +// Copyright (C) 2002-2012 Nikolaus Gebhardt
- +// This file is part of the "Irrlicht Engine".
- +// For conditions of distribution and use, see copyright notice in irrlicht.h
- +// This device code is based on the original GLFW3 device implementation
- +// contributed by Shane Parker (sirshane).
- +
- +#ifndef __C_IRR_DEVICE_GLFW3_H_INCLUDED__
- +#define __C_IRR_DEVICE_GLFW3_H_INCLUDED__
- +
- +#include "IrrCompileConfig.h"
- +
- +#ifdef _IRR_COMPILE_WITH_GLFW3_DEVICE_
- +
- +#include "IrrlichtDevice.h"
- +#include "CIrrDeviceStub.h"
- +#include "IImagePresenter.h"
- +#include "ICursorControl.h"
- +
- +#include <GLFW/glfw3.h>
- +
- +namespace irr
- +{
- +
- + class CIrrDeviceGLFW3 : public CIrrDeviceStub, video::IImagePresenter
- + {
- + public:
- +
- + //! constructor
- + CIrrDeviceGLFW3(const SIrrlichtCreationParameters& param);
- +
- + //! destructor
- + virtual ~CIrrDeviceGLFW3();
- +
- + //! runs the device. Returns false if device wants to be deleted
- + virtual bool run() _IRR_OVERRIDE_;
- +
- + //! pause execution temporarily
- + virtual void yield() _IRR_OVERRIDE_;
- +
- + //! pause execution for a specified time
- + virtual void sleep(u32 timeMs, bool pauseTimer) _IRR_OVERRIDE_;
- +
- + //! sets the caption of the window
- + virtual void setWindowCaption(const wchar_t* text) _IRR_OVERRIDE_;
- +
- + //! returns if window is active. if not, nothing need to be drawn
- + virtual bool isWindowActive() const _IRR_OVERRIDE_;
- +
- + //! returns if window has focus.
- + bool isWindowFocused() const _IRR_OVERRIDE_;
- +
- + //! returns if window is minimized.
- + bool isWindowMinimized() const _IRR_OVERRIDE_;
- +
- + //! returns color format of the window.
- + video::ECOLOR_FORMAT getColorFormat() const _IRR_OVERRIDE_;
- +
- + //! presents a surface in the client area
- + virtual bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0) _IRR_OVERRIDE_;
- +
- + //! notifies the device that it should close itself
- + virtual void closeDevice() _IRR_OVERRIDE_;
- +
- + //! \return Returns a pointer to a list with all video modes supported
- + virtual video::IVideoModeList* getVideoModeList() _IRR_OVERRIDE_;
- +
- + //! Sets if the window should be resizable in windowed mode.
- + virtual void setResizable(bool resize=false) _IRR_OVERRIDE_;
- +
- + //! Minimizes the window.
- + virtual void minimizeWindow() _IRR_OVERRIDE_;
- +
- + //! Maximizes the window.
- + virtual void maximizeWindow() _IRR_OVERRIDE_;
- +
- + //! Restores the window size.
- + virtual void restoreWindow() _IRR_OVERRIDE_;
- +
- + //! Get the position of this window on screen
- + virtual core::position2di getWindowPosition() _IRR_OVERRIDE_;
- +
- + //! Activate any joysticks, and generate events for them.
- + virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo) _IRR_OVERRIDE_;
- +
- + //! Set the current Gamma Value for the Display
- + virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) _IRR_OVERRIDE_;
- +
- + //! Get the current Gamma Value for the Display
- + virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) _IRR_OVERRIDE_;
- +
- + //! Get the device type
- + virtual E_DEVICE_TYPE getType() const _IRR_OVERRIDE_
- + {
- + return EIDT_GLFW3;
- + }
- +
- + //get the window
- + virtual GLFWwindow *getWindow();
- +
- + //! Implementation of the linux cursor control
- + class CCursorControl : public gui::ICursorControl
- + {
- + public:
- +
- + CCursorControl(CIrrDeviceGLFW3* dev)
- + : Device(dev), IsVisible(true)
- + {
- + }
- +
- + //! Changes the visible state of the mouse cursor.
- + virtual void setVisible(bool visible) _IRR_OVERRIDE_
- + {
- + IsVisible = visible;
- + if ( visible )
- + glfwSetInputMode(Device->window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
- + else
- + glfwSetInputMode(Device->window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
- + }
- +
- + //! Returns if the cursor is currently visible.
- + virtual bool isVisible() const _IRR_OVERRIDE_
- + {
- + return IsVisible;
- + }
- +
- + //! Sets the new position of the cursor.
- + virtual void setPosition(const core::position2d<f32> &pos) _IRR_OVERRIDE_
- + {
- + setPosition(pos.X, pos.Y);
- + }
- +
- + //! Sets the new position of the cursor.
- + virtual void setPosition(f32 x, f32 y) _IRR_OVERRIDE_
- + {
- + setPosition((s32)(x*Device->Width), (s32)(y*Device->Height));
- + }
- +
- + //! Sets the new position of the cursor.
- + virtual void setPosition(const core::position2d<s32> &pos) _IRR_OVERRIDE_
- + {
- + setPosition(pos.X, pos.Y);
- + }
- +
- + //! Sets the new position of the cursor.
- + virtual void setPosition(s32 x, s32 y) _IRR_OVERRIDE_
- + {
- + glfwSetCursorPos (Device->window, x, y);
- + }
- +
- + //! Returns the current position of the mouse cursor.
- + virtual const core::position2d<s32>& getPosition() _IRR_OVERRIDE_
- + {
- + updateCursorPos();
- + return CursorPos;
- + }
- +
- + //! Returns the current position of the mouse cursor.
- + virtual core::position2d<f32> getRelativePosition() _IRR_OVERRIDE_
- + {
- + updateCursorPos();
- + return core::position2d<f32>(CursorPos.X / (f32)Device->Width,
- + CursorPos.Y / (f32)Device->Height);
- + }
- +
- + //
- + virtual void setReferenceRect(core::rect<s32>* rect=0) _IRR_OVERRIDE_
- + {
- + //Nothing to do here
- + }
- +
- + //! Sets the active cursor icon
- + virtual void setActiveIcon(gui::ECURSOR_ICON iconId) _IRR_OVERRIDE_
- + {
- + GLFWcursor* cursor = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR); //ToDo: tipo de cursor
- + glfwSetCursor(Device->window, cursor);
- + }
- +
- + //! Gets the currently active icon
- + //virtual gui::ECURSOR_ICON getActiveIcon() const _IRR_OVERRIDE_ = 0;
- +
- + //! Add a custom sprite as cursor icon.
- + //virtual gui::ECURSOR_ICON addIcon(const gui::SCursorSprite& icon) _IRR_OVERRIDE_ = 0;
- + /*{
- + unsigned char pixels[16 * 16 * 4];
- + memset(pixels, 0xff, sizeof(pixels));
- + GLFWimage image;
- + image.width = 16;
- + image.height = 16;
- + image.pixels = pixels;
- + GLFWcursor* cursor = glfwCreateCursor(&image, 0, 0);
- + }*/
- +
- + //! replace the given cursor icon.
- + //virtual void changeIcon(gui::ECURSOR_ICON iconId, const gui::SCursorSprite& icon) _IRR_OVERRIDE_ = 0;
- +
- + //! Return a system-specific size which is supported for cursors. Larger icons will fail, smaller icons might work.
- + //virtual core::dimension2di getSupportedIconSize() const _IRR_OVERRIDE_ = 0;
- +
- + private:
- +
- + void updateCursorPos()
- + {
- + CursorPos.X = Device->MouseX;
- + CursorPos.Y = Device->MouseY;
- +
- + if (CursorPos.X < 0)
- + CursorPos.X = 0;
- + if (CursorPos.X > (s32)Device->Width)
- + CursorPos.X = Device->Width;
- + if (CursorPos.Y < 0)
- + CursorPos.Y = 0;
- + if (CursorPos.Y > (s32)Device->Height)
- + CursorPos.Y = Device->Height;
- + }
- +
- + CIrrDeviceGLFW3* Device;
- + core::position2d<s32> CursorPos;
- + bool IsVisible;
- + };
- +
- + private:
- +
- + //! create the driver
- + void createDriver();
- +
- + bool createWindow();
- +
- + void createKeyMap();
- +
- + GLFWwindow* window;
- +
- +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
- + core::array<int> Joysticks;
- +#endif
- +
- + SEvent irrevent;
- +
- + s32 MouseX, MouseY;
- + u32 MouseButtonStates;
- +
- + u32 Width, Height;
- +
- + bool Resizable;
- + bool WindowHasFocus;
- + bool WindowMinimized;
- +
- + struct SKeyMap
- + {
- + SKeyMap() {}
- + SKeyMap(s32 x11, s32 win32)
- + : GLFW3Key(x11), Win32Key(win32)
- + {
- + }
- +
- + s32 GLFW3Key;
- + s32 Win32Key;
- +
- + bool operator<(const SKeyMap& o) const
- + {
- + return GLFW3Key < o.GLFW3Key; //ToDo: revisar
- + }
- + };
- +
- + core::array<SKeyMap> KeyMap;
- + };
- +
- + //ToDo: joysticks
- +
- +} // end namespace irr
- +
- +#endif // _IRR_COMPILE_WITH_GLFW3_DEVICE_
- +#endif // __C_IRR_DEVICE_GLFW3_H_INCLUDED__
- +
- diff -Naur irrlicht-code-5600-trunk/source/Irrlicht/COpenGLDriver.cpp irrlicht-glfw/source/Irrlicht/COpenGLDriver.cpp
- --- irrlicht-code-5600-trunk/source/Irrlicht/COpenGLDriver.cpp 2017-12-31 21:24:55.000000000 +0100
- +++ irrlicht-glfw/source/Irrlicht/COpenGLDriver.cpp 2018-01-22 16:08:53.000000000 +0100
- @@ -24,6 +24,11 @@
- #include <SDL/SDL.h>
- #endif
- +#ifdef _IRR_COMPILE_WITH_GLFW3_DEVICE_
- +#include <GLFW/glfw3.h>
- +#include "CIrrDeviceGLFW3.h"
- +#endif
- +
- namespace irr
- {
- namespace video
- @@ -52,19 +57,33 @@
- #endif
- #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
- -COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceSDL* device)
- - : CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), CacheHandler(0),
- - CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true),
- - AntiAlias(params.AntiAlias), ColorFormat(ECF_R8G8B8), FixedPipelineState(EOFPS_ENABLE),
- - Params(params), SDLDevice(device), ContextManager(0), DeviceType(EIDT_SDL)
- -{
- -#ifdef _DEBUG
- - setDebugName("COpenGLDriver");
- + COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceSDL* device)
- + : CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), CacheHandler(0),
- + CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true),
- + AntiAlias(params.AntiAlias), ColorFormat(ECF_R8G8B8), FixedPipelineState(EOFPS_ENABLE),
- + Params(params), SDLDevice(device), ContextManager(0), DeviceType(EIDT_SDL)
- + {
- + #ifdef _DEBUG
- + setDebugName("COpenGLDriver");
- + #endif
- +
- + genericDriverInit();
- + }
- #endif
- - genericDriverInit();
- -}
- +#ifdef _IRR_COMPILE_WITH_GLFW3_DEVICE_
- + COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceGLFW3* device)
- + : CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), CacheHandler(0),
- + CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true),
- + AntiAlias(params.AntiAlias), ColorFormat(ECF_R8G8B8), FixedPipelineState(EOFPS_ENABLE),
- + Params(params), GLFW3Device(device), ContextManager(0), DeviceType(EIDT_GLFW3)
- + {
- + #ifdef _DEBUG
- + setDebugName("COpenGLDriver");
- + #endif
- + genericDriverInit();
- + }
- #endif
- bool COpenGLDriver::initDriver()
- @@ -295,6 +314,11 @@
- glFrontFace(GL_CW);
- #endif
- +#if defined(_IRR_COMPILE_WITH_GLFW3_DEVICE_)
- + if ( DeviceType == EIDT_GLFW3 )
- + glFrontFace(GL_CW);
- +#endif
- +
- clearBuffers(clearFlag, clearColor, clearDepth, clearStencil);
- return true;
- @@ -319,6 +343,14 @@
- }
- #endif
- +#ifdef _IRR_COMPILE_WITH_GLFW3_DEVICE_
- + if ( DeviceType == EIDT_GLFW3 )
- + {
- + glfwSwapBuffers(this->GLFW3Device->getWindow());
- + status = true;
- + }
- +#endif
- +
- // todo: console device present
- return status;
- @@ -4382,15 +4414,30 @@
- #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
- IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
- io::IFileSystem* io, CIrrDeviceSDL* device)
- -{
- -#ifdef _IRR_COMPILE_WITH_OPENGL_
- - return new COpenGLDriver(params, io, device);
- -#else
- - return 0;
- -#endif // _IRR_COMPILE_WITH_OPENGL_
- -}
- + {
- + #ifdef _IRR_COMPILE_WITH_OPENGL_
- + return new COpenGLDriver(params, io, device);
- + #else
- + return 0;
- + #endif // _IRR_COMPILE_WITH_OPENGL_
- + }
- #endif // _IRR_COMPILE_WITH_SDL_DEVICE_
- +// -----------------------------------
- +// GLFW3 VERSION
- +// -----------------------------------
- +#ifdef _IRR_COMPILE_WITH_GLFW3_DEVICE_
- +IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
- + io::IFileSystem* io, CIrrDeviceGLFW3* device)
- + {
- + #ifdef _IRR_COMPILE_WITH_OPENGL_
- + return new COpenGLDriver(params, io, device);
- + #else
- + return 0;
- + #endif // _IRR_COMPILE_WITH_OPENGL_
- + }
- +#endif // _IRR_COMPILE_WITH_GLFW3_DEVICE_
- +
- } // end namespace
- } // end namespace
- diff -Naur irrlicht-code-5600-trunk/source/Irrlicht/COpenGLDriver.h irrlicht-glfw/source/Irrlicht/COpenGLDriver.h
- --- irrlicht-code-5600-trunk/source/Irrlicht/COpenGLDriver.h 2017-08-21 15:53:01.000000000 +0200
- +++ irrlicht-glfw/source/Irrlicht/COpenGLDriver.h 2018-01-22 05:15:08.000000000 +0100
- @@ -14,6 +14,7 @@
- class CIrrDeviceWin32;
- class CIrrDeviceLinux;
- class CIrrDeviceSDL;
- + class CIrrDeviceGLFW3;
- class CIrrDeviceMacOSX;
- }
- @@ -51,6 +52,10 @@
- COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceSDL* device);
- #endif
- +#ifdef _IRR_COMPILE_WITH_GLFW3_DEVICE_
- + COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceGLFW3* device);
- +#endif
- +
- bool initDriver();
- //! destructor
- @@ -502,6 +507,10 @@
- CIrrDeviceSDL *SDLDevice;
- #endif
- + #ifdef _IRR_COMPILE_WITH_GLFW3_DEVICE_
- + CIrrDeviceGLFW3 *GLFW3Device;
- + #endif
- +
- IContextManager* ContextManager;
- E_DEVICE_TYPE DeviceType;
- diff -Naur irrlicht-code-5600-trunk/source/Irrlicht/Irrlicht.cpp irrlicht-glfw/source/Irrlicht/Irrlicht.cpp
- --- irrlicht-code-5600-trunk/source/Irrlicht/Irrlicht.cpp 2017-11-28 22:54:18.000000000 +0100
- +++ irrlicht-glfw/source/Irrlicht/Irrlicht.cpp 2018-01-22 05:16:50.000000000 +0100
- @@ -30,6 +30,10 @@
- #include "CIrrDeviceSDL.h"
- #endif
- +#ifdef _IRR_COMPILE_WITH_GLFW3_DEVICE_
- +#include "CIrrDeviceGLFW3.h"
- +#endif
- +
- #ifdef _IRR_COMPILE_WITH_FB_DEVICE_
- #include "CIrrDeviceFB.h"
- #endif
- @@ -85,6 +89,11 @@
- dev = new CIrrDeviceSDL(params);
- #endif
- +#ifdef _IRR_COMPILE_WITH_GLFW3_DEVICE_
- + if (params.DeviceType == EIDT_GLFW3 || (!dev && params.DeviceType == EIDT_BEST))
- + dev = new CIrrDeviceGLFW3(params);
- +#endif
- +
- #ifdef _IRR_COMPILE_WITH_FB_DEVICE_
- if (params.DeviceType == EIDT_FRAMEBUFFER || (!dev && params.DeviceType == EIDT_BEST))
- dev = new CIrrDeviceFB(params);
- diff -Naur irrlicht-code-5600-trunk/source/Irrlicht/Irrlicht-gcc.cbp irrlicht-glfw/source/Irrlicht/Irrlicht-gcc.cbp
- --- irrlicht-code-5600-trunk/source/Irrlicht/Irrlicht-gcc.cbp 2017-08-23 18:41:15.000000000 +0200
- +++ irrlicht-glfw/source/Irrlicht/Irrlicht-gcc.cbp 2018-01-22 05:16:02.559571907 +0100
- @@ -765,6 +765,8 @@
- <Unit filename="CIrrDeviceLinux.h" />
- <Unit filename="CIrrDeviceSDL.cpp" />
- <Unit filename="CIrrDeviceSDL.h" />
- + <Unit filename="CIrrDeviceGLFW3.cpp" />
- + <Unit filename="CIrrDeviceGLFW3.h" />
- <Unit filename="CIrrDeviceStub.cpp" />
- <Unit filename="CIrrDeviceStub.h" />
- <Unit filename="CIrrDeviceWin32.cpp" />
- diff -Naur irrlicht-code-5600-trunk/source/Irrlicht/Makefile irrlicht-glfw/source/Irrlicht/Makefile
- --- irrlicht-code-5600-trunk/source/Irrlicht/Makefile 2017-11-06 15:39:37.000000000 +0100
- +++ irrlicht-glfw/source/Irrlicht/Makefile 2018-01-22 05:17:14.248548410 +0100
- @@ -44,7 +44,7 @@
- IRRVIDEOOBJ = CVideoModeList.o CFPSCounter.o $(IRRDRVROBJ) $(IRRIMAGEOBJ)
- IRRSWRENDEROBJ = CSoftwareDriver.o CSoftwareTexture.o CTRFlat.o CTRFlatWire.o CTRGouraud.o CTRGouraudWire.o CTRNormalMap.o CTRStencilShadow.o CTRTextureFlat.o CTRTextureFlatWire.o CTRTextureGouraud.o CTRTextureGouraudAdd.o CTRTextureGouraudNoZ.o CTRTextureGouraudWire.o CZBuffer.o CTRTextureGouraudVertexAlpha2.o CTRTextureGouraudNoZ2.o CTRTextureLightMap2_M2.o CTRTextureLightMap2_M4.o CTRTextureLightMap2_M1.o CSoftwareDriver2.o CSoftwareTexture2.o CTRTextureGouraud2.o CTRGouraud2.o CTRGouraudAlpha2.o CTRGouraudAlphaNoZ2.o CTRTextureDetailMap2.o CTRTextureGouraudAdd2.o CTRTextureGouraudAddNoZ2.o CTRTextureWire2.o CTRTextureLightMap2_Add.o CTRTextureLightMapGouraud2_M4.o IBurningShader.o CTRTextureBlend.o CTRTextureGouraudAlpha.o CTRTextureGouraudAlphaNoZ.o CDepthBuffer.o CBurningShader_Raster_Reference.o
- IRRIOOBJ = CFileList.o CFileSystem.o CLimitReadFile.o CMemoryFile.o CReadFile.o CWriteFile.o CXMLReader.o CXMLWriter.o CWADReader.o CZipReader.o CPakReader.o CNPKReader.o CTarReader.o CMountPointReader.o irrXML.o CAttributes.o lzma/LzmaDec.o
- -IRROTHEROBJ = CIrrDeviceSDL.o CIrrDeviceLinux.o CIrrDeviceConsole.o CIrrDeviceStub.o CIrrDeviceWin32.o CIrrDeviceFB.o CLogger.o COSOperator.o Irrlicht.o os.o leakHunter.o CProfiler.o utf8.o
- +IRROTHEROBJ = CIrrDeviceSDL.o CIrrDeviceGLFW3.o CIrrDeviceLinux.o CIrrDeviceConsole.o CIrrDeviceStub.o CIrrDeviceWin32.o CIrrDeviceFB.o CLogger.o COSOperator.o Irrlicht.o os.o leakHunter.o CProfiler.o utf8.o
- IRRGUIOBJ = CGUIButton.o CGUICheckBox.o CGUIComboBox.o CGUIContextMenu.o CGUIEditBox.o CGUIEnvironment.o CGUIFileOpenDialog.o CGUIFont.o CGUIImage.o CGUIInOutFader.o CGUIListBox.o CGUIMenu.o CGUIMeshViewer.o CGUIMessageBox.o CGUIModalScreen.o CGUIScrollBar.o CGUISpinBox.o CGUISkin.o CGUIStaticText.o CGUITabControl.o CGUITable.o CGUIToolBar.o CGUIWindow.o CGUIColorSelectDialog.o CDefaultGUIElementFactory.o CGUISpriteBank.o CGUIImageList.o CGUITreeView.o CGUIProfiler.o
- ZLIBOBJ = zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/deflate.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o zlib/uncompr.o zlib/zutil.o
- JPEGLIBOBJ = jpeglib/jcapimin.o jpeglib/jcapistd.o jpeglib/jccoefct.o jpeglib/jccolor.o jpeglib/jcdctmgr.o jpeglib/jchuff.o jpeglib/jcinit.o jpeglib/jcmainct.o jpeglib/jcmarker.o jpeglib/jcmaster.o jpeglib/jcomapi.o jpeglib/jcparam.o jpeglib/jcprepct.o jpeglib/jcsample.o jpeglib/jctrans.o jpeglib/jdapimin.o jpeglib/jdapistd.o jpeglib/jdatadst.o jpeglib/jdatasrc.o jpeglib/jdcoefct.o jpeglib/jdcolor.o jpeglib/jddctmgr.o jpeglib/jdhuff.o jpeglib/jdinput.o jpeglib/jdmainct.o jpeglib/jdmarker.o jpeglib/jdmaster.o jpeglib/jdmerge.o jpeglib/jdpostct.o jpeglib/jdsample.o jpeglib/jdtrans.o jpeglib/jerror.o jpeglib/jfdctflt.o jpeglib/jfdctfst.o jpeglib/jfdctint.o jpeglib/jidctflt.o jpeglib/jidctfst.o jpeglib/jidctint.o jpeglib/jmemmgr.o jpeglib/jmemnobs.o jpeglib/jquant1.o jpeglib/jquant2.o jpeglib/jutils.o jpeglib/jcarith.o jpeglib/jdarith.o jpeglib/jaricom.o
- diff -Naur irrlicht-code-5600-trunk/source/Irrlicht/.vscode/settings.json irrlicht-glfw/source/Irrlicht/.vscode/settings.json
- --- irrlicht-code-5600-trunk/source/Irrlicht/.vscode/settings.json 1970-01-01 01:00:00.000000000 +0100
- +++ irrlicht-glfw/source/Irrlicht/.vscode/settings.json 2018-01-22 04:24:10.777545696 +0100
- @@ -0,0 +1,5 @@
- +{
- + "files.associations": {
- + "*.tcc": "cpp"
- + }
- +}
- \ No hay ningún carácter de nueva línea al final del fichero
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement