mirror of
https://github.com/glest/glest-source.git
synced 2025-08-17 21:51:17 +02:00
- got sdl2 branch compiling and game loads
This commit is contained in:
@@ -2481,7 +2481,7 @@ void ServerSocket::NETdiscoverUPnPDevices() {
|
||||
// WATCH OUT! Because the thread takes void * as a parameter we MUST cast to the pointer type
|
||||
// used on the other side (inside the thread)
|
||||
//printf("STARTING UPNP Thread\n");
|
||||
ServerSocket::upnpdiscoverThread = SDL_CreateThread(&UPNP_Tools::upnp_init, dynamic_cast<UPNPInitInterface *>(this));
|
||||
ServerSocket::upnpdiscoverThread = SDL_CreateThread(&UPNP_Tools::upnp_init, "upnpdiscoverThread", dynamic_cast<UPNPInitInterface *>(this));
|
||||
safeMutexUPNP.ReleaseLock();
|
||||
//printf("In [%s::%s] Line: %d safeMutexUPNP\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
|
@@ -48,7 +48,7 @@ int PlatformContextGl::charSet = 1;
|
||||
PlatformContextGl::PlatformContextGl() {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
icon = NULL;
|
||||
screen = NULL;
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
PlatformContextGl::~PlatformContextGl() {
|
||||
@@ -59,6 +59,10 @@ PlatformContextGl::~PlatformContextGl() {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
SDL_Surface * PlatformContextGl::getScreenSurface() {
|
||||
return SDL_GetWindowSurface(window);
|
||||
}
|
||||
|
||||
void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,
|
||||
bool hardware_acceleration,
|
||||
bool fullscreen_anti_aliasing, float gammaValue) {
|
||||
@@ -92,20 +96,20 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to set resolution: %d x %d, colorBits = %d.\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,resW,resH,colorBits);
|
||||
|
||||
if(screen != NULL) {
|
||||
SDL_FreeSurface(SDL_GetWindowSurface(screen));
|
||||
screen = NULL;
|
||||
if(window != NULL) {
|
||||
SDL_FreeSurface(getScreenSurface());
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//screen = SDL_CreateWindow(resW, resH, colorBits, flags);
|
||||
screen = SDL_CreateWindow("MG",
|
||||
window = SDL_CreateWindow("MG",
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
resW, resH, flags);
|
||||
|
||||
if(screen == 0) {
|
||||
if(window == 0) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
std::ostringstream msg;
|
||||
@@ -118,35 +122,37 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg.str().c_str());
|
||||
|
||||
//screen = SDL_SetVideoMode(resW, resH, i, flags);
|
||||
screen = SDL_CreateWindow("MG",
|
||||
window = SDL_CreateWindow("MG",
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
resW, resH, flags);
|
||||
|
||||
if(screen == 0) {
|
||||
if(window == 0) {
|
||||
// try to switch to native desktop resolution
|
||||
screen = SDL_CreateWindow("MG",
|
||||
window = SDL_CreateWindow("MG",
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
0, 0,
|
||||
SDL_WINDOW_FULLSCREEN_DESKTOP|flags);
|
||||
}
|
||||
if(screen == 0) {
|
||||
if(window == 0) {
|
||||
// try to revert to 640x480
|
||||
screen = SDL_CreateWindow("MG",
|
||||
window = SDL_CreateWindow("MG",
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
650, 480,
|
||||
SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
}
|
||||
if(screen == 0) {
|
||||
if(window == 0) {
|
||||
throw std::runtime_error(msg.str());
|
||||
}
|
||||
}
|
||||
|
||||
glcontext = SDL_GL_CreateContext(window);
|
||||
|
||||
int h;
|
||||
int w;
|
||||
SDL_GetWindowSize(screen, &w, &h);
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
glViewport( 0, 0, w, h ) ;
|
||||
|
||||
#ifndef WIN32
|
||||
@@ -219,7 +225,7 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,
|
||||
printf("Icon Load Error #2: %s\n", SDL_GetError());
|
||||
}
|
||||
else {
|
||||
SDL_SetWindowIcon(screen,icon);
|
||||
SDL_SetWindowIcon(window,icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -257,7 +263,7 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,
|
||||
if(gammaValue != 0.0) {
|
||||
//printf("Attempting to call SDL_SetGamma using value %f\n", gammaValue);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
if (SDL_SetWindowBrightness(screen, gammaValue) < 0) {
|
||||
if (SDL_SetWindowBrightness(window, gammaValue) < 0) {
|
||||
printf("WARNING, SDL_SetWindowBrightness failed using value %f [%s]\n", gammaValue,SDL_GetError());
|
||||
}
|
||||
}
|
||||
@@ -281,11 +287,11 @@ void PlatformContextGl::end() {
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
if(screen != NULL) {
|
||||
if(window != NULL) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
SDL_DestroyWindow(screen);
|
||||
screen = NULL;
|
||||
SDL_DestroyWindow(window);
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
@@ -296,7 +302,7 @@ void PlatformContextGl::makeCurrent() {
|
||||
|
||||
void PlatformContextGl::swapBuffers() {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
||||
SDL_GL_SwapWindow(screen);
|
||||
SDL_GL_SwapWindow(window);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -213,7 +213,7 @@ Thread::~Thread() {
|
||||
|
||||
if(isThreadExecuteCompleteStatus() == false) {
|
||||
printf("**WARNING** thread destructor will KILL thread [%p]...\n",thread);
|
||||
SDL_KillThread(thread);
|
||||
//SDL_KillThread(thread);
|
||||
}
|
||||
else {
|
||||
SDL_WaitThread(thread, NULL);
|
||||
@@ -248,7 +248,7 @@ void Thread::start() {
|
||||
BaseThread *base_thread = dynamic_cast<BaseThread *>(this);
|
||||
if(base_thread) base_thread->setStarted(true);
|
||||
|
||||
thread = SDL_CreateThread(beginExecution, this);
|
||||
thread = SDL_CreateThread(beginExecution, base_thread->getUniqueID().c_str(), this);
|
||||
if(thread == NULL) {
|
||||
if(base_thread) base_thread->setStarted(false);
|
||||
|
||||
@@ -380,7 +380,7 @@ void Thread::queueAutoCleanThread() {
|
||||
|
||||
void Thread::kill() {
|
||||
MutexSafeWrapper safeMutex(mutexthreadAccessor);
|
||||
SDL_KillThread(thread);
|
||||
//SDL_KillThread(thread);
|
||||
thread = NULL;
|
||||
}
|
||||
|
||||
|
@@ -41,6 +41,7 @@ namespace Shared{ namespace Platform{
|
||||
|
||||
static Window* global_window = 0;
|
||||
static int oldX=0,oldY=0;
|
||||
SDL_Window *Window::sdlWindow = 0;
|
||||
int64 Window::lastMouseEvent = 0; /** for use in mouse hover calculations */
|
||||
Vec2i Window::mousePos;
|
||||
MouseState Window::mouseState;
|
||||
@@ -79,6 +80,35 @@ static HWND GetSDLWindow()
|
||||
|
||||
#endif
|
||||
|
||||
Window::Window() {
|
||||
this->sdlWindow=0;
|
||||
// Default to 1x1 until set by caller to avoid divide by 0
|
||||
this->w = 1;
|
||||
this->h = 1;
|
||||
|
||||
for(int idx = 0; idx < mbCount; idx++) {
|
||||
lastMouseDown[idx] = 0;
|
||||
lastMouseX[idx] = 0;
|
||||
lastMouseY[idx] = 0;
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
assert(global_window == 0);
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
global_window = this;
|
||||
Window::isActive = true;
|
||||
|
||||
lastMouseEvent = 0;
|
||||
mousePos = Vec2i(0);
|
||||
mouseState.clear();
|
||||
|
||||
#ifdef WIN32
|
||||
init_win32();
|
||||
#endif
|
||||
}
|
||||
|
||||
Window::Window(SDL_Window *sdlWindow) {
|
||||
this->sdlWindow=sdlWindow;
|
||||
// Default to 1x1 until set by caller to avoid divide by 0
|
||||
@@ -121,6 +151,13 @@ Window::~Window() {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void Window::setSDLWindow(SDL_Window *window) {
|
||||
Window::sdlWindow = window;
|
||||
}
|
||||
SDL_Window *Window::getSDLWindow() {
|
||||
return Window::sdlWindow;
|
||||
}
|
||||
|
||||
bool Window::handleEvent() {
|
||||
string codeLocation = "a";
|
||||
|
||||
@@ -324,8 +361,8 @@ bool Window::handleEvent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Window::revertMousePos(SDL_Window *sdlwindow) {
|
||||
SDL_WarpMouseInWindow( sdlwindow,oldX, oldY);
|
||||
void Window::revertMousePos() {
|
||||
SDL_WarpMouseInWindow(sdlWindow,oldX, oldY);
|
||||
}
|
||||
|
||||
Vec2i Window::getOldMousePos() {
|
||||
@@ -458,7 +495,7 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a
|
||||
}
|
||||
}
|
||||
|
||||
void Window::toggleFullscreen(SDL_Window *sdlwindow) {
|
||||
void Window::toggleFullscreen() {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
@@ -466,12 +503,12 @@ void Window::toggleFullscreen(SDL_Window *sdlwindow) {
|
||||
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
||||
//SDL_Surface *cur_surface = SDL_GetVideoSurface();
|
||||
if(sdlwindow != NULL) {
|
||||
if(sdlWindow != NULL) {
|
||||
if(isFullScreen){
|
||||
SDL_SetWindowFullscreen(sdlwindow,SDL_WINDOW_FULLSCREEN);
|
||||
SDL_SetWindowFullscreen(sdlWindow,SDL_WINDOW_FULLSCREEN);
|
||||
}
|
||||
else {
|
||||
SDL_SetWindowFullscreen(sdlwindow,0);
|
||||
SDL_SetWindowFullscreen(sdlWindow,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -563,13 +600,13 @@ wchar_t Window::convertStringtoSDLKey(const string &value) {
|
||||
|
||||
if(value.length() >= 1) {
|
||||
if(value.length() == 3 && value[0] == '\'' && value[2] == '\'') {
|
||||
result = (SDLKey)value[1];
|
||||
result = (SDL_Keycode)value[1];
|
||||
}
|
||||
else {
|
||||
bool foundKey = false;
|
||||
if(value.length() > 1) {
|
||||
for(int i = SDLK_UNKNOWN; i < SDLK_LAST; ++i) {
|
||||
SDLKey key = static_cast<SDLKey>(i);
|
||||
for(int i = SDLK_UNKNOWN; i < SDL_NUM_SCANCODES; ++i) {
|
||||
SDL_Keycode key = static_cast<SDL_Keycode>(i);
|
||||
string keyName = SDL_GetKeyName(key);
|
||||
if(value == keyName) {
|
||||
result = key;
|
||||
@@ -580,7 +617,7 @@ wchar_t Window::convertStringtoSDLKey(const string &value) {
|
||||
}
|
||||
|
||||
if(foundKey == false) {
|
||||
result = (SDLKey)value[0];
|
||||
result = (SDL_Keycode)value[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -624,14 +661,14 @@ bool Window::isAllowedKey(wchar_t key) {
|
||||
bool result =(iterFind != mapAllowedKeys.end());
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) {
|
||||
string keyName = SDL_GetKeyName((SDLKey)key);
|
||||
string keyName = SDL_GetKeyName((SDL_Keycode)key);
|
||||
printf("key: %d [%s] allowed result: %d\n",key,keyName.c_str(),result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,bool modifiersAllowed) {
|
||||
bool isKeyPressed(SDL_Keycode compareKey, SDL_KeyboardEvent input,bool modifiersAllowed) {
|
||||
vector<int> modifiersToCheck;
|
||||
if(modifiersAllowed == false) {
|
||||
modifiersToCheck.push_back(KMOD_LCTRL);
|
||||
@@ -643,7 +680,7 @@ bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,bool modifiersAllow
|
||||
bool result = isKeyPressed(compareKey, input, modifiersToCheck);
|
||||
return result;
|
||||
}
|
||||
bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,vector<int> modifiersToCheck) {
|
||||
bool isKeyPressed(SDL_Keycode compareKey, SDL_KeyboardEvent input,vector<int> modifiersToCheck) {
|
||||
Uint16 c = SDLK_UNKNOWN;
|
||||
//if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
|
||||
if(input.keysym.sym > 0) {
|
||||
@@ -739,7 +776,7 @@ bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,vector<int> modifie
|
||||
}
|
||||
// SDL does NOT handle lowercase
|
||||
if(compareKey >= 'A' && compareKey <= 'Z') {
|
||||
compareKey = (SDLKey)tolower((char)compareKey);
|
||||
compareKey = (SDL_Keycode)tolower((char)compareKey);
|
||||
}
|
||||
|
||||
bool result = (c == compareKey);
|
||||
@@ -841,7 +878,7 @@ bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,vector<int> modifie
|
||||
}
|
||||
}
|
||||
string compareKeyName = SDL_GetKeyName(compareKey);
|
||||
string pressKeyName = SDL_GetKeyName((SDLKey)c);
|
||||
string pressKeyName = SDL_GetKeyName((SDL_Keycode)c);
|
||||
|
||||
//printf ("In [%s::%s Line: %d] compareKey [%d - %s] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,compareKey,compareKeyName.c_str(),c,pressKeyName.c_str(),result);
|
||||
|
||||
@@ -880,7 +917,7 @@ wchar_t extractKeyPressedUnicode(SDL_KeyboardEvent input) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||
|
||||
string pressKeyName = SDL_GetKeyName((SDLKey)c);
|
||||
string pressKeyName = SDL_GetKeyName((SDL_Keycode)c);
|
||||
//string inputKeyName = SDL_GetKeyName(input.keysym.sym);
|
||||
|
||||
//printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d\n",
|
||||
@@ -920,13 +957,13 @@ vector<int> extractKeyPressedUnicodeLength(string text) {
|
||||
return result;
|
||||
}
|
||||
|
||||
SDLKey extractKeyPressed(SDL_KeyboardEvent input) {
|
||||
SDLKey c = SDLK_UNKNOWN;
|
||||
SDL_Keycode extractKeyPressed(SDL_KeyboardEvent input) {
|
||||
SDL_Keycode c = SDLK_UNKNOWN;
|
||||
//if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
|
||||
if(input.keysym.sym > 0) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.sym = %d input.keysym.mod = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,input.keysym.sym,input.keysym.mod);
|
||||
|
||||
c = (SDLKey)input.keysym.sym;
|
||||
c = (SDL_Keycode)input.keysym.sym;
|
||||
// if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
|
||||
// c = SDLKey(c & 0xFF);
|
||||
// }
|
||||
@@ -946,7 +983,7 @@ SDLKey extractKeyPressed(SDL_KeyboardEvent input) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||
|
||||
string pressKeyName = SDL_GetKeyName((SDLKey)c);
|
||||
string pressKeyName = SDL_GetKeyName((SDL_Keycode)c);
|
||||
//string inputKeyName = SDL_GetKeyName(input.keysym.sym);
|
||||
|
||||
//printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d\n",
|
||||
@@ -1013,14 +1050,14 @@ bool isAllowedInputTextKey(wchar_t &key) {
|
||||
key != SDLK_MENU &&
|
||||
key != SDLK_POWER);
|
||||
|
||||
string inputKeyName = SDL_GetKeyName((SDLKey)key);
|
||||
string inputKeyName = SDL_GetKeyName((SDL_Keycode)key);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool isAllowedInputTextKey(SDLKey key) {
|
||||
bool isAllowedInputTextKey(SDL_Keycode key) {
|
||||
if(Window::isAllowedKey(key) == true) {
|
||||
return true;
|
||||
}
|
||||
@@ -1117,7 +1154,7 @@ wchar_t Window::extractLastKeyPressed() {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||
|
||||
string pressKeyName = SDL_GetKeyName((SDLKey)c);
|
||||
string pressKeyName = SDL_GetKeyName((SDL_Keycode)c);
|
||||
//string inputKeyName = SDL_GetKeyName(keystate.sym);
|
||||
|
||||
//printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d\n",
|
||||
|
@@ -31,6 +31,40 @@ namespace Shared{ namespace Platform{
|
||||
// class WindowGl
|
||||
// =====================================================
|
||||
|
||||
WindowGl::WindowGl() : Window() {
|
||||
}
|
||||
WindowGl::WindowGl(SDL_Window *sdlWindow) : Window(sdlWindow) {
|
||||
}
|
||||
WindowGl::~WindowGl() {
|
||||
}
|
||||
|
||||
void WindowGl::setGamma(SDL_Window *window,float gammaValue) {
|
||||
//SDL_SetGamma(gammaValue, gammaValue, gammaValue);
|
||||
//SDL_SetWindowGammaRamp(getSDLWindow(), gammaValue, gammaValue, gammaValue);
|
||||
gammaValue = clamp(gammaValue, 0.1f, 10.0f);
|
||||
|
||||
Uint16 red_ramp[256];
|
||||
Uint16 green_ramp[256];
|
||||
Uint16 blue_ramp[256];
|
||||
|
||||
SDL_CalculateGammaRamp(gammaValue, red_ramp);
|
||||
SDL_memcpy(green_ramp, red_ramp, sizeof(red_ramp));
|
||||
SDL_memcpy(blue_ramp, red_ramp, sizeof(red_ramp));
|
||||
|
||||
SDL_SetWindowGammaRamp(window, red_ramp, green_ramp, blue_ramp);
|
||||
}
|
||||
void WindowGl::setGamma(float gammaValue) {
|
||||
context.setGammaValue(gammaValue);
|
||||
WindowGl::setGamma(getSDLWindow(),gammaValue);
|
||||
}
|
||||
|
||||
SDL_Window * WindowGl::getScreenWindow() {
|
||||
return context.getPlatformContextGlPtr()->getScreenWindow();
|
||||
}
|
||||
SDL_Surface * WindowGl::getScreenSurface() {
|
||||
return context.getPlatformContextGlPtr()->getScreenSurface();
|
||||
}
|
||||
|
||||
void WindowGl::initGl(int colorBits, int depthBits, int stencilBits,
|
||||
bool hardware_acceleration, bool fullscreen_anti_aliasing,
|
||||
float gammaValue) {
|
||||
@@ -42,6 +76,7 @@ void WindowGl::initGl(int colorBits, int depthBits, int stencilBits,
|
||||
context.setGammaValue(gammaValue);
|
||||
|
||||
context.init();
|
||||
setSDLWindow(context.getPlatformContextGlPtr()->getScreenWindow());
|
||||
}
|
||||
|
||||
void WindowGl::makeCurrentGl() {
|
||||
|
Reference in New Issue
Block a user