diff --git a/src/gl/MiniFB_GL.c b/src/gl/MiniFB_GL.c index 737c010..b743244 100644 --- a/src/gl/MiniFB_GL.c +++ b/src/gl/MiniFB_GL.c @@ -203,6 +203,18 @@ init_GL(SWindowData *window_data) { void resize_GL(SWindowData *window_data) { if(window_data->is_initialized) { + #if defined(_WIN32) || defined(WIN32) + + SWindowData_Win *window_data_ex = (SWindowData_Win *) window_data->specific; + wglMakeCurrent(window_data_ex->hdc, window_data_ex->hGLRC); + + #elif defined(linux) + + SWindowData_X11 *window_data_ex = (SWindowData_X11 *) window_data->specific; + glXMakeCurrent(window_data_ex->display, window_data_ex->window, window_data_ex->context); + + #endif + glViewport(0, 0, window_data->window_width, window_data->window_height); glMatrixMode(GL_PROJECTION); @@ -221,11 +233,15 @@ redraw_GL(SWindowData *window_data, const void *pixels) { SWindowData_Win *window_data_ex = (SWindowData_Win *) window_data->specific; GLenum format = BGRA; + wglMakeCurrent(window_data_ex->hdc, window_data_ex->hGLRC); + #elif defined(linux) SWindowData_X11 *window_data_ex = (SWindowData_X11 *) window_data->specific; GLenum format = BGRA; + glXMakeCurrent(window_data_ex->display, window_data_ex->window, window_data_ex->context); + #endif float x, y, w, h; diff --git a/tests/hidpi.c b/tests/hidpi.c index 3cf2c1b..4053a89 100644 --- a/tests/hidpi.c +++ b/tests/hidpi.c @@ -1,7 +1,6 @@ #include #include #include -#include #include #define DIMEN_LOW 512 @@ -11,38 +10,35 @@ static unsigned int g_buffer_low[DIMEN_LOW * DIMEN_LOW]; static unsigned int g_buffer_high[DIMEN_HIGH * DIMEN_HIGH]; void -pretty_square(unsigned int *p, int dimen) -{ - memset(p, 127, dimen*dimen*4); - const int one_half_dimen = dimen / 2; - const int one_quarter_dimen = one_half_dimen / 2; - const int three_quarter_dimen = one_half_dimen + one_quarter_dimen; - for (int x = one_quarter_dimen; x < three_quarter_dimen; x++) - for (int y = one_quarter_dimen; y < three_quarter_dimen; y++) - p[y*dimen + x] = (x & 1) ? MFB_RGB(223,0,(255*(x-one_quarter_dimen))/one_half_dimen) : MFB_RGB(0,0,0); +pretty_square(unsigned int *p, int dimen) { + memset(p, 127, dimen * dimen * 4); + const int one_half_dimen = dimen / 2; + const int one_quarter_dimen = one_half_dimen / 2; + const int three_quarter_dimen = one_half_dimen + one_quarter_dimen; + for (int x = one_quarter_dimen; x < three_quarter_dimen; x++) + for (int y = one_quarter_dimen; y < three_quarter_dimen; y++) + p[y * dimen + x] = (x & 1) ? MFB_RGB(223, 0, (255 * (x - one_quarter_dimen)) / one_half_dimen) : MFB_RGB(0, 0, 0); } -int -main() -{ - pretty_square(g_buffer_low, DIMEN_LOW); - pretty_square(g_buffer_high, DIMEN_HIGH); +int +main() { + pretty_square(g_buffer_low, DIMEN_LOW); + pretty_square(g_buffer_high, DIMEN_HIGH); - struct mfb_window *window_low = mfb_open("LowRes", DIMEN_LOW, DIMEN_LOW); - struct mfb_window *window_high = mfb_open("HighRes", DIMEN_HIGH/2, DIMEN_HIGH/2); + struct mfb_window *window_low = mfb_open("LowRes", DIMEN_LOW, DIMEN_LOW); + struct mfb_window *window_high = mfb_open("HighRes", DIMEN_HIGH / 2, DIMEN_HIGH / 2); - while (window_high || window_low) - { - if (window_low) - if (mfb_update_ex(window_low, g_buffer_low, DIMEN_LOW, DIMEN_LOW) != STATE_OK - || !mfb_wait_sync(window_low)) - window_low = NULL; + while (window_high || window_low) { + if (window_low) + if (mfb_update_ex(window_low, g_buffer_low, DIMEN_LOW, DIMEN_LOW) != STATE_OK + || !mfb_wait_sync(window_low)) + window_low = NULL; - if (window_high) - if (mfb_update_ex(window_high, g_buffer_high, DIMEN_HIGH, DIMEN_HIGH) != STATE_OK - || !mfb_wait_sync(window_high)) - window_high = NULL; + if (window_high) + if (mfb_update_ex(window_high, g_buffer_high, DIMEN_HIGH, DIMEN_HIGH) != STATE_OK + || !mfb_wait_sync(window_high)) + window_high = NULL; } - - return 0; + + return 0; }