mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-24 17:49:52 +01:00
align
This commit is contained in:
parent
da69bc6620
commit
b417da74f6
4
inc/dd.h
4
inc/dd.h
@ -83,8 +83,8 @@ typedef struct cnc_ddraw
|
|||||||
BOOL devmode;
|
BOOL devmode;
|
||||||
BOOL vsync;
|
BOOL vsync;
|
||||||
BOOL vhack;
|
BOOL vhack;
|
||||||
BOOL isredalert;
|
BOOL isredalert;
|
||||||
BOOL iscnc1;
|
BOOL iscnc1;
|
||||||
LONG incutscene;
|
LONG incutscene;
|
||||||
DWORD (WINAPI *renderer)(void);
|
DWORD (WINAPI *renderer)(void);
|
||||||
BOOL fullscreen;
|
BOOL fullscreen;
|
||||||
|
@ -250,21 +250,21 @@ static BOOL d3d9_set_states()
|
|||||||
|
|
||||||
static BOOL d3d9_update_vertices(BOOL in_cutscene, BOOL stretch)
|
static BOOL d3d9_update_vertices(BOOL in_cutscene, BOOL stretch)
|
||||||
{
|
{
|
||||||
float vpX = stretch ? (float)g_ddraw->render.viewport.x : 0.0f;
|
float vp_x = stretch ? (float)g_ddraw->render.viewport.x : 0.0f;
|
||||||
float vpY = stretch ? (float)g_ddraw->render.viewport.y : 0.0f;
|
float vp_y = stretch ? (float)g_ddraw->render.viewport.y : 0.0f;
|
||||||
|
|
||||||
float vpW = stretch ? (float)(g_ddraw->render.viewport.width + g_ddraw->render.viewport.x) : (float)g_ddraw->width;
|
float vp_w = stretch ? (float)(g_ddraw->render.viewport.width + g_ddraw->render.viewport.x) : (float)g_ddraw->width;
|
||||||
float vpH = stretch ? (float)(g_ddraw->render.viewport.height + g_ddraw->render.viewport.y) : (float)g_ddraw->height;
|
float vp_h = stretch ? (float)(g_ddraw->render.viewport.height + g_ddraw->render.viewport.y) : (float)g_ddraw->height;
|
||||||
|
|
||||||
float sH = in_cutscene ? g_d3d9.scale_h * ((float)CUTSCENE_HEIGHT / g_ddraw->height) : g_d3d9.scale_h;
|
float s_h = in_cutscene ? g_d3d9.scale_h * ((float)CUTSCENE_HEIGHT / g_ddraw->height) : g_d3d9.scale_h;
|
||||||
float sW = in_cutscene ? g_d3d9.scale_w * ((float)CUTSCENE_WIDTH / g_ddraw->width) : g_d3d9.scale_w;
|
float s_w = in_cutscene ? g_d3d9.scale_w * ((float)CUTSCENE_WIDTH / g_ddraw->width) : g_d3d9.scale_w;
|
||||||
|
|
||||||
CUSTOMVERTEX vertices[] =
|
CUSTOMVERTEX vertices[] =
|
||||||
{
|
{
|
||||||
{ vpX - 0.5f, vpH - 0.5f, 0.0f, 1.0f, 0.0f, sH },
|
{ vp_x - 0.5f, vp_h - 0.5f, 0.0f, 1.0f, 0.0f, s_h },
|
||||||
{ vpX - 0.5f, vpY - 0.5f, 0.0f, 1.0f, 0.0f, 0.0f },
|
{ vp_x - 0.5f, vp_y - 0.5f, 0.0f, 1.0f, 0.0f, 0.0f },
|
||||||
{ vpW - 0.5f, vpH - 0.5f, 0.0f, 1.0f, sW, sH },
|
{ vp_w - 0.5f, vp_h - 0.5f, 0.0f, 1.0f, s_w, s_h },
|
||||||
{ vpW - 0.5f, vpY - 0.5f, 0.0f, 1.0f, sW, 0.0f }
|
{ vp_w - 0.5f, vp_y - 0.5f, 0.0f, 1.0f, s_w, 0.0f }
|
||||||
};
|
};
|
||||||
|
|
||||||
void *data;
|
void *data;
|
||||||
|
@ -175,7 +175,8 @@ static void ogl_create_textures(int width, int height)
|
|||||||
g_ogl.surface_tex_height =
|
g_ogl.surface_tex_height =
|
||||||
height <= 512 ? 512 : height <= 1024 ? 1024 : height <= 2048 ? 2048 : height <= 4096 ? 4096 : height;
|
height <= 512 ? 512 : height <= 1024 ? 1024 : height <= 2048 ? 2048 : height <= 4096 ? 4096 : height;
|
||||||
|
|
||||||
g_ogl.surface_tex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, g_ogl.surface_tex_width * g_ogl.surface_tex_height * sizeof(int));
|
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.adjust_alignment = (width % 4) != 0;
|
||||||
|
|
||||||
@ -316,8 +317,8 @@ static void ogl_init_main_program()
|
|||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, g_ogl.main_vbos[1]);
|
glBindBuffer(GL_ARRAY_BUFFER, g_ogl.main_vbos[1]);
|
||||||
GLfloat tex_coord[] = {
|
GLfloat tex_coord[] = {
|
||||||
0.0f, 0.0f,
|
0.0f, 0.0f,
|
||||||
0.0f, g_ogl.scale_h,
|
0.0f, g_ogl.scale_h,
|
||||||
g_ogl.scale_w, g_ogl.scale_h,
|
g_ogl.scale_w, g_ogl.scale_h,
|
||||||
g_ogl.scale_w, 0.0f,
|
g_ogl.scale_w, 0.0f,
|
||||||
};
|
};
|
||||||
@ -338,10 +339,10 @@ static void ogl_init_main_program()
|
|||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, g_ogl.main_vbos[1]);
|
glBindBuffer(GL_ARRAY_BUFFER, g_ogl.main_vbos[1]);
|
||||||
GLfloat tex_coord[] = {
|
GLfloat tex_coord[] = {
|
||||||
0.0f, 0.0f,
|
0.0f, 0.0f,
|
||||||
g_ogl.scale_w, 0.0f,
|
g_ogl.scale_w, 0.0f,
|
||||||
g_ogl.scale_w, g_ogl.scale_h,
|
g_ogl.scale_w, g_ogl.scale_h,
|
||||||
0.0f, g_ogl.scale_h,
|
0.0f, g_ogl.scale_h,
|
||||||
};
|
};
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(tex_coord), tex_coord, GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, sizeof(tex_coord), tex_coord, GL_STATIC_DRAW);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
@ -511,10 +512,10 @@ static void ogl_init_scale_program()
|
|||||||
glBindVertexArray(g_ogl.main_vao);
|
glBindVertexArray(g_ogl.main_vao);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, g_ogl.main_vbos[1]);
|
glBindBuffer(GL_ARRAY_BUFFER, g_ogl.main_vbos[1]);
|
||||||
GLfloat tex_coord_pal[] = {
|
GLfloat tex_coord_pal[] = {
|
||||||
0.0f, 0.0f,
|
0.0f, 0.0f,
|
||||||
g_ogl.scale_w, 0.0f,
|
g_ogl.scale_w, 0.0f,
|
||||||
g_ogl.scale_w, g_ogl.scale_h,
|
g_ogl.scale_w, g_ogl.scale_h,
|
||||||
0.0f, g_ogl.scale_h,
|
0.0f, g_ogl.scale_h,
|
||||||
};
|
};
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(tex_coord_pal), tex_coord_pal, GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, sizeof(tex_coord_pal), tex_coord_pal, GL_STATIC_DRAW);
|
||||||
glVertexAttribPointer(g_ogl.main_tex_coord_attr_loc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
glVertexAttribPointer(g_ogl.main_tex_coord_attr_loc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
||||||
@ -538,9 +539,13 @@ static void ogl_render()
|
|||||||
g_ddraw->render.viewport.width, g_ddraw->render.viewport.height);
|
g_ddraw->render.viewport.width, g_ddraw->render.viewport.height);
|
||||||
|
|
||||||
if (g_ogl.main_program)
|
if (g_ogl.main_program)
|
||||||
|
{
|
||||||
glUseProgram(g_ogl.main_program);
|
glUseProgram(g_ogl.main_program);
|
||||||
|
}
|
||||||
else if (g_ddraw->bpp == 16)
|
else if (g_ddraw->bpp == 16)
|
||||||
|
{
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
}
|
||||||
|
|
||||||
while (g_ogl.use_opengl && g_ddraw->render.run &&
|
while (g_ogl.use_opengl && g_ddraw->render.run &&
|
||||||
(g_ddraw->render.forcefps || WaitForSingleObject(g_ddraw->render.sem, 200) != WAIT_FAILED))
|
(g_ddraw->render.forcefps || WaitForSingleObject(g_ddraw->render.sem, 200) != WAIT_FAILED))
|
||||||
@ -625,6 +630,7 @@ static void ogl_render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int error_check_count = 0;
|
static int error_check_count = 0;
|
||||||
|
|
||||||
if (error_check_count < 20)
|
if (error_check_count < 20)
|
||||||
{
|
{
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
@ -673,8 +679,8 @@ static void ogl_render()
|
|||||||
glBindVertexArray(g_ogl.main_vao);
|
glBindVertexArray(g_ogl.main_vao);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, g_ogl.main_vbos[1]);
|
glBindBuffer(GL_ARRAY_BUFFER, g_ogl.main_vbos[1]);
|
||||||
GLfloat texCoord[] = {
|
GLfloat texCoord[] = {
|
||||||
0.0f, 0.0f,
|
0.0f, 0.0f,
|
||||||
0.0f, g_ogl.scale_h,
|
0.0f, g_ogl.scale_h,
|
||||||
g_ogl.scale_w, g_ogl.scale_h,
|
g_ogl.scale_w, g_ogl.scale_h,
|
||||||
g_ogl.scale_w, 0.0f,
|
g_ogl.scale_w, 0.0f,
|
||||||
};
|
};
|
||||||
@ -689,10 +695,10 @@ static void ogl_render()
|
|||||||
glBindVertexArray(g_ogl.main_vao);
|
glBindVertexArray(g_ogl.main_vao);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, g_ogl.main_vbos[1]);
|
glBindBuffer(GL_ARRAY_BUFFER, g_ogl.main_vbos[1]);
|
||||||
GLfloat texCoord[] = {
|
GLfloat texCoord[] = {
|
||||||
0.0f, 0.0f,
|
0.0f, 0.0f,
|
||||||
g_ogl.scale_w, 0.0f,
|
g_ogl.scale_w, 0.0f,
|
||||||
g_ogl.scale_w, g_ogl.scale_h,
|
g_ogl.scale_w, g_ogl.scale_h,
|
||||||
0.0f, g_ogl.scale_h,
|
0.0f, g_ogl.scale_h,
|
||||||
};
|
};
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(texCoord), texCoord, GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, sizeof(texCoord), texCoord, GL_STATIC_DRAW);
|
||||||
glVertexAttribPointer(g_ogl.main_tex_coord_attr_loc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
glVertexAttribPointer(g_ogl.main_tex_coord_attr_loc, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
||||||
@ -732,11 +738,15 @@ static void ogl_render()
|
|||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
if (g_ddraw->child_window_exists)
|
if (g_ddraw->child_window_exists)
|
||||||
|
{
|
||||||
glViewport(0, g_ddraw->render.height - g_ddraw->height, g_ddraw->width, g_ddraw->height);
|
glViewport(0, g_ddraw->render.height - g_ddraw->height, g_ddraw->width, g_ddraw->height);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
glViewport(
|
glViewport(
|
||||||
g_ddraw->render.viewport.x, g_ddraw->render.viewport.y,
|
g_ddraw->render.viewport.x, g_ddraw->render.viewport.y,
|
||||||
g_ddraw->render.viewport.width, g_ddraw->render.viewport.height);
|
g_ddraw->render.viewport.width, g_ddraw->render.viewport.height);
|
||||||
|
}
|
||||||
|
|
||||||
// apply filter
|
// apply filter
|
||||||
|
|
||||||
@ -761,10 +771,10 @@ static void ogl_render()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
glBegin(GL_TRIANGLE_FAN);
|
glBegin(GL_TRIANGLE_FAN);
|
||||||
glTexCoord2f(0, 0); glVertex2f(-1, 1);
|
glTexCoord2f(0, 0); glVertex2f(-1, 1);
|
||||||
glTexCoord2f(g_ogl.scale_w, 0); glVertex2f(1, 1);
|
glTexCoord2f(g_ogl.scale_w, 0); glVertex2f( 1, 1);
|
||||||
glTexCoord2f(g_ogl.scale_w, g_ogl.scale_h); glVertex2f(1, -1);
|
glTexCoord2f(g_ogl.scale_w, g_ogl.scale_h); glVertex2f( 1, -1);
|
||||||
glTexCoord2f(0, g_ogl.scale_h); glVertex2f(-1, -1);
|
glTexCoord2f(0, g_ogl.scale_h); glVertex2f(-1, -1);
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user