fix windows / renderer compile (renderer requires sdl for now)
This commit is contained in:
parent
841022c907
commit
58127f355b
35
SConscript
35
SConscript
@ -242,26 +242,25 @@ def findLibs(env, conf):
|
||||
if not GetOption('renderer') and not conf.CheckLib('SDLmain'):
|
||||
FatalError("libSDLmain not found or not installed")
|
||||
|
||||
if not GetOption('renderer'):
|
||||
#Look for SDL
|
||||
runSdlConfig = platform == "Linux" or compilePlatform == "Linux" or platform == "FreeBSD"
|
||||
if False and platform == "Darwin" and conf.CheckFramework("SDL"):
|
||||
runSdlConfig = False
|
||||
elif not conf.CheckLib("SDL2"):
|
||||
FatalError("SDL development library not found or not installed")
|
||||
#Look for SDL
|
||||
runSdlConfig = platform == "Linux" or compilePlatform == "Linux" or platform == "FreeBSD"
|
||||
if False and platform == "Darwin" and conf.CheckFramework("SDL"):
|
||||
runSdlConfig = False
|
||||
elif not conf.CheckLib("SDL2"):
|
||||
FatalError("SDL development library not found or not installed")
|
||||
|
||||
if runSdlConfig:
|
||||
try:
|
||||
env.ParseConfig('sdl2-config --cflags')
|
||||
if GetOption('static'):
|
||||
env.ParseConfig('sdl2-config --static-libs')
|
||||
else:
|
||||
env.ParseConfig('sdl2-config --libs')
|
||||
except:
|
||||
pass
|
||||
if runSdlConfig:
|
||||
try:
|
||||
env.ParseConfig('sdl2-config --cflags')
|
||||
if GetOption('static'):
|
||||
env.ParseConfig('sdl2-config --static-libs')
|
||||
else:
|
||||
env.ParseConfig('sdl2-config --libs')
|
||||
except:
|
||||
pass
|
||||
|
||||
#look for SDL.h
|
||||
if not GetOption('renderer') and not conf.CheckCHeader('SDL2.h'):
|
||||
if not conf.CheckCHeader('SDL2.h'):
|
||||
if conf.CheckCHeader('SDL2/SDL.h'):
|
||||
env.Append(CPPDEFINES=["SDL_INC"])
|
||||
else:
|
||||
@ -505,8 +504,6 @@ if GetOption('opengl') or GetOption('opengl-renderer'):
|
||||
|
||||
if GetOption('renderer'):
|
||||
env.Append(CPPDEFINES=['RENDERER'])
|
||||
else:
|
||||
env.Append(CPPDEFINES=['USE_SDL'])
|
||||
|
||||
if GetOption('font'):
|
||||
env.Append(CPPDEFINES=['FONTEDITOR'])
|
||||
|
@ -1,11 +1,10 @@
|
||||
#ifdef USE_SDL
|
||||
#ifndef RENDERER
|
||||
|
||||
#include <map>
|
||||
#include "common/String.h"
|
||||
#include <ctime>
|
||||
#include <climits>
|
||||
#ifdef WIN
|
||||
#define _WIN32_WINNT 0x0501 //Necessary for some macros and functions, tells windows.h to include functions only available in Windows XP or later
|
||||
#include <direct.h>
|
||||
#endif
|
||||
#include "SDLCompat.h"
|
||||
@ -54,10 +53,6 @@ using namespace std;
|
||||
|
||||
#define INCLUDE_SYSWM
|
||||
#include "SDLCompat.h"
|
||||
#if defined(USE_SDL) && defined(LIN) && defined(SDL_VIDEO_DRIVER_X11)
|
||||
SDL_SysWMinfo sdl_wminfo;
|
||||
Atom XA_CLIPBOARD, XA_TARGETS, XA_UTF8_STRING;
|
||||
#endif
|
||||
|
||||
int desktopWidth = 1280, desktopHeight = 1024;
|
||||
|
||||
@ -134,10 +129,7 @@ void blit(pixel * vid)
|
||||
|
||||
int SDLOpen()
|
||||
{
|
||||
#if defined(WIN) && defined(WINCONSOLE)
|
||||
FILE * console = fopen("CON", "w" );
|
||||
#endif
|
||||
if (SDL_Init(SDL_INIT_VIDEO)<0)
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
||||
{
|
||||
fprintf(stderr, "Initializing SDL: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
@ -148,32 +140,6 @@ int SDLOpen()
|
||||
desktopWidth = SDLDisplayMode.w;
|
||||
desktopHeight = SDLDisplayMode.h;
|
||||
|
||||
#if defined(WIN) && defined(WINCONSOLE)
|
||||
//On Windows, SDL redirects stdout to stdout.txt, which can be annoying when debugging, here we redirect back to the console
|
||||
if (console)
|
||||
{
|
||||
freopen("CON", "w", stdout);
|
||||
freopen("CON", "w", stderr);
|
||||
//fclose(console);
|
||||
}
|
||||
#endif
|
||||
#ifdef WIN
|
||||
SDL_SysWMinfo SysInfo;
|
||||
SDL_VERSION(&SysInfo.version);
|
||||
if(SDL_GetWMInfo(&SysInfo) <= 0) {
|
||||
printf("%s : %p\n", SDL_GetError(), SysInfo.window);
|
||||
exit(-1);
|
||||
}
|
||||
HWND WindowHandle = SysInfo.window;
|
||||
|
||||
// Use GetModuleHandle to get the Exe HMODULE/HINSTANCE
|
||||
HMODULE hModExe = GetModuleHandle(NULL);
|
||||
HICON hIconSmall = (HICON)LoadImage(hModExe, MAKEINTRESOURCE(101), IMAGE_ICON, 16, 16, LR_SHARED);
|
||||
HICON hIconBig = (HICON)LoadImage(hModExe, MAKEINTRESOURCE(101), IMAGE_ICON, 32, 32, LR_SHARED);
|
||||
SendMessage(WindowHandle, WM_SETICON, ICON_SMALL, (LPARAM)hIconSmall);
|
||||
SendMessage(WindowHandle, WM_SETICON, ICON_BIG, (LPARAM)hIconBig);
|
||||
#endif
|
||||
|
||||
sdl_window = SDL_CreateWindow("The Powder Toy", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WINDOWW * scale, WINDOWH * scale,
|
||||
fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||
sdl_renderer = SDL_CreateRenderer(sdl_window, -1, 0);
|
||||
@ -187,6 +153,23 @@ int SDLOpen()
|
||||
//SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
|
||||
//SDL_SetWindowResizable(sdl_window, SDL_TRUE);
|
||||
|
||||
#ifdef WIN
|
||||
SDL_SysWMinfo SysInfo;
|
||||
SDL_VERSION(&SysInfo.version);
|
||||
if(SDL_GetWindowWMInfo(sdl_window, &SysInfo) <= 0)
|
||||
{
|
||||
printf("%s : %p\n", SDL_GetError(), SysInfo.info.win.window);
|
||||
exit(-1);
|
||||
}
|
||||
HWND WindowHandle = SysInfo.info.win.window;
|
||||
|
||||
// Use GetModuleHandle to get the Exe HMODULE/HINSTANCE
|
||||
HMODULE hModExe = GetModuleHandle(NULL);
|
||||
HICON hIconSmall = (HICON)LoadImage(hModExe, MAKEINTRESOURCE(101), IMAGE_ICON, 16, 16, LR_SHARED);
|
||||
HICON hIconBig = (HICON)LoadImage(hModExe, MAKEINTRESOURCE(101), IMAGE_ICON, 32, 32, LR_SHARED);
|
||||
SendMessage(WindowHandle, WM_SETICON, ICON_SMALL, (LPARAM)hIconSmall);
|
||||
SendMessage(WindowHandle, WM_SETICON, ICON_BIG, (LPARAM)hIconBig);
|
||||
#endif
|
||||
#ifdef LIN
|
||||
SDL_Surface *icon = SDL_CreateRGBSurfaceFrom((void*)app_icon, 48, 48, 32, 192, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
|
||||
SDL_SetWindowIcon(sdl_window, icon);
|
||||
@ -412,9 +395,6 @@ void DoubleScreenDialog()
|
||||
{
|
||||
Client::Ref().SetPref("Scale", 1);
|
||||
engine->SetScale(1);
|
||||
#ifdef WIN
|
||||
LoadWindowPosition(1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#if defined(USE_SDL) && defined(_MSC_VER) && (_MSC_VER >= 1900)
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1900)
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
#ifdef USE_SDL
|
||||
|
||||
#ifdef SDL_INC
|
||||
#include "SDL2/SDL.h"
|
||||
#else
|
||||
@ -7,13 +5,11 @@
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_SYSWM
|
||||
#if defined(WIN) || defined(LIN)
|
||||
#if defined(WIN)
|
||||
#ifdef SDL_INC
|
||||
#include <SDL2/SDL_syswm.h>
|
||||
#else
|
||||
#include <SDL_syswm.h>
|
||||
#endif
|
||||
#endif // WIN || LIN
|
||||
#endif // WIN
|
||||
#endif // INCLUDE_SYSWM
|
||||
|
||||
#endif // USE_SDL
|
||||
|
@ -114,21 +114,17 @@ void LocalBrowserView::textChanged()
|
||||
else if (num > pageCount)
|
||||
pageTextbox->SetText(String::Build(pageCount));
|
||||
changed = true;
|
||||
#ifdef USE_SDL
|
||||
lastChanged = GetTicks()+600;
|
||||
#endif
|
||||
}
|
||||
|
||||
void LocalBrowserView::OnTick(float dt)
|
||||
{
|
||||
c->Update();
|
||||
#ifdef USE_SDL
|
||||
if (changed && lastChanged < GetTicks())
|
||||
{
|
||||
changed = false;
|
||||
c->SetPage(std::max(pageTextbox->GetText().ToNumber<int>(true), 0));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void LocalBrowserView::NotifyPageChanged(LocalBrowserModel * sender)
|
||||
|
@ -180,13 +180,7 @@ OptionsView::OptionsView():
|
||||
FullscreenAction(OptionsView * v_){ v = v_; }
|
||||
virtual void ActionCallback(ui::Checkbox * sender)
|
||||
{
|
||||
#ifdef USE_SDL
|
||||
#if defined(MACOSX) && !SDL_VERSION_ATLEAST(1, 2, 15)
|
||||
ErrorMessage::Blocking("Information", "Fullscreen doesn't work on OS X");
|
||||
#else
|
||||
v->c->SetFullscreen(sender->GetChecked());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -291,9 +291,7 @@ void SearchView::textChanged()
|
||||
else if (num > pageCount)
|
||||
pageTextbox->SetText(String::Build(pageCount));
|
||||
changed = true;
|
||||
#ifdef USE_SDL
|
||||
lastChanged = GetTicks()+600;
|
||||
#endif
|
||||
}
|
||||
|
||||
void SearchView::OnTryOkay(OkayMethod method)
|
||||
@ -780,13 +778,11 @@ void SearchView::NotifySelectedChanged(SearchModel * sender)
|
||||
void SearchView::OnTick(float dt)
|
||||
{
|
||||
c->Update();
|
||||
#ifdef USE_SDL
|
||||
if (changed && lastChanged < GetTicks())
|
||||
{
|
||||
changed = false;
|
||||
c->SetPage(std::max(pageTextbox->GetText().ToNumber<int>(true), 0));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SearchView::OnMouseWheel(int x, int y, int d)
|
||||
|
Reference in New Issue
Block a user