GDI driver partially visible with RGUI/game now, need to figure out why it isn't totally visible. Also need to stretch the frame, swap red/blue and flip vertically.

This commit is contained in:
Brad Parker 2017-01-06 19:55:28 -05:00
parent dd2778fb32
commit 177d811475
2 changed files with 32 additions and 24 deletions

View File

@ -34,6 +34,7 @@ static unsigned gdi_menu_pitch = 0;
static unsigned gdi_video_width = 0;
static unsigned gdi_video_height = 0;
static unsigned gdi_video_pitch = 0;
static unsigned gdi_video_bits = 0;
static bool gdi_rgb32 = 0;
static void gdi_gfx_free(void *data);
@ -67,6 +68,8 @@ static void *gdi_gfx_init(const video_info_t *video,
gdi_video_height = video->height;
gdi_rgb32 = video->rgb32;
gdi_video_bits = video->rgb32 ? 32 : 16;
if (video->rgb32)
gdi_video_pitch = video->width * 4;
else
@ -218,12 +221,6 @@ static bool gdi_gfx_frame(void *data, const void *frame,
bool draw = true;
gdi_t *gdi = (gdi_t*)data;
(void)frame;
(void)frame_width;
(void)frame_height;
(void)pitch;
(void)msg;
if (!frame || !frame_width || !frame_height)
return true;
@ -257,18 +254,37 @@ 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,
width,
height,
gdi_dither, frame_to_copy);*/
unsigned win_width, win_height;
HWND hwnd = win32_get_window();
HDC dc = GetDC(hwnd);
BITMAPINFO info;
video_driver_get_size(&win_width, &win_height);
ZeroMemory(&info, sizeof(BITMAPINFO));
info.bmiHeader.biBitCount = gdi_video_bits;
info.bmiHeader.biWidth = width;
info.bmiHeader.biHeight = height;
info.bmiHeader.biPlanes = 1;
info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
info.bmiHeader.biSizeImage = pitch * height;
info.bmiHeader.biCompression = BI_RGB;
StretchDIBits(dc, 0, 0, win_width, win_height, 0, 0, width, height,
frame_to_copy, &info, DIB_RGB_COLORS, SRCCOPY);
ReleaseDC(hwnd, dc);
}
video_context_driver_update_window_title();
video_context_driver_swap_buffers();
//UpdateWindow(win32_get_window());
return true;

View File

@ -24,6 +24,7 @@
#endif
#include "../font_driver.h"
#include "../video_driver.h"
#include "../../configuration.h"
#include "../../verbosity.h"
#include "../common/gdi_common.h"
@ -93,6 +94,8 @@ static void gdi_render_msg(void *data, const char *msg,
if (!font || string_is_empty(msg))
return;
video_driver_get_size(&width, &height);
if (params)
{
x = params->x;
@ -107,23 +110,12 @@ static void gdi_render_msg(void *data, const char *msg,
if (!font->gdi)
return;
newX = x;//x * width;
newY = y;//height - (y * height);
//if (strlen(msg) + newX > width)
// newX -= strlen(msg) + newX - width;
//gdi_put_str(*font->gdi->gdi_cv, newX, newY, msg);
//gdi_refresh_display(*font->gdi->gdi_display);
printf("drawing text: %s at %d x %d\n", msg, newX, newY);
newX = x * width;
newY = height - (y * height);
hdc = GetDC(hwnd);
TextOut(hdc, newX, newY, msg, utf8len(msg));
ReleaseDC(hwnd, hdc);
UpdateWindow(hwnd);
}
static void gdi_font_flush_block(void* data)