mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +01:00
make fixpitch setting working with primary surface too
This commit is contained in:
parent
efad3e0fd5
commit
e578df74e3
@ -32,7 +32,6 @@ typedef struct OGLRENDERER
|
||||
GLuint scale_vbos[3];
|
||||
GLuint scale_vao;
|
||||
BOOL use_opengl;
|
||||
BOOL adjust_alignment;
|
||||
BOOL filter_bilinear;
|
||||
} OGLRENDERER;
|
||||
|
||||
|
@ -36,7 +36,7 @@ void cfg_load()
|
||||
g_ddraw->accurate_timers = cfg_get_bool("accuratetimers", FALSE);
|
||||
g_ddraw->resizable = cfg_get_bool("resizable", TRUE);
|
||||
g_ddraw->nonexclusive = cfg_get_bool("nonexclusive", FALSE);
|
||||
g_ddraw->fixpitch = cfg_get_bool("fixpitch", FALSE);
|
||||
g_ddraw->fixpitch = cfg_get_bool("fixpitch", TRUE);
|
||||
g_ddraw->fixchilds = cfg_get_int("fixchilds", FIX_CHILDS_DETECT_PAINT);
|
||||
g_ddraw->fixwndprochook = cfg_get_bool("fixwndprochook", FALSE);
|
||||
g_ddraw->novidmem = cfg_get_bool("novidmem", FALSE);
|
||||
@ -332,7 +332,7 @@ static void cfg_create_ini()
|
||||
"\n"
|
||||
"; Fixes issues where the pitch of a surface is not a multiple of 4\n"
|
||||
"; Note: Enable this if some parts of the screen are being displayed diagonally\n"
|
||||
"fixpitch=false\n"
|
||||
"fixpitch=true\n"
|
||||
"\n"
|
||||
"; Force CPU0 affinity, avoids crashes/freezing, *might* have a performance impact\n"
|
||||
"singlecpu=true\n"
|
||||
|
@ -1030,16 +1030,17 @@ HRESULT dd_CreateSurface(
|
||||
|
||||
if (dst_surface->width && dst_surface->height)
|
||||
{
|
||||
if (dst_surface->width == 71 && dst_surface->height == 24) dst_surface->width = 72; //Commandos
|
||||
DWORD bmp_width = dst_surface->width;
|
||||
DWORD bmp_height = dst_surface->height;
|
||||
|
||||
dst_surface->lx_pitch = dst_surface->bpp / 8;
|
||||
dst_surface->l_pitch = dst_surface->width * dst_surface->lx_pitch;
|
||||
dst_surface->l_pitch = bmp_width * dst_surface->lx_pitch;
|
||||
|
||||
if (g_ddraw->fixpitch && !(dst_surface->caps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_BACKBUFFER)))
|
||||
if (g_ddraw->fixpitch)
|
||||
{
|
||||
while (dst_surface->l_pitch % 4)
|
||||
{
|
||||
dst_surface->l_pitch = ++dst_surface->width * dst_surface->lx_pitch;
|
||||
dst_surface->l_pitch = ++bmp_width * dst_surface->lx_pitch;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1047,8 +1048,8 @@ HRESULT dd_CreateSurface(
|
||||
HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256);
|
||||
|
||||
dst_surface->bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
dst_surface->bmi->bmiHeader.biWidth = dst_surface->width;
|
||||
dst_surface->bmi->bmiHeader.biHeight = -((int)dst_surface->height + 200);
|
||||
dst_surface->bmi->bmiHeader.biWidth = bmp_width;
|
||||
dst_surface->bmi->bmiHeader.biHeight = -((int)bmp_height + 200);
|
||||
dst_surface->bmi->bmiHeader.biPlanes = 1;
|
||||
dst_surface->bmi->bmiHeader.biBitCount = dst_surface->bpp;
|
||||
dst_surface->bmi->bmiHeader.biCompression = dst_surface->bpp == 8 ? BI_RGB : BI_BITFIELDS;
|
||||
@ -1061,7 +1062,7 @@ HRESULT dd_CreateSurface(
|
||||
}
|
||||
|
||||
dst_surface->bmi->bmiHeader.biSizeImage =
|
||||
((dst_surface->width * clr_bits + 31) & ~31) / 8 * dst_surface->height;
|
||||
((bmp_width * clr_bits + 31) & ~31) / 8 * bmp_height;
|
||||
|
||||
if (dst_surface->bpp == 8)
|
||||
{
|
||||
@ -1090,7 +1091,7 @@ HRESULT dd_CreateSurface(
|
||||
dst_surface->bitmap =
|
||||
CreateDIBSection(dst_surface->hdc, dst_surface->bmi, DIB_RGB_COLORS, (void**)&dst_surface->surface, NULL, 0);
|
||||
|
||||
dst_surface->bmi->bmiHeader.biHeight = -((int)dst_surface->height);
|
||||
dst_surface->bmi->bmiHeader.biHeight = -((int)bmp_height);
|
||||
|
||||
if (!dst_surface->bitmap)
|
||||
{
|
||||
@ -1098,7 +1099,7 @@ HRESULT dd_CreateSurface(
|
||||
HeapAlloc(
|
||||
GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
dst_surface->l_pitch * (dst_surface->height + 200) * dst_surface->lx_pitch);
|
||||
dst_surface->l_pitch * (bmp_height + 200) * dst_surface->lx_pitch);
|
||||
}
|
||||
|
||||
if (dst_surface->caps & DDSCAPS_PRIMARYSURFACE)
|
||||
|
@ -361,6 +361,8 @@ DWORD WINAPI d3d9_render_main(void)
|
||||
|
||||
if (g_ddraw->primary &&
|
||||
g_ddraw->primary->bpp == g_ddraw->bpp &&
|
||||
g_ddraw->primary->width == g_ddraw->width &&
|
||||
g_ddraw->primary->height == g_ddraw->height &&
|
||||
(g_ddraw->bpp == 16 || g_ddraw->bpp == 32 || g_ddraw->primary->palette))
|
||||
{
|
||||
if (g_ddraw->vhack)
|
||||
|
@ -49,6 +49,8 @@ DWORD WINAPI gdi_render_main(void)
|
||||
|
||||
if (g_ddraw->primary &&
|
||||
g_ddraw->primary->bpp == g_ddraw->bpp &&
|
||||
g_ddraw->primary->width == g_ddraw->width &&
|
||||
g_ddraw->primary->height == g_ddraw->height &&
|
||||
(g_ddraw->bpp == 16 || g_ddraw->bpp == 32 || g_ddraw->primary->palette))
|
||||
{
|
||||
if (warning_end_tick)
|
||||
|
@ -184,8 +184,6 @@ static void ogl_create_textures(int width, int height)
|
||||
g_ogl.surface_tex =
|
||||
HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, g_ogl.surface_tex_width * g_ogl.surface_tex_height * sizeof(int));
|
||||
|
||||
g_ogl.adjust_alignment = (width % 4) != 0;
|
||||
|
||||
g_ogl.scale_w = (float)width / g_ogl.surface_tex_width;
|
||||
g_ogl.scale_h = (float)height / g_ogl.surface_tex_height;
|
||||
|
||||
@ -598,6 +596,8 @@ static void ogl_render()
|
||||
|
||||
if (g_ddraw->primary &&
|
||||
g_ddraw->primary->bpp == g_ddraw->bpp &&
|
||||
g_ddraw->primary->width == g_ddraw->width &&
|
||||
g_ddraw->primary->height == g_ddraw->height &&
|
||||
(g_ddraw->bpp == 16 || g_ddraw->bpp == 32 || g_ddraw->primary->palette))
|
||||
{
|
||||
if (g_ddraw->vhack)
|
||||
@ -644,8 +644,10 @@ static void ogl_render()
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, g_ogl.surface_tex_ids[tex_index]);
|
||||
|
||||
if (g_ogl.adjust_alignment)
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
DWORD row_len = g_ddraw->primary->l_pitch ? g_ddraw->primary->l_pitch / g_ddraw->primary->lx_pitch : 0;
|
||||
|
||||
if (row_len != g_ddraw->primary->width)
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, row_len);
|
||||
|
||||
glTexSubImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
@ -658,8 +660,8 @@ static void ogl_render()
|
||||
g_ogl.surface_type,
|
||||
g_ddraw->primary->surface);
|
||||
|
||||
if (g_ogl.adjust_alignment)
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||
if (row_len != g_ddraw->primary->width)
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
}
|
||||
|
||||
static int error_check_count = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user