Commit 76beb5b7 authored by Lionel Ulmer's avatar Lionel Ulmer Committed by Alexandre Julliard

Factorize the 'ortho' code (will be needed later on).

parent 2d7c07c7
......@@ -668,28 +668,10 @@ static void draw_primitive_handle_GL_state(IDirect3DDeviceImpl *This,
glEnable(GL_FOG);
} else if ((vertex_transformed == TRUE) &&
(glThis->transform_state != GL_TRANSFORM_ORTHO)) {
GLfloat height, width;
GLfloat trans_mat[16];
glThis->transform_state = GL_TRANSFORM_ORTHO;
width = glThis->parent.surface->surface_desc.dwWidth;
height = glThis->parent.surface->surface_desc.dwHeight;
/* The X axis is straighforward.. For the Y axis, we need to convert 'D3D' screen coordinates
to OpenGL screen coordinates (ie the upper left corner is not the same).
For Z, the mystery is what should it be mapped to ? Ie should the resulting range be between
-1.0 and 1.0 (as the X and Y coordinates) or between 0.0 and 1.0 ? */
trans_mat[ 0] = 2.0 / width; trans_mat[ 4] = 0.0; trans_mat[ 8] = 0.0; trans_mat[12] = -1.0;
trans_mat[ 1] = 0.0; trans_mat[ 5] = -2.0 / height; trans_mat[ 9] = 0.0; trans_mat[13] = 1.0;
trans_mat[ 2] = 0.0; trans_mat[ 6] = 0.0; trans_mat[10] = 1.0; trans_mat[14] = -1.0;
trans_mat[ 3] = 0.0; trans_mat[ 7] = 0.0; trans_mat[11] = 0.0; trans_mat[15] = 1.0;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(trans_mat);
/* Set our orthographic projection */
glThis->transform_state = GL_TRANSFORM_ORTHO;
d3ddevice_set_ortho(This);
/* Remove also fogging... */
glDisable(GL_FOG);
}
......@@ -1901,6 +1883,30 @@ d3ddevice_bltfast(IDirectDrawSurfaceImpl *This, DWORD dstx,
}
void
d3ddevice_set_ortho(IDirect3DDeviceImpl *This)
{
GLfloat height, width;
GLfloat trans_mat[16];
width = This->surface->surface_desc.dwWidth;
height = This->surface->surface_desc.dwHeight;
/* The X axis is straighforward.. For the Y axis, we need to convert 'D3D' screen coordinates
to OpenGL screen coordinates (ie the upper left corner is not the same).
For Z, the mystery is what should it be mapped to ? Ie should the resulting range be between
-1.0 and 1.0 (as the X and Y coordinates) or between 0.0 and 1.0 ? */
trans_mat[ 0] = 2.0 / width; trans_mat[ 4] = 0.0; trans_mat[ 8] = 0.0; trans_mat[12] = -1.0;
trans_mat[ 1] = 0.0; trans_mat[ 5] = -2.0 / height; trans_mat[ 9] = 0.0; trans_mat[13] = 1.0;
trans_mat[ 2] = 0.0; trans_mat[ 6] = 0.0; trans_mat[10] = 1.0; trans_mat[14] = -1.0;
trans_mat[ 3] = 0.0; trans_mat[ 7] = 0.0; trans_mat[11] = 0.0; trans_mat[15] = 1.0;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(trans_mat);
}
void
d3ddevice_set_matrices(IDirect3DDeviceImpl *This, DWORD matrices,
D3DMATRIX *world_mat, D3DMATRIX *view_mat, D3DMATRIX *proj_mat)
{
......
......@@ -269,31 +269,11 @@ static void execute(IDirect3DExecuteBufferImpl *This,
break;
case D3DVT_TLVERTEX: {
GLdouble height, width;
GLfloat trans_mat[16];
/* First, disable lighting */
/* First, disable lighting and fogging */
glDisable(GL_LIGHTING);
width = lpDevice->surface->surface_desc.dwWidth;
height = lpDevice->surface->surface_desc.dwHeight;
/* The X axis is straighforward.. For the Y axis, we need to convert 'D3D' screen coordinates
to OpenGL screen coordinates (ie the upper left corner is not the same).
For Z, the mystery is what should it be mapped to ? Ie should the resulting range be between
-1.0 and 1.0 (as the X and Y coordinates) or between 0.0 and 1.0 ? */
trans_mat[ 0] = 2.0 / width; trans_mat[ 4] = 0.0; trans_mat[ 8] = 0.0; trans_mat[12] = -1.0;
trans_mat[ 1] = 0.0; trans_mat[ 5] = -2.0 / height; trans_mat[ 9] = 0.0; trans_mat[13] = 1.0;
trans_mat[ 2] = 0.0; trans_mat[ 6] = 0.0; trans_mat[10] = 1.0; trans_mat[14] = -1.0;
trans_mat[ 3] = 0.0; trans_mat[ 7] = 0.0; trans_mat[11] = 0.0; trans_mat[15] = 1.0;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(trans_mat);
/* Remove also fogging... */
glDisable(GL_FOG);
d3ddevice_set_ortho(lpDevice);
} break;
default:
......
......@@ -164,6 +164,9 @@ extern HRESULT d3ddevice_find(IDirect3DImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS
/* Used to upload the texture */
extern HRESULT gltex_upload_texture(IDirectDrawSurfaceImpl *This) ;
/* Used to set-up our orthographic projection */
extern void d3ddevice_set_ortho(IDirect3DDeviceImpl *This) ;
/* Common functions defined in d3dcommon.c */
void set_render_state(IDirect3DDeviceGLImpl* This,
D3DRENDERSTATETYPE dwRenderStateType, DWORD dwRenderState);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment