WIP. build under Win32 without SDL

This commit is contained in:
Thomas Bernard 2018-05-31 17:29:29 +02:00
parent 4d86b8a0c1
commit 3e4f3d0313
12 changed files with 54 additions and 24 deletions

View File

@ -52,7 +52,7 @@
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>NOTTF;__ENABLE_LUA__;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NOTTF;__ENABLE_LUA__;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4244</DisableSpecificWarnings> <DisableSpecificWarnings>4244</DisableSpecificWarnings>
<AdditionalIncludeDirectories>..\..\..\..\lua\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\..\..\lpng1634;..\..\..\..\lua\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
@ -66,7 +66,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NOTTF;__ENABLE_LUA__;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NOTTF;__ENABLE_LUA__;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4244</DisableSpecificWarnings> <DisableSpecificWarnings>4244</DisableSpecificWarnings>
<AdditionalIncludeDirectories>..\..\..\..\lua\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\..\..\lpng1634;..\..\..\..\lua\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>

View File

@ -1406,8 +1406,10 @@ void Main_handler(void)
} }
else else
{ {
#if defined(USE_SDL) || defined(USE_SDL2)
// Removed all SDL_Delay() timing here: relying on Get_input() // Removed all SDL_Delay() timing here: relying on Get_input()
SDL_Delay(10); SDL_Delay(10);
#endif
} }
// Gestion de la souris // Gestion de la souris

View File

@ -34,7 +34,7 @@
#include <sys/types.h> #include <sys/types.h>
#elif defined (__MINT__) #elif defined (__MINT__)
#include <mint/sysbind.h> #include <mint/sysbind.h>
#elif defined(__WIN32__) #elif defined(WIN32)
#include <windows.h> #include <windows.h>
#include <commdlg.h> #include <commdlg.h>
#endif #endif
@ -92,15 +92,19 @@
byte Native_filesel(byte load) byte Native_filesel(byte load)
{ {
//load = load; //load = load;
#ifdef __WIN32__ #if WIN32
OPENFILENAME ofn; OPENFILENAME ofn;
char szFileName[MAX_PATH] = ""; char szFileName[MAX_PATH] = "";
SDL_SysWMinfo wminfo;
HWND hwnd; HWND hwnd;
#if defined(USE_SDL) || defined(USE_SDL2)
SDL_SysWMinfo wminfo;
SDL_VERSION(&wminfo.version); SDL_VERSION(&wminfo.version);
SDL_GetWMInfo(&wminfo); SDL_GetWMInfo(&wminfo);
hwnd = wminfo.window; hwnd = wminfo.window;
#else
hwnd = GetActiveWindow();
#endif
ZeroMemory(&ofn, sizeof(ofn)); ZeroMemory(&ofn, sizeof(ofn));
@ -459,7 +463,7 @@ static void Read_dir_callback(void * pdata, const char *file_name, const word *u
// unreliable on non-physical drives : // unreliable on non-physical drives :
// Sometimes it's missing, sometimes it's present even at root... // Sometimes it's missing, sometimes it's present even at root...
// We skip it here and add a specific check after the loop // We skip it here and add a specific check after the loop
#if defined(__WIN32__) #if defined(WIN32)
if (!strcmp(file_name, PARENT_DIR)) if (!strcmp(file_name, PARENT_DIR))
return; return;
#endif #endif
@ -564,7 +568,7 @@ void Read_list_of_files(T_Fileselector *list, byte selected_format)
Add_element_to_list(list, PARENT_DIR, Format_filename(PARENT_DIR,19,1), 1, ICON_NONE); Add_element_to_list(list, PARENT_DIR, Format_filename(PARENT_DIR,19,1), 1, ICON_NONE);
list->Nb_directories ++; list->Nb_directories ++;
#elif defined (__WIN32__) #elif defined (WIN32)
// Windows : // Windows :
if (((current_path[0]>='a'&&current_path[0]<='z')||(current_path[0]>='A'&&current_path[0]<='Z')) && if (((current_path[0]>='a'&&current_path[0]<='z')||(current_path[0]>='A'&&current_path[0]<='Z')) &&
current_path[1]==':' && current_path[1]==':' &&
@ -674,7 +678,7 @@ void Read_list_of_drives(T_Fileselector *list, byte name_length)
UnLockDosList( LDF_VOLUMES | LDF_ASSIGNS | LDF_READ ); UnLockDosList( LDF_VOLUMES | LDF_ASSIGNS | LDF_READ );
} }
} }
#elif defined (__WIN32__) #elif defined (WIN32)
{ {
char drive_name[]="A:\\"; char drive_name[]="A:\\";
int drive_bits = GetLogicalDrives(); int drive_bits = GetLogicalDrives();

View File

@ -1135,7 +1135,9 @@ void Fill_general(byte fill_color)
if (! (Permanent_draw_count&7)) if (! (Permanent_draw_count&7))
{ {
dword now = GFX2_GetTicks(); dword now = GFX2_GetTicks();
#if defined(USE_SDL) || defined(USE_SDL2)
SDL_PumpEvents(); SDL_PumpEvents();
#endif
if (now>= Permanent_draw_next_refresh) if (now>= Permanent_draw_next_refresh)
{ {
Permanent_draw_next_refresh = now+100; Permanent_draw_next_refresh = now+100;

View File

@ -25,7 +25,7 @@
// Signal handler: I activate it for the two platforms who certainly // Signal handler: I activate it for the two platforms who certainly
// support them. Feel free to check with others. // support them. Feel free to check with others.
#if defined(__WIN32__) || defined(__linux__) #if defined(WIN32) || defined(__linux__)
#define GRAFX2_CATCHES_SIGNALS #define GRAFX2_CATCHES_SIGNALS
#endif #endif
@ -49,7 +49,7 @@
#if defined(USE_SDL) #if defined(USE_SDL)
#include <SDL_byteorder.h> #include <SDL_byteorder.h>
#endif #endif
#if defined(__WIN32__) #if defined(WIN32)
#include <windows.h> // GetLogicalDrives(), GetDriveType(), DRIVE_* #include <windows.h> // GetLogicalDrives(), GetDriveType(), DRIVE_*
#endif #endif
#if !defined(__GP2X__) && defined(USE_SDL) #if !defined(__GP2X__) && defined(USE_SDL)
@ -2872,7 +2872,10 @@ void Set_config_defaults(void)
#ifdef GRAFX2_CATCHES_SIGNALS #ifdef GRAFX2_CATCHES_SIGNALS
#if defined(__WIN32__) #if defined(WIN32)
#if defined(_MSC_VER)
typedef void (*__p_sig_fn_t)(int);
#endif
#define SIGHANDLER_T __p_sig_fn_t #define SIGHANDLER_T __p_sig_fn_t
#elif defined(__macosx__) #elif defined(__macosx__)
typedef void (*sig_t) (int); typedef void (*sig_t) (int);
@ -3096,7 +3099,9 @@ void Define_icon(void)
LPVOID lpResIcon32; LPVOID lpResIcon32;
HGLOBAL hMem; HGLOBAL hMem;
WORD nID; WORD nID;
#if defined(USE_SDL) || defined(USE_SDL2)
SDL_SysWMinfo info; SDL_SysWMinfo info;
#endif
hInstance = (HINSTANCE)GetModuleHandle(NULL); hInstance = (HINSTANCE)GetModuleHandle(NULL);
if (hInstance==NULL) if (hInstance==NULL)
@ -3118,9 +3123,11 @@ void Define_icon(void)
if (lpResIconDir==NULL) if (lpResIconDir==NULL)
break; break;
#if defined(USE_SDL) || defined(USE_SDL2)
SDL_VERSION(&info.version); SDL_VERSION(&info.version);
SDL_GetWMInfo(&info); SDL_GetWMInfo(&info);
#endif
// //
// 16x16 // 16x16
// //
@ -3152,9 +3159,13 @@ void Define_icon(void)
16, 16, LR_DEFAULTCOLOR); 16, 16, LR_DEFAULTCOLOR);
if (hicon==NULL) if (hicon==NULL)
break; break;
// Set it // Set it
#if defined(USE_SDL) || defined(USE_SDL2)
SetClassLongPtr(info.window, GCL_HICONSM, (LONG_PTR)hicon); SetClassLongPtr(info.window, GCL_HICONSM, (LONG_PTR)hicon);
#else
// TODO
#endif
// //
@ -3190,7 +3201,11 @@ void Define_icon(void)
break; break;
// Set it // Set it
#if defined(USE_SDL) || defined(USE_SDL2)
SetClassLongPtr(info.window, GCL_HICON, (LONG_PTR)hicon); SetClassLongPtr(info.window, GCL_HICON, (LONG_PTR)hicon);
#else
// TODO
#endif
// Success // Success

View File

@ -26,7 +26,7 @@
#include <SDL_syswm.h> #include <SDL_syswm.h>
#endif #endif
#ifdef __WIN32__ #ifdef WIN32
#include <windows.h> #include <windows.h>
#include <shellapi.h> #include <shellapi.h>
#endif #endif

View File

@ -598,7 +598,7 @@ void Get_full_filename(char * output_name, const char * file_name, const char *
} }
/// Lock file used to prevent several instances of grafx2 from harming each others' backups /// Lock file used to prevent several instances of grafx2 from harming each others' backups
#ifdef __WIN32__ #ifdef WIN32
HANDLE Lock_file_handle = INVALID_HANDLE_VALUE; HANDLE Lock_file_handle = INVALID_HANDLE_VALUE;
#else #else
int Lock_file_handle = -1; int Lock_file_handle = -1;
@ -618,7 +618,7 @@ byte Create_lock_file(const char *file_directory)
#endif #endif
strcat(lock_filename,"gfx2.lck"); strcat(lock_filename,"gfx2.lck");
#ifdef __WIN32__ #ifdef WIN32
// Windowzy method for creating a lock file // Windowzy method for creating a lock file
Lock_file_handle = CreateFileA( Lock_file_handle = CreateFileA(
lock_filename, lock_filename,
@ -655,7 +655,7 @@ void Release_lock_file(const char *file_directory)
{ {
char lock_filename[MAX_PATH_CHARACTERS]; char lock_filename[MAX_PATH_CHARACTERS];
#ifdef __WIN32__ #ifdef WIN32
if (Lock_file_handle != INVALID_HANDLE_VALUE) if (Lock_file_handle != INVALID_HANDLE_VALUE)
{ {
CloseHandle(Lock_file_handle); CloseHandle(Lock_file_handle);

View File

@ -79,7 +79,7 @@ void Extract_path(char *dest, const char *source);
/// Finds the rightmost path separator in a full filename. Used to separate directory from file. /// Finds the rightmost path separator in a full filename. Used to separate directory from file.
char * Find_last_separator(const char * str); char * Find_last_separator(const char * str);
#if defined(__WIN32__) #if defined(WIN32)
#define PATH_SEPARATOR "\\" #define PATH_SEPARATOR "\\"
#elif defined(__MINT__) #elif defined(__MINT__)
#define PATH_SEPARATOR "\\" #define PATH_SEPARATOR "\\"

View File

@ -715,7 +715,7 @@ void Zoom_a_line(byte* original_line, byte* zoomed_line,
/*############################################################################*/ /*############################################################################*/
#if defined(__WIN32__) #if defined(WIN32)
#include <windows.h> #include <windows.h>
#elif defined(__macosx__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #elif defined(__macosx__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#if defined(__OpenBSD__) #if defined(__OpenBSD__)
@ -755,7 +755,7 @@ unsigned long Memory_free(void)
// If Grafx2 thinks the memory is full, weird things may happen. And if memory // If Grafx2 thinks the memory is full, weird things may happen. And if memory
// ever becomes full and you're still saying there are 10MB free here, the // ever becomes full and you're still saying there are 10MB free here, the
// program will crash without saving any picture backup ! You've been warned... // program will crash without saving any picture backup ! You've been warned...
#if defined(__WIN32__) #if defined(WIN32)
MEMORYSTATUS mstt; MEMORYSTATUS mstt;
mstt.dwLength = sizeof(MEMORYSTATUS); mstt.dwLength = sizeof(MEMORYSTATUS);
GlobalMemoryStatus(&mstt); GlobalMemoryStatus(&mstt);

View File

@ -193,7 +193,7 @@ static int Valid_character(word c, int input_type)
// d'autres poseront des problèmes au shell, alors on évite. // d'autres poseront des problèmes au shell, alors on évite.
// Sous Windows : c'est moins grave car le fopen() échouerait de toutes façons. // Sous Windows : c'est moins grave car le fopen() échouerait de toutes façons.
// AmigaOS4: Pas de ':' car utilisé pour les volumes. // AmigaOS4: Pas de ':' car utilisé pour les volumes.
#if defined(__WIN32__) #if defined(WIN32)
char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':', '\\'}; char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':', '\\'};
#elif defined (__amigaos4__) || defined(__AROS__) #elif defined (__amigaos4__) || defined(__AROS__)
char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':'}; char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':'};
@ -305,8 +305,9 @@ void Init_virtual_keyboard(word y_pos, word keyboard_width, word keyboard_height
// TODO X11 and others // TODO X11 and others
static char* getClipboard(word * * unicode) static char* getClipboard(word * * unicode)
{ {
#ifdef __WIN32__ #ifdef WIN32
char* dst = NULL; char* dst = NULL;
#if defined(USE_SDL) || defined(USE_SDL2)
SDL_SysWMinfo info; SDL_SysWMinfo info;
SDL_VERSION(&info.version); SDL_VERSION(&info.version);
@ -314,6 +315,10 @@ static char* getClipboard(word * * unicode)
if ( SDL_GetWMInfo(&info) ) if ( SDL_GetWMInfo(&info) )
{ {
if (OpenClipboard(info.window) ) if (OpenClipboard(info.window) )
#else
{
if (OpenClipboard(GetActiveWindow()))
#endif
{ {
HANDLE hMem; HANDLE hMem;
if ( IsClipboardFormatAvailable(CF_TEXT) ) if ( IsClipboardFormatAvailable(CF_TEXT) )

View File

@ -69,7 +69,7 @@
if (chdir(path)) { if (chdir(path)) {
if (errno == ENOTDIR) { if (errno == ENOTDIR) {
#if defined(__WIN32__) || defined(__MORPHOS__) || defined(__amigaos__) #if defined(WIN32) || defined(__MORPHOS__) || defined(__amigaos__)
// No symbolic links and no readlink() // No symbolic links and no readlink()
l = -1; l = -1;
#else #else

View File

@ -295,7 +295,7 @@ void Init_text(void)
snprintf(directory_name, sizeof(directory_name), "%s%s", Config_directory, "/fonts"); snprintf(directory_name, sizeof(directory_name), "%s%s", Config_directory, "/fonts");
For_each_file(directory_name, Add_font); For_each_file(directory_name, Add_font);
#if defined(__WIN32__) #if defined(WIN32)
// Parcours du répertoire systeme windows "fonts" // Parcours du répertoire systeme windows "fonts"
#ifndef NOTTF #ifndef NOTTF
{ {
@ -709,6 +709,8 @@ byte *Render_text(const char *str, int font_number, int size, int antialias, int
{ {
#if defined(USE_SDL) || defined(USE_SDL2) #if defined(USE_SDL) || defined(USE_SDL2)
return Render_text_SFont(str, font_number, width, height, palette); return Render_text_SFont(str, font_number, width, height, palette);
#else
return NULL;
#endif #endif
} }
} }