- do not use the alpha coordinates when ALPHABLEND is disabled
- disable fogging in the XYZRHW case - various other small fixes
This commit is contained in:
parent
62d4f41ee8
commit
c3d89f5566
|
@ -710,6 +710,8 @@ static void draw_primitive_handle_GL_state(IDirect3DDeviceGLImpl *glThis,
|
|||
glMultMatrixf((float *) glThis->world_mat);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadMatrixf((float *) glThis->proj_mat);
|
||||
|
||||
if (glThis->render_state.fog_on == TRUE) glEnable(GL_FOG);
|
||||
} else if ((vertex_transformed == TRUE) &&
|
||||
((glThis->last_vertices_transformed == FALSE) ||
|
||||
(glThis->matrices_changed == TRUE))) {
|
||||
|
@ -732,6 +734,9 @@ static void draw_primitive_handle_GL_state(IDirect3DDeviceGLImpl *glThis,
|
|||
glLoadIdentity();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadMatrixf(trans_mat);
|
||||
|
||||
/* Remove also fogging... */
|
||||
glDisable(GL_FOG);
|
||||
}
|
||||
glThis->matrices_changed = FALSE;
|
||||
|
||||
|
@ -936,10 +941,15 @@ inline static void handle_diffuse(DWORD *color) {
|
|||
(*color >> 24) & 0xFF);
|
||||
}
|
||||
inline static void handle_diffuse_and_specular(DWORD *color_d, DWORD *color_s) {
|
||||
glColor4ub((*color_d >> 16) & 0xFF,
|
||||
(*color_d >> 8) & 0xFF,
|
||||
(*color_d >> 0) & 0xFF,
|
||||
(*color_d >> 24) & 0xFF);
|
||||
handle_diffuse(color_d);
|
||||
}
|
||||
inline static void handle_diffuse_no_alpha(DWORD *color) {
|
||||
glColor3ub((*color >> 16) & 0xFF,
|
||||
(*color >> 8) & 0xFF,
|
||||
(*color >> 0) & 0xFF);
|
||||
}
|
||||
inline static void handle_diffuse_and_specular_no_alpha(DWORD *color_d, DWORD *color_s) {
|
||||
handle_diffuse_no_alpha(color_d);
|
||||
}
|
||||
inline static void handle_texture(D3DVALUE *coords) {
|
||||
glTexCoord2fv(coords);
|
||||
|
@ -1005,7 +1015,10 @@ static void draw_primitive_strided_7(IDirect3DDeviceImpl *This,
|
|||
D3DVALUE *position =
|
||||
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);
|
||||
|
||||
handle_diffuse_and_specular(color_d, color_s);
|
||||
if (glThis->render_state.alpha_blend_enable == TRUE)
|
||||
handle_diffuse_and_specular(color_d, color_s);
|
||||
else
|
||||
handle_diffuse_and_specular_no_alpha(color_d, color_s);
|
||||
handle_texture(tex_coord);
|
||||
handle_xyzrhw(position);
|
||||
|
||||
|
@ -1040,7 +1053,10 @@ static void draw_primitive_strided_7(IDirect3DDeviceImpl *This,
|
|||
(DWORD *) (((char *) lpD3DDrawPrimStrideData->diffuse.lpvData) + i * lpD3DDrawPrimStrideData->diffuse.dwStride);
|
||||
DWORD *color_s =
|
||||
(DWORD *) (((char *) lpD3DDrawPrimStrideData->specular.lpvData) + i * lpD3DDrawPrimStrideData->specular.dwStride);
|
||||
handle_diffuse_and_specular(color_d, color_s);
|
||||
if (glThis->render_state.alpha_blend_enable == TRUE)
|
||||
handle_diffuse_and_specular(color_d, color_s);
|
||||
else
|
||||
handle_diffuse_and_specular_no_alpha(color_d, color_s);
|
||||
} else {
|
||||
if (d3dvtVertexType & D3DFVF_SPECULAR) {
|
||||
DWORD *color_s =
|
||||
|
@ -1049,7 +1065,10 @@ static void draw_primitive_strided_7(IDirect3DDeviceImpl *This,
|
|||
} else if (d3dvtVertexType & D3DFVF_DIFFUSE) {
|
||||
DWORD *color_d =
|
||||
(DWORD *) (((char *) lpD3DDrawPrimStrideData->diffuse.lpvData) + i * lpD3DDrawPrimStrideData->diffuse.dwStride);
|
||||
handle_diffuse(color_d);
|
||||
if (glThis->render_state.alpha_blend_enable == TRUE)
|
||||
handle_diffuse(color_d);
|
||||
else
|
||||
handle_diffuse_no_alpha(color_d);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1866,6 +1885,8 @@ d3ddevice_create(IDirect3DDeviceImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfa
|
|||
gl_object->render_state.min = GL_NEAREST;
|
||||
gl_object->render_state.alpha_ref = 0.0; /* No actual idea about the real default value... */
|
||||
gl_object->render_state.alpha_func = GL_ALWAYS; /* Here either but it seems logical */
|
||||
gl_object->render_state.alpha_blend_enable = FALSE;
|
||||
gl_object->render_state.fog_on = FALSE;
|
||||
|
||||
/* Allocate memory for the matrices */
|
||||
gl_object->world_mat = (D3DMATRIX *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 16 * sizeof(float));
|
||||
|
@ -1884,7 +1905,6 @@ d3ddevice_create(IDirect3DDeviceImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfa
|
|||
ENTER_GL();
|
||||
TRACE(" current context set\n");
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glColor3f(1.0, 1.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
glDrawBuffer(buffer);
|
||||
glReadBuffer(buffer);
|
||||
|
|
|
@ -137,7 +137,7 @@ HRESULT WINAPI gltex_setcolorkey_cb(IDirectDrawSurfaceImpl *texture, DWORD dwFla
|
|||
return DD_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
static HRESULT
|
||||
gltex_upload_texture(IDirectDrawSurfaceImpl *This, BOOLEAN init_upload) {
|
||||
IDirect3DTextureGLImpl *glThis = (IDirect3DTextureGLImpl *) This->tex_private;
|
||||
GLuint current_texture;
|
||||
|
@ -148,7 +148,7 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *This, BOOLEAN init_upload) {
|
|||
GLsizei width, GLenum format, GLenum type, const GLvoid *table) = NULL;
|
||||
BOOL upload_done = FALSE;
|
||||
BOOL error = FALSE;
|
||||
GLenum format, pixel_format;
|
||||
GLenum format = GL_RGBA, pixel_format = GL_UNSIGNED_BYTE; /* This is only to prevent warnings.. */
|
||||
VOID *surface = NULL;
|
||||
|
||||
DDSURFACEDESC *src_d = (DDSURFACEDESC *)&(This->surface_desc);
|
||||
|
@ -179,7 +179,7 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *This, BOOLEAN init_upload) {
|
|||
if (pal == NULL) {
|
||||
ERR("Palettized texture Loading with a NULL palette !\n");
|
||||
glBindTexture(GL_TEXTURE_2D, current_texture);
|
||||
return;
|
||||
return D3DERR_INVALIDPALETTE;
|
||||
}
|
||||
/* Get the surface's palette */
|
||||
for (i = 0; i < 256; i++) {
|
||||
|
@ -323,6 +323,7 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *This, BOOLEAN init_upload) {
|
|||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, current_texture);
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
HRESULT WINAPI
|
||||
|
@ -462,6 +463,7 @@ GL_IDirect3DTextureImpl_2_1T_Load(LPDIRECT3DTEXTURE2 iface,
|
|||
IDirectDrawSurfaceImpl *lpD3DTextureImpl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirect3DTexture2, lpD3DTexture2);
|
||||
DWORD mem_used;
|
||||
DDSURFACEDESC *src_d, *dst_d;
|
||||
HRESULT ret_value = D3D_OK;
|
||||
|
||||
TRACE("(%p/%p)->(%p)\n", This, iface, lpD3DTexture2);
|
||||
|
||||
|
@ -521,14 +523,14 @@ GL_IDirect3DTextureImpl_2_1T_Load(LPDIRECT3DTEXTURE2 iface,
|
|||
/* Now, load the texture */
|
||||
/* d3dd->set_context(d3dd); We need to set the context somehow.... */
|
||||
|
||||
gltex_upload_texture(This, glThis->first_unlock);
|
||||
ret_value = gltex_upload_texture(This, glThis->first_unlock);
|
||||
glThis->first_unlock = FALSE;
|
||||
|
||||
LEAVE_GL();
|
||||
}
|
||||
}
|
||||
|
||||
return D3D_OK;
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
HRESULT WINAPI
|
||||
|
@ -553,7 +555,7 @@ ULONG WINAPI
|
|||
Thunk_IDirect3DTextureImpl_2_Release(LPDIRECT3DTEXTURE2 iface)
|
||||
{
|
||||
TRACE("(%p)->() thunking to IDirectDrawSurface7 interface.\n", iface);
|
||||
return IDirectDrawSurface7_AddRef(COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirect3DTexture2, IDirectDrawSurface7, iface));
|
||||
return IDirectDrawSurface7_Release(COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirect3DTexture2, IDirectDrawSurface7, iface));
|
||||
}
|
||||
|
||||
HRESULT WINAPI
|
||||
|
@ -578,7 +580,7 @@ ULONG WINAPI
|
|||
Thunk_IDirect3DTextureImpl_1_Release(LPDIRECT3DTEXTURE iface)
|
||||
{
|
||||
TRACE("(%p)->() thunking to IDirectDrawSurface7 interface.\n", iface);
|
||||
return IDirectDrawSurface7_AddRef(COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirect3DTexture, IDirectDrawSurface7, iface));
|
||||
return IDirectDrawSurface7_Release(COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirect3DTexture, IDirectDrawSurface7, iface));
|
||||
}
|
||||
|
||||
HRESULT WINAPI
|
||||
|
|
|
@ -577,7 +577,10 @@ void DDRAW_dump_surface_to_disk(IDirectDrawSurfaceImpl *surface, FILE *f)
|
|||
{
|
||||
int i;
|
||||
|
||||
DDRAW_dump_surface_desc(&(surface->surface_desc));
|
||||
if (TRACE_ON(ddraw)) {
|
||||
DPRINTF("Dumping surface : \n");
|
||||
DDRAW_dump_surface_desc(&(surface->surface_desc));
|
||||
}
|
||||
|
||||
fprintf(f, "P6\n%ld %ld\n255\n", surface->surface_desc.dwWidth, surface->surface_desc.dwHeight);
|
||||
|
||||
|
|
|
@ -227,8 +227,8 @@ void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,
|
|||
switch ((D3DTEXTUREBLEND) dwRenderState) {
|
||||
case D3DTBLEND_MODULATE:
|
||||
case D3DTBLEND_MODULATEALPHA:
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
break;
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
break;
|
||||
default:
|
||||
ERR("Unhandled texture environment %ld !\n",dwRenderState);
|
||||
}
|
||||
|
@ -239,13 +239,16 @@ void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,
|
|||
case D3DCULL_NONE:
|
||||
glDisable(GL_CULL_FACE);
|
||||
break;
|
||||
/* Not sure about these... The DirectX doc is, well, pretty unclear :-) */
|
||||
case D3DCULL_CW:
|
||||
glEnable(GL_CULL_FACE);
|
||||
glFrontFace(GL_CW);
|
||||
glCullFace(GL_BACK);
|
||||
break;
|
||||
case D3DCULL_CCW:
|
||||
glEnable(GL_CULL_FACE);
|
||||
glFrontFace(GL_CCW);
|
||||
glCullFace(GL_BACK);
|
||||
break;
|
||||
default:
|
||||
ERR("Unhandled cull mode %ld !\n",dwRenderState);
|
||||
|
@ -274,17 +277,23 @@ void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,
|
|||
break;
|
||||
|
||||
case D3DRENDERSTATE_ALPHABLENDENABLE: /* 27 */
|
||||
if (dwRenderState)
|
||||
if (dwRenderState) {
|
||||
glEnable(GL_BLEND);
|
||||
else
|
||||
rs->alpha_blend_enable = TRUE;
|
||||
} else {
|
||||
glDisable(GL_BLEND);
|
||||
rs->alpha_blend_enable = FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case D3DRENDERSTATE_FOGENABLE: /* 28 */
|
||||
if (dwRenderState)
|
||||
if (dwRenderState) {
|
||||
glEnable(GL_FOG);
|
||||
else
|
||||
rs->fog_on = TRUE;
|
||||
} else {
|
||||
glDisable(GL_FOG);
|
||||
rs->fog_on = FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case D3DRENDERSTATE_SPECULARENABLE: /* 29 */
|
||||
|
|
|
@ -67,6 +67,10 @@ typedef struct render_state {
|
|||
/* This is needed for the Alpha stuff */
|
||||
GLenum alpha_func;
|
||||
GLclampf alpha_ref;
|
||||
BOOLEAN alpha_blend_enable;
|
||||
|
||||
/* This is needed to re-enable fogging when XYZRHW and XYZ primitives are mixed */
|
||||
BOOLEAN fog_on;
|
||||
} RenderState;
|
||||
|
||||
/* Common functions defined in d3dcommon.c */
|
||||
|
|
Loading…
Reference in New Issue