diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 8337d1f179..4adff55e2f 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -515,6 +515,10 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message, { LRESULT ret; bool quit = false; + PAINTSTRUCT ps; + HDC hdc; + RECT rc; + POINT aptStar[6] = {50,2, 2,98, 98,33, 2,33, 98,98, 50,2}; if (message == WM_NCLBUTTONDBLCLK) doubleclick_on_titlebar = true; @@ -522,11 +526,15 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message, switch (message) { case WM_PAINT: - PAINTSTRUCT ps; - HDC hdc = BeginPaint(hwnd, &ps); - TextOut(hdc, 0, 0, "Hello, Windows!", 15); + hdc = BeginPaint(hwnd, &ps); + //TextOut(hdc, 0, 0, "Hello, Windows!", 15); + GetClientRect(hwnd, &rc); + SetMapMode(hdc, MM_ANISOTROPIC); + SetWindowExtEx(hdc, 100, 100, NULL); + SetViewportExtEx(hdc, rc.right, rc.bottom, NULL); + Polyline(hdc, aptStar, 6); EndPaint(hwnd, &ps); - break; + return 0L; case WM_DROPFILES: case WM_SYSCOMMAND: case WM_CHAR: @@ -856,6 +864,7 @@ bool win32_set_video_mode(void *data, if (res == -1) { RARCH_ERR("GetMessage error code %d\n", GetLastError()); + break; } else { diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index c35306a0c3..37dbd6efbc 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -85,7 +85,13 @@ bool win32_get_metrics(void *data, void win32_show_cursor(bool state); +#ifdef __cplusplus +extern "C" { +#endif HWND win32_get_window(void); +#ifdef __cplusplus +} +#endif bool win32_has_focus(void); @@ -96,7 +102,6 @@ void win32_set_window(unsigned *width, unsigned *height, bool fullscreen, bool windowed_full, void *rect_data); #ifndef _XBOX -/* FIXME: It should not be necessary to add the W after MONITORINFOEX, but linking fails without it. */ void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use, unsigned *width, unsigned *height, bool fullscreen, bool windowed_full, RECT *rect, RECT *mon_rect, DWORD *style); diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c index 7686be526a..93ff82e2fc 100644 --- a/gfx/drivers/gdi_gfx.c +++ b/gfx/drivers/gdi_gfx.c @@ -23,6 +23,10 @@ #include "../../menu/menu_driver.h" #include "../common/gdi_common.h" +#if defined(_WIN32) && !defined(_XBOX) +#include "../common/win32_common.h" +#endif + static unsigned char *gdi_menu_frame = NULL; static unsigned gdi_menu_width = 0; static unsigned gdi_menu_height = 0; @@ -212,8 +216,8 @@ static bool gdi_gfx_frame(void *data, const void *frame, unsigned width = 0; unsigned height = 0; bool draw = true; + gdi_t *gdi = (gdi_t*)data; - (void)data; (void)frame; (void)frame_width; (void)frame_height; @@ -253,6 +257,10 @@ static bool gdi_gfx_frame(void *data, const void *frame, if (msg) font_driver_render_msg(NULL, msg, NULL); + video_context_driver_update_window_title(); + + video_context_driver_swap_buffers(); + if (draw) { /*gdi_dither_bitmap(gdi_cv, 0, 0, @@ -261,6 +269,8 @@ static bool gdi_gfx_frame(void *data, const void *frame, gdi_dither, frame_to_copy);*/ } + //UpdateWindow(win32_get_window()); + return true; } diff --git a/gfx/drivers_context/gdi_ctx.cpp b/gfx/drivers_context/gdi_ctx.cpp index 4d93578a38..a2a8c12abb 100644 --- a/gfx/drivers_context/gdi_ctx.cpp +++ b/gfx/drivers_context/gdi_ctx.cpp @@ -40,16 +40,16 @@ #include "../common/win32_common.h" -static HDC win32_hdc; +static HDC win32_gdi_hdc; -static unsigned win32_major = 0; -static unsigned win32_minor = 0; -static unsigned win32_interval = 0; -static enum gfx_ctx_api win32_api = GFX_CTX_NONE; +static unsigned win32_gdi_major = 0; +static unsigned win32_gdi_minor = 0; +static unsigned win32_gdi_interval = 0; +static enum gfx_ctx_api win32_gdi_api = GFX_CTX_NONE; void *dinput_gdi; -static void setup_pixel_format(HDC hdc) +static void setup_gdi_pixel_format(HDC hdc) { PIXELFORMATDESCRIPTOR pfd = {0}; pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); @@ -77,7 +77,7 @@ static bool gfx_ctx_gdi_set_resize(void *data, (void)width; (void)height; - switch (win32_api) + switch (win32_gdi_api) { case GFX_CTX_NONE: default: @@ -144,7 +144,7 @@ static void *gfx_ctx_gdi_init(void *video_driver) if (!win32_window_init(&wndclass, true, NULL)) return NULL; - switch (win32_api) + switch (win32_gdi_api) { case GFX_CTX_NONE: default: @@ -160,17 +160,17 @@ static void gfx_ctx_gdi_destroy(void *data) (void)data; - switch (win32_api) + switch (win32_gdi_api) { case GFX_CTX_NONE: default: break; } - if (window && win32_hdc) + if (window && win32_gdi_hdc) { - ReleaseDC(window, win32_hdc); - win32_hdc = NULL; + ReleaseDC(window, win32_gdi_hdc); + win32_gdi_hdc = NULL; } if (window) @@ -186,8 +186,8 @@ static void gfx_ctx_gdi_destroy(void *data) } g_inited = false; - win32_major = 0; - win32_minor = 0; + win32_gdi_major = 0; + win32_gdi_minor = 0; } static bool gfx_ctx_gdi_set_video_mode(void *data, @@ -200,7 +200,7 @@ static bool gfx_ctx_gdi_set_video_mode(void *data, goto error; } - switch (win32_api) + switch (win32_gdi_api) { case GFX_CTX_NONE: default: @@ -254,9 +254,9 @@ static bool gfx_ctx_gdi_bind_api(void *data, { (void)data; - win32_major = major; - win32_minor = minor; - win32_api = api; + win32_gdi_major = major; + win32_gdi_minor = minor; + win32_gdi_api = api; return true; } @@ -290,15 +290,15 @@ static void gfx_ctx_gdi_swap_buffers(void *data) { (void)data; - SwapBuffers(win32_hdc); + SwapBuffers(win32_gdi_hdc); } void create_gdi_context(HWND hwnd, bool *quit) { (void)quit; - win32_hdc = GetDC(hwnd); + win32_gdi_hdc = GetDC(hwnd); - setup_pixel_format(win32_hdc); + setup_gdi_pixel_format(win32_gdi_hdc); g_inited = true; } diff --git a/griffin/griffin.c b/griffin/griffin.c index bd09df0a0a..8a2942388b 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -221,7 +221,6 @@ VIDEO CONTEXT #endif - /*============================================================ VIDEO SHADERS ============================================================ */ @@ -358,6 +357,10 @@ VIDEO DRIVER #endif #include "../gfx/drivers/nullgfx.c" +#if defined(_WIN32) && !defined(_XBOX) +#include "../gfx/drivers/gdi_gfx.c" +#endif + /*============================================================ FONTS ============================================================ */ diff --git a/griffin/griffin_cpp.cpp b/griffin/griffin_cpp.cpp index 0207179676..e01399c174 100644 --- a/griffin/griffin_cpp.cpp +++ b/griffin/griffin_cpp.cpp @@ -115,6 +115,10 @@ UI COMMON CONTEXT #include "../gfx/drivers_context/wgl_ctx.cpp" #endif +#if defined(_WIN32) && !defined(_XBOX) +#include "../gfx/drivers_context/gdi_ctx.cpp" +#endif + #if defined(HAVE_FFMPEG) #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES3) #include "../cores/libretro-ffmpeg/fft/fft.cpp"