win_opengl: Fix MSVC build errors and warnings

This commit is contained in:
ts-korhonen
2021-04-17 00:12:49 +03:00
parent 7a83b463c2
commit b7be825ba7
3 changed files with 24 additions and 13 deletions

View File

@@ -19,8 +19,8 @@
#include <Windows.h> #include <Windows.h>
extern int opengl_init(HWND hwnd); extern int opengl_init(HWND hwnd);
extern int opengl_pause(); extern int opengl_pause(void);
extern void opengl_close(); extern void opengl_close(void);
extern void opengl_set_fs(int fs); extern void opengl_set_fs(int fs);
extern void opengl_resize(int w, int h); extern void opengl_resize(int w, int h);

View File

@@ -39,6 +39,9 @@
#include <SDL2/SDL_syswm.h> #include <SDL2/SDL_syswm.h>
#include <glad/glad.h> #include <glad/glad.h>
#include <stdlib.h>
#include <stdint.h>
#include <86box/86box.h> #include <86box/86box.h>
#include <86box/plat.h> #include <86box/plat.h>
#include <86box/video.h> #include <86box/video.h>
@@ -51,8 +54,7 @@ static const int INIT_HEIGHT = 400;
/* Option; Target framerate: Sync with emulation / 25 fps / 30 fps / 50 fps / 60 fps / 75 fps */ /* Option; Target framerate: Sync with emulation / 25 fps / 30 fps / 50 fps / 60 fps / 75 fps */
static const int SYNC_WITH_BLITTER = 1; static const int SYNC_WITH_BLITTER = 1;
static const int TARGET_FRAMERATE = 75; static const int TARGET_FRAMETIME = 13;
static const int TARGET_FRAMETIME = 1000 / TARGET_FRAMERATE;
/* Option; Vsync: Off / On */ /* Option; Vsync: Off / On */
static const int VSYNC = 0; static const int VSYNC = 0;
@@ -90,7 +92,7 @@ static union
HANDLE blit_waiting; HANDLE blit_waiting;
}; };
HANDLE asArray[3]; HANDLE asArray[3];
} sync_objects = {}; } sync_objects = { 0 };
/** /**
* @brief Signal from OpenGL thread that it's done with video buffer. * @brief Signal from OpenGL thread that it's done with video buffer.
@@ -103,7 +105,7 @@ static HANDLE blit_done = NULL;
static volatile struct static volatile struct
{ {
int x, y, y1, y2, w, h, resized; int x, y, y1, y2, w, h, resized;
} blit_info = {}; } blit_info = { 0 };
/** /**
* @brief Resize event parameters. * @brief Resize event parameters.
@@ -111,7 +113,7 @@ static volatile struct
static volatile struct static volatile struct
{ {
int width, height, fullscreen, scaling_mode; int width, height, fullscreen, scaling_mode;
} resize_info = {}; } resize_info = { 0 };
/** /**
* @brief Identifiers to OpenGL objects and uniforms. * @brief Identifiers to OpenGL objects and uniforms.
@@ -250,7 +252,7 @@ static gl_identifiers initialize_glcontext()
1.f, -1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f 1.f, -1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f
}; };
gl_identifiers gl = {}; gl_identifiers gl = { 0 };
glGenVertexArrays(1, &gl.vertexArrayID); glGenVertexArrays(1, &gl.vertexArrayID);
@@ -361,7 +363,7 @@ static void render_and_swap(gl_identifiers gl)
* OpenGL context should be accessed only from this single thread. * OpenGL context should be accessed only from this single thread.
* Events are used to synchronize communication. * Events are used to synchronize communication.
*/ */
static void opengl_main() static void opengl_main(void* param)
{ {
SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); /* Is this actually doing anything...? */ SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); /* Is this actually doing anything...? */
@@ -372,7 +374,7 @@ static void opengl_main()
/* Keep track of certain parameters, only changed in this thread to avoid race conditions */ /* Keep track of certain parameters, only changed in this thread to avoid race conditions */
int fullscreen = resize_info.fullscreen, video_width = INIT_WIDTH, video_height = INIT_HEIGHT; int fullscreen = resize_info.fullscreen, video_width = INIT_WIDTH, video_height = INIT_HEIGHT;
SDL_SysWMinfo wmi; SDL_SysWMinfo wmi = { 0 };
SDL_VERSION(&wmi.version); SDL_VERSION(&wmi.version);
SDL_GetWindowWMInfo(window, &wmi); SDL_GetWindowWMInfo(window, &wmi);
@@ -602,12 +604,12 @@ int opengl_init(HWND hwnd)
return 1; return 1;
} }
int opengl_pause() int opengl_pause(void)
{ {
return 0; return 0;
} }
void opengl_close() void opengl_close(void)
{ {
if (thread == NULL) if (thread == NULL)
return; return;

View File

@@ -34,6 +34,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdint.h>
#include <86box/86box.h> #include <86box/86box.h>
#include <86box/plat.h> #include <86box/plat.h>
@@ -80,13 +81,21 @@ static char* read_file_to_string(const char* path)
{ {
/* get file size */ /* get file size */
fseek(file_handle, 0, SEEK_END); fseek(file_handle, 0, SEEK_END);
long file_size = ftell(file_handle);
size_t file_size = (size_t)ftell(file_handle);
fseek(file_handle, 0, SEEK_SET); fseek(file_handle, 0, SEEK_SET);
/* read to buffer and close */ /* read to buffer and close */
char* content = (char*)malloc(sizeof(char) * (file_size + 1)); char* content = (char*)malloc(sizeof(char) * (file_size + 1));
if (!content)
return NULL;
size_t length = fread(content, sizeof(char), file_size, file_handle); size_t length = fread(content, sizeof(char), file_size, file_handle);
fclose(file_handle); fclose(file_handle);
content[length] = 0; content[length] = 0;
return content; return content;