- fix (stupid) regressions introduced by last series of patch

- 24 bpp handling for lock / unlock code
- some better checks for AlphaPixel value
- better TRACEing to better catch threading problems
This commit is contained in:
Lionel Ulmer 2003-06-04 23:36:48 +00:00 committed by Alexandre Julliard
parent fc58c2a933
commit ed88304868
4 changed files with 246 additions and 175 deletions

View File

@ -126,8 +126,8 @@ static void set_context(IDirect3DDeviceImpl* This)
{
IDirect3DDeviceGLImpl* glThis = (IDirect3DDeviceGLImpl*) This;
ENTER_GL();
TRACE("glxMakeCurrent %p, %ld, %p\n",glThis->display,glThis->drawable, glThis->gl_context);
ENTER_GL();
if (glXMakeCurrent(glThis->display, glThis->drawable, glThis->gl_context) == False) {
ERR("Error in setting current context (context %p drawable %ld)!\n",
glThis->gl_context, glThis->drawable);
@ -1093,6 +1093,11 @@ static void draw_primitive_strided(IDirect3DDeviceImpl *This,
IDirect3DDeviceGLImpl* glThis = (IDirect3DDeviceGLImpl*) This;
int num_active_stages = 0;
/* I put the trace before the various locks... So as to better understand where locks occur :-) */
if (TRACE_ON(ddraw)) {
TRACE(" Vertex format : "); dump_flexible_vertex(d3dvtVertexType);
}
/* This is to prevent 'thread contention' between a thread locking the device and another
doing 3D display on it... */
EnterCriticalSection(&(This->crit));
@ -1104,10 +1109,6 @@ static void draw_primitive_strided(IDirect3DDeviceImpl *This,
glThis->state = SURFACE_GL;
if (TRACE_ON(ddraw)) {
TRACE(" Vertex format : "); dump_flexible_vertex(d3dvtVertexType);
}
/* Just a hack for now.. Will have to find better algorithm :-/ */
if ((d3dvtVertexType & D3DFVF_POSITION_MASK) != D3DFVF_XYZ) {
vertex_lighted = TRUE;
@ -1925,6 +1926,7 @@ draw_primitive_handle_textures(IDirect3DDeviceImpl *This)
if (glThis->current_bound_texture[stage] == NULL) {
if (This->state_block.texture_stage_state[stage][D3DTSS_COLOROP - 1] != D3DTOP_DISABLE) {
TRACE(" enabling 2D texturing and");
glEnable(GL_TEXTURE_2D);
}
}
@ -1933,6 +1935,13 @@ draw_primitive_handle_textures(IDirect3DDeviceImpl *This)
}
glThis->current_bound_texture[stage] = This->current_texture[stage];
} else {
if (glThis->current_bound_texture[stage] == NULL) {
TRACE(" displaying without texturing activated for stage %ld.\n", stage);
} else {
TRACE(" using already bound texture id %d for stage %ld.\n",
((IDirect3DTextureGLImpl *) (glThis->current_bound_texture[stage])->tex_private)->tex_name, stage);
}
}
/* If no texure valid for this stage, go out of the loop */
@ -2500,6 +2509,8 @@ d3ddevice_set_ortho(IDirect3DDeviceImpl *This)
{
GLfloat height, width;
GLfloat trans_mat[16];
TRACE("(%p)\n", This);
width = This->surface->surface_desc.dwWidth;
height = This->surface->surface_desc.dwHeight;
@ -2534,6 +2545,8 @@ void
d3ddevice_set_matrices(IDirect3DDeviceImpl *This, DWORD matrices,
D3DMATRIX *world_mat, D3DMATRIX *view_mat, D3DMATRIX *proj_mat)
{
TRACE("(%p,%08lx,%p,%p,%p)\n", This, matrices, world_mat, view_mat, proj_mat);
ENTER_GL();
if ((matrices & (VIEWMAT_CHANGED|WORLDMAT_CHANGED)) != 0) {
glMatrixMode(GL_MODELVIEW);
@ -2645,7 +2658,10 @@ d3ddevice_matrices_updated(IDirect3DDeviceImpl *This, DWORD matrices)
{
IDirect3DDeviceGLImpl *glThis = (IDirect3DDeviceGLImpl *) This;
DWORD tex_mat, tex_stage;
if ((matrices & (VIEWMAT_CHANGED|WORLDMAT_CHANGED|PROJMAT_CHANGED)) != 0) {
TRACE("(%p,%08lx)\n", This, matrices);
if (matrices & (VIEWMAT_CHANGED|WORLDMAT_CHANGED|PROJMAT_CHANGED)) {
if (glThis->transform_state == GL_TRANSFORM_NORMAL) {
/* This will force an update of the transform state at the next drawing. */
glThis->transform_state = GL_TRANSFORM_NONE;
@ -2722,24 +2738,34 @@ static void d3ddevice_lock_update(IDirectDrawSurfaceImpl* This, LPCRECT pRect, D
/* Note that here we cannot do 'optmizations' about the WriteOnly flag... Indeed, a game
may only write to the device... But when we will blit it back to the screen, we need
also to blit correctly the parts the application did not overwrite... */
if ((This->surface_desc.u4.ddpfPixelFormat.u1.dwRGBBitCount == 16) &&
(This->surface_desc.u4.ddpfPixelFormat.u2.dwRBitMask == 0xF800) &&
(This->surface_desc.u4.ddpfPixelFormat.u3.dwGBitMask == 0x07E0) &&
(This->surface_desc.u4.ddpfPixelFormat.u4.dwBBitMask == 0x001F) &&
(This->surface_desc.u4.ddpfPixelFormat.u5.dwRGBAlphaBitMask == 0x0000)) {
buffer_type = GL_UNSIGNED_SHORT_5_6_5;
buffer_color = GL_RGB;
} else if ((This->surface_desc.u4.ddpfPixelFormat.u1.dwRGBBitCount == 32) &&
(This->surface_desc.u4.ddpfPixelFormat.u2.dwRBitMask == 0x00FF0000) &&
(This->surface_desc.u4.ddpfPixelFormat.u3.dwGBitMask == 0x0000FF00) &&
(This->surface_desc.u4.ddpfPixelFormat.u4.dwBBitMask == 0x000000FF) &&
(This->surface_desc.u4.ddpfPixelFormat.u5.dwRGBAlphaBitMask == 0x00000000)) {
buffer_type = GL_UNSIGNED_BYTE;
buffer_color = GL_BGRA;
glPixelStorei(GL_PACK_SWAP_BYTES, TRUE);
if (((This->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_RGB) != 0) &&
(((This->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_ALPHAPIXELS) == 0) ||
(This->surface_desc.u4.ddpfPixelFormat.u5.dwRGBAlphaBitMask == 0x00000000))) {
if ((This->surface_desc.u4.ddpfPixelFormat.u1.dwRGBBitCount == 16) &&
(This->surface_desc.u4.ddpfPixelFormat.u2.dwRBitMask == 0xF800) &&
(This->surface_desc.u4.ddpfPixelFormat.u3.dwGBitMask == 0x07E0) &&
(This->surface_desc.u4.ddpfPixelFormat.u4.dwBBitMask == 0x001F)) {
buffer_type = GL_UNSIGNED_SHORT_5_6_5;
buffer_color = GL_RGB;
} else if ((This->surface_desc.u4.ddpfPixelFormat.u1.dwRGBBitCount == 24) &&
(This->surface_desc.u4.ddpfPixelFormat.u2.dwRBitMask == 0xFF0000) &&
(This->surface_desc.u4.ddpfPixelFormat.u3.dwGBitMask == 0x00FF00) &&
(This->surface_desc.u4.ddpfPixelFormat.u4.dwBBitMask == 0x0000FF)) {
buffer_type = GL_UNSIGNED_BYTE;
buffer_color = GL_RGB;
} else if ((This->surface_desc.u4.ddpfPixelFormat.u1.dwRGBBitCount == 32) &&
(This->surface_desc.u4.ddpfPixelFormat.u2.dwRBitMask == 0x00FF0000) &&
(This->surface_desc.u4.ddpfPixelFormat.u3.dwGBitMask == 0x0000FF00) &&
(This->surface_desc.u4.ddpfPixelFormat.u4.dwBBitMask == 0x000000FF)) {
buffer_type = GL_UNSIGNED_INT_8_8_8_8_REV;
buffer_color = GL_BGRA;
} else {
ERR(" unsupported pixel format at device locking.\n");
return;
}
} else {
ERR(" unsupported pixel format at device locking.\n");
ERR(" unsupported pixel format at device locking - alpha on frame buffer.\n");
return;
}
@ -2774,8 +2800,6 @@ static void d3ddevice_lock_update(IDirectDrawSurfaceImpl* This, LPCRECT pRect, D
dst += This->surface_desc.u1.lPitch;
}
glPixelStorei(GL_PACK_SWAP_BYTES, FALSE);
if (is_front)
gl_d3d_dev->front_state = SURFACE_MEMORY;
else
@ -2834,7 +2858,7 @@ static void d3ddevice_flush_to_frame_buffer(IDirect3DDeviceImpl *d3d_dev, LPCREC
if (upload_surface_to_tex_memory_init(surf, 0, &gl_d3d_dev->current_internal_format,
initial, FALSE, UNLOCK_TEX_SIZE, UNLOCK_TEX_SIZE) != D3D_OK) {
initial, FALSE, UNLOCK_TEX_SIZE, UNLOCK_TEX_SIZE) != DD_OK) {
ERR(" unsupported pixel format at frame buffer flush.\n");
return;
}
@ -2948,6 +2972,9 @@ static void d3ddevice_unlock_update(IDirectDrawSurfaceImpl* This, LPCRECT pRect)
if ((This->lastlocktype & DDLOCK_READONLY) == 0) {
if (is_front == TRUE) {
GLenum prev_draw;
TRACE(" flushing front buffer immediatly on screen.\n");
ENTER_GL();
glGetIntegerv(GL_DRAW_BUFFER, &prev_draw);
glDrawBuffer(GL_FRONT);
@ -3008,10 +3035,12 @@ d3ddevice_create(IDirect3DDeviceImpl **obj, IDirectDrawImpl *d3d, IDirectDrawSur
object->matrices_updated = d3ddevice_matrices_updated;
object->flush_to_framebuffer = d3ddevice_flush_to_frame_buffer;
InitializeCriticalSection(&(object->crit));
TRACE(" creating OpenGL device for surface = %p, d3d = %p\n", surface, d3d);
InitializeCriticalSection(&(object->crit));
TRACE(" device critical section : %p\n", &(object->crit));
device_context = GetDC(surface->ddraw_owner->window);
gl_object->display = get_display(device_context);
gl_object->drawable = get_drawable(device_context);

View File

@ -154,6 +154,9 @@ static void update(IDirect3DLightImpl* This) {
static void activate(IDirect3DLightImpl* This) {
IDirect3DLightGLImpl *glThis = (IDirect3DLightGLImpl *) This;
TRACE("(%p)\n", This);
ENTER_GL();
update(This);
/* If was not active, activate it */
@ -166,6 +169,9 @@ static void activate(IDirect3DLightImpl* This) {
static void desactivate(IDirect3DLightImpl* This) {
IDirect3DLightGLImpl *glThis = (IDirect3DLightGLImpl *) This;
TRACE("(%p)\n", This);
ENTER_GL();
/* If was not active, activate it */
if ((glThis->parent.light.dwFlags & D3DLIGHT_ACTIVE) != 0) {

View File

@ -266,10 +266,13 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *surf_ptr, IDirect3DDeviceImpl *d3dd
snoop_texture(surf_ptr);
if (upload_surface_to_tex_memory_init(surf_ptr, surf_ptr->mipmap_level, &(gl_surf_ptr->current_internal_format),
gl_surf_ptr->initial_upload_done == FALSE, TRUE, 0, 0) == D3D_OK) {
gl_surf_ptr->initial_upload_done == FALSE, TRUE, 0, 0) == DD_OK) {
upload_surface_to_tex_memory(NULL, 0, 0, &(gl_surf_ptr->surface_ptr));
upload_surface_to_tex_memory_release();
gl_surf_ptr->dirty_flag = SURFACE_MEMORY;
} else {
ERR("Problem for upload of texture %d (level = %d / initial done = %d).\n",
gl_surf_ptr->tex_name, surf_ptr->mipmap_level, gl_surf_ptr->initial_upload_done);
}
}
@ -302,6 +305,8 @@ gltex_setcolorkey_cb(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDDCOLORKEY c
if (glThis->dirty_flag == SURFACE_GL) {
GLuint cur_tex;
TRACE(" flushing GL texture back to memory.\n");
ENTER_GL();
glGetIntegerv(GL_TEXTURE_BINDING_2D, &cur_tex);
@ -368,6 +373,10 @@ gltex_bltfast(IDirectDrawSurfaceImpl *surf_ptr, DWORD dstx,
return DDERR_INVALIDPARAMS;
}
if ((width == 0) || (height == 0)) {
return DD_OK;
}
TRACE(" direct frame buffer => texture BltFast override.\n");
ENTER_GL();
@ -380,24 +389,29 @@ gltex_bltfast(IDirectDrawSurfaceImpl *surf_ptr, DWORD dstx,
(width == surf_ptr->surface_desc.dwWidth) && (height == surf_ptr->surface_desc.dwHeight))) {
/* If not 'full size' and the surface is dirty, first flush it to GL before doing the copy. */
if (upload_surface_to_tex_memory_init(surf_ptr, surf_ptr->mipmap_level, &(gl_surf_ptr->current_internal_format),
gl_surf_ptr->initial_upload_done == FALSE, TRUE, 0, 0) != D3D_OK) {
gl_surf_ptr->initial_upload_done == FALSE, TRUE, 0, 0) == DD_OK) {
upload_surface_to_tex_memory(NULL, 0, 0, &(gl_surf_ptr->surface_ptr));
upload_surface_to_tex_memory_release();
gl_surf_ptr->dirty_flag = SURFACE_MEMORY;
} else {
glBindTexture(GL_TEXTURE_2D, cur_tex);
LEAVE_GL();
ERR("Error at texture upload !\n");
return DDERR_INVALIDPARAMS;
}
}
/* This is a hack and would need some clean-up :-) */
if (gl_surf_ptr->initial_upload_done == FALSE) {
gl_surf_ptr->dirty_flag = SURFACE_MEMORY_DIRTY;
if (upload_surface_to_tex_memory_init(surf_ptr, surf_ptr->mipmap_level, &(gl_surf_ptr->current_internal_format),
gl_surf_ptr->initial_upload_done == FALSE, TRUE, 0, 0) != D3D_OK) {
TRUE, TRUE, 0, 0) == DD_OK) {
upload_surface_to_tex_memory(NULL, 0, 0, &(gl_surf_ptr->surface_ptr));
upload_surface_to_tex_memory_release();
gl_surf_ptr->dirty_flag = SURFACE_MEMORY;
} else {
glBindTexture(GL_TEXTURE_2D, cur_tex);
LEAVE_GL();
ERR("Error at texture upload (initial case) !\n");
return DDERR_INVALIDPARAMS;
}
}
@ -490,6 +504,8 @@ static void gltex_set_palette(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteIm
if (glThis->dirty_flag == SURFACE_GL) {
GLuint cur_tex;
TRACE(" flushing GL texture back to memory.\n");
ENTER_GL();
glGetIntegerv(GL_TEXTURE_BINDING_2D, &cur_tex);
glBindTexture(GL_TEXTURE_2D, glThis->tex_name);
@ -836,18 +852,19 @@ HRESULT d3dtexture_create(IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *surf, BO
to save those... */
surf->aux_blt = gltex_blt;
surf->aux_bltfast = gltex_bltfast;
TRACE(" GL texture created for surface %p (private data at %p)\n", surf, private);
ENTER_GL();
if (surf->mipmap_level == 0) {
glGenTextures(1, &(private->tex_name));
if (private->tex_name == 0) ERR("Error at creation of OpenGL texture ID !\n");
TRACE(" GL texture created for surface %p (private data at %p and GL id %d).\n", surf, private, private->tex_name);
TRACE(" GL texture id is : %d.\n", private->tex_name);
private->__global_dirty_flag = (at_creation == FALSE ? SURFACE_MEMORY_DIRTY : SURFACE_MEMORY);
private->global_dirty_flag = &(private->__global_dirty_flag);
} else {
private->tex_name = ((IDirect3DTextureGLImpl *) (main->tex_private))->tex_name;
TRACE(" GL texture created for surface %p (private data at %p and GL id reusing id %d from surface %p (%p)).\n",
surf, private, private->tex_name, main, main->tex_private);
TRACE(" GL texture id reusing id %d from surface %p (private at %p)).\n", private->tex_name, main, main->tex_private);
private->global_dirty_flag = &(((IDirect3DTextureGLImpl *) (main->tex_private))->__global_dirty_flag);
}
LEAVE_GL();

View File

@ -88,8 +88,7 @@ void set_render_state(IDirect3DDeviceImpl* This,
DWORD dwRenderState = lpStateBlock->render_state[dwRenderStateType - 1];
IDirect3DDeviceGLImpl *glThis = (IDirect3DDeviceGLImpl *) This;
if (TRACE_ON(ddraw))
TRACE("%s = %08lx\n", _get_renderstate(dwRenderStateType), dwRenderState);
TRACE("%s = %08lx\n", _get_renderstate(dwRenderStateType), dwRenderState);
/* First, all the stipple patterns */
if ((dwRenderStateType >= D3DRENDERSTATE_STIPPLEPATTERN00) &&
@ -623,169 +622,189 @@ HRESULT upload_surface_to_tex_memory_init(IDirectDrawSurfaceImpl *surf_ptr, GLui
RGB Textures
************ */
if (src_pf->u1.dwRGBBitCount == 8) {
if ((src_pf->u2.dwRBitMask == 0xE0) &&
(src_pf->u3.dwGBitMask == 0x1C) &&
(src_pf->u4.dwBBitMask == 0x03)) {
/* **********************
GL_UNSIGNED_BYTE_3_3_2
********************** */
if (colorkey_active) {
/* This texture format will never be used.. So do not care about color keying
up until the point in time it will be needed :-) */
FIXME(" ColorKeying not supported in the RGB 332 format !");
}
current_format = GL_RGB;
internal_format = GL_RGB;
current_pixel_format = GL_UNSIGNED_BYTE_3_3_2;
convert_type = NO_CONVERSION;
} else {
if ((src_pf->dwFlags & DDPF_ALPHAPIXELS) &&
(src_pf->u5.dwRGBAlphaBitMask != 0x00)) {
error = TRUE;
} else {
if ((src_pf->u2.dwRBitMask == 0xE0) &&
(src_pf->u3.dwGBitMask == 0x1C) &&
(src_pf->u4.dwBBitMask == 0x03)) {
/* **********************
GL_UNSIGNED_BYTE_3_3_2
********************** */
if (colorkey_active) {
/* This texture format will never be used.. So do not care about color keying
up until the point in time it will be needed :-) */
FIXME(" ColorKeying not supported in the RGB 332 format !");
}
current_format = GL_RGB;
internal_format = GL_RGB;
current_pixel_format = GL_UNSIGNED_BYTE_3_3_2;
convert_type = NO_CONVERSION;
} else {
error = TRUE;
}
}
} else if (src_pf->u1.dwRGBBitCount == 16) {
if ((src_pf->u2.dwRBitMask == 0xF800) &&
(src_pf->u3.dwGBitMask == 0x07E0) &&
(src_pf->u4.dwBBitMask == 0x001F) &&
(src_pf->u5.dwRGBAlphaBitMask == 0x0000)) {
if (colorkey_active) {
convert_type = CONVERT_CK_565;
if ((src_pf->dwFlags & DDPF_ALPHAPIXELS) &&
(src_pf->u5.dwRGBAlphaBitMask != 0x0000)) {
if ((src_pf->u2.dwRBitMask == 0xF800) &&
(src_pf->u3.dwGBitMask == 0x07C0) &&
(src_pf->u4.dwBBitMask == 0x003E) &&
(src_pf->u5.dwRGBAlphaBitMask == 0x0001)) {
current_format = GL_RGBA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_SHORT_5_5_5_1;
} else {
convert_type = NO_CONVERSION;
current_format = GL_RGB;
internal_format = GL_RGB;
current_pixel_format = GL_UNSIGNED_SHORT_5_6_5;
}
} else if ((src_pf->u2.dwRBitMask == 0xF800) &&
(src_pf->u3.dwGBitMask == 0x07C0) &&
(src_pf->u4.dwBBitMask == 0x003E) &&
(src_pf->u5.dwRGBAlphaBitMask == 0x0001)) {
current_format = GL_RGBA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_SHORT_5_5_5_1;
if (colorkey_active) {
convert_type = CONVERT_CK_5551;
} else {
convert_type = NO_CONVERSION;
}
} else if ((src_pf->u2.dwRBitMask == 0xF000) &&
(src_pf->u3.dwGBitMask == 0x0F00) &&
(src_pf->u4.dwBBitMask == 0x00F0) &&
(src_pf->u5.dwRGBAlphaBitMask == 0x000F)) {
current_format = GL_RGBA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_SHORT_4_4_4_4;
if (colorkey_active) {
convert_type = CONVERT_CK_4444;
} else {
convert_type = NO_CONVERSION;
}
} else if ((src_pf->u2.dwRBitMask == 0x0F00) &&
(src_pf->u3.dwGBitMask == 0x00F0) &&
(src_pf->u4.dwBBitMask == 0x000F) &&
(src_pf->u5.dwRGBAlphaBitMask == 0xF000)) {
if (colorkey_active) {
convert_type = CONVERT_CK_4444_ARGB;
if (colorkey_active) {
convert_type = CONVERT_CK_5551;
} else {
convert_type = NO_CONVERSION;
}
} else if ((src_pf->u2.dwRBitMask == 0xF000) &&
(src_pf->u3.dwGBitMask == 0x0F00) &&
(src_pf->u4.dwBBitMask == 0x00F0) &&
(src_pf->u5.dwRGBAlphaBitMask == 0x000F)) {
current_format = GL_RGBA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_SHORT_4_4_4_4;
if (colorkey_active) {
convert_type = CONVERT_CK_4444;
} else {
convert_type = NO_CONVERSION;
}
} else if ((src_pf->u2.dwRBitMask == 0x0F00) &&
(src_pf->u3.dwGBitMask == 0x00F0) &&
(src_pf->u4.dwBBitMask == 0x000F) &&
(src_pf->u5.dwRGBAlphaBitMask == 0xF000)) {
if (colorkey_active) {
convert_type = CONVERT_CK_4444_ARGB;
current_format = GL_RGBA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_SHORT_4_4_4_4;
} else {
convert_type = NO_CONVERSION;
current_format = GL_BGRA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_SHORT_4_4_4_4_REV;
}
} else if ((src_pf->u2.dwRBitMask == 0x7C00) &&
(src_pf->u3.dwGBitMask == 0x03E0) &&
(src_pf->u4.dwBBitMask == 0x001F) &&
(src_pf->u5.dwRGBAlphaBitMask == 0x8000)) {
if (colorkey_active) {
convert_type = CONVERT_CK_1555;
current_format = GL_RGBA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_SHORT_5_5_5_1;
} else {
convert_type = NO_CONVERSION;
current_format = GL_BGRA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_SHORT_1_5_5_5_REV;
}
} else {
convert_type = NO_CONVERSION;
current_format = GL_BGRA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_SHORT_4_4_4_4_REV;
error = TRUE;
}
} else if ((src_pf->u2.dwRBitMask == 0x7C00) &&
(src_pf->u3.dwGBitMask == 0x03E0) &&
(src_pf->u4.dwBBitMask == 0x001F) &&
(src_pf->u5.dwRGBAlphaBitMask == 0x8000)) {
if (colorkey_active) {
convert_type = CONVERT_CK_1555;
} else {
if ((src_pf->u2.dwRBitMask == 0xF800) &&
(src_pf->u3.dwGBitMask == 0x07E0) &&
(src_pf->u4.dwBBitMask == 0x001F)) {
if (colorkey_active) {
convert_type = CONVERT_CK_565;
current_format = GL_RGBA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_SHORT_5_5_5_1;
} else {
convert_type = NO_CONVERSION;
current_format = GL_RGB;
internal_format = GL_RGB;
current_pixel_format = GL_UNSIGNED_SHORT_5_6_5;
}
} else if ((src_pf->u2.dwRBitMask == 0x7C00) &&
(src_pf->u3.dwGBitMask == 0x03E0) &&
(src_pf->u4.dwBBitMask == 0x001F)) {
convert_type = CONVERT_555;
current_format = GL_RGBA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_SHORT_5_5_5_1;
} else {
convert_type = NO_CONVERSION;
current_format = GL_BGRA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_SHORT_1_5_5_5_REV;
error = TRUE;
}
} else if ((src_pf->u2.dwRBitMask == 0x7C00) &&
(src_pf->u3.dwGBitMask == 0x03E0) &&
(src_pf->u4.dwBBitMask == 0x001F) &&
(src_pf->u5.dwRGBAlphaBitMask == 0x0000)) {
convert_type = CONVERT_555;
current_format = GL_RGBA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_SHORT_5_5_5_1;
} else {
error = TRUE;
}
} else if (src_pf->u1.dwRGBBitCount == 24) {
if ((src_pf->u2.dwRBitMask == 0x00FF0000) &&
(src_pf->u3.dwGBitMask == 0x0000FF00) &&
(src_pf->u4.dwBBitMask == 0x000000FF) &&
(src_pf->u5.dwRGBAlphaBitMask == 0x00000000)) {
if (colorkey_active) {
convert_type = CONVERT_CK_RGB24;
current_format = GL_RGBA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_INT_8_8_8_8;
} else {
convert_type = NO_CONVERSION;
current_format = GL_BGR;
internal_format = GL_RGB;
current_pixel_format = GL_UNSIGNED_BYTE;
}
} else {
if ((src_pf->dwFlags & DDPF_ALPHAPIXELS) &&
(src_pf->u5.dwRGBAlphaBitMask != 0x000000)) {
error = TRUE;
} else {
if ((src_pf->u2.dwRBitMask == 0xFF0000) &&
(src_pf->u3.dwGBitMask == 0x00FF00) &&
(src_pf->u4.dwBBitMask == 0x0000FF)) {
if (colorkey_active) {
convert_type = CONVERT_CK_RGB24;
current_format = GL_RGBA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_INT_8_8_8_8;
} else {
convert_type = NO_CONVERSION;
current_format = GL_BGR;
internal_format = GL_RGB;
current_pixel_format = GL_UNSIGNED_BYTE;
}
} else {
error = TRUE;
}
}
} else if (src_pf->u1.dwRGBBitCount == 32) {
if ((src_pf->u2.dwRBitMask == 0xFF000000) &&
(src_pf->u3.dwGBitMask == 0x00FF0000) &&
(src_pf->u4.dwBBitMask == 0x0000FF00) &&
(src_pf->u5.dwRGBAlphaBitMask == 0x000000FF)) {
if (colorkey_active) {
convert_type = CONVERT_CK_8888;
} else {
convert_type = NO_CONVERSION;
}
current_format = GL_RGBA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_INT_8_8_8_8;
} else if ((src_pf->u2.dwRBitMask == 0x00FF0000) &&
(src_pf->u3.dwGBitMask == 0x0000FF00) &&
(src_pf->u4.dwBBitMask == 0x000000FF) &&
(src_pf->u5.dwRGBAlphaBitMask == 0xFF000000)) {
if (colorkey_active) {
convert_type = CONVERT_CK_8888_ARGB;
if ((src_pf->dwFlags & DDPF_ALPHAPIXELS) &&
(src_pf->u5.dwRGBAlphaBitMask != 0x00000000)) {
if ((src_pf->u2.dwRBitMask == 0xFF000000) &&
(src_pf->u3.dwGBitMask == 0x00FF0000) &&
(src_pf->u4.dwBBitMask == 0x0000FF00) &&
(src_pf->u5.dwRGBAlphaBitMask == 0x000000FF)) {
if (colorkey_active) {
convert_type = CONVERT_CK_8888;
} else {
convert_type = NO_CONVERSION;
}
current_format = GL_RGBA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_INT_8_8_8_8;
} else if ((src_pf->u2.dwRBitMask == 0x00FF0000) &&
(src_pf->u3.dwGBitMask == 0x0000FF00) &&
(src_pf->u4.dwBBitMask == 0x000000FF) &&
(src_pf->u5.dwRGBAlphaBitMask == 0xFF000000)) {
if (colorkey_active) {
convert_type = CONVERT_CK_8888_ARGB;
current_format = GL_RGBA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_INT_8_8_8_8;
} else {
convert_type = NO_CONVERSION;
current_format = GL_BGRA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_INT_8_8_8_8_REV;
}
} else {
convert_type = NO_CONVERSION;
current_format = GL_BGRA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_INT_8_8_8_8_REV;
}
} else if ((src_pf->u2.dwRBitMask == 0x00FF0000) &&
(src_pf->u3.dwGBitMask == 0x0000FF00) &&
(src_pf->u4.dwBBitMask == 0x000000FF) &&
(src_pf->u5.dwRGBAlphaBitMask == 0x00000000)) {
if (need_alpha_ck == TRUE) {
convert_type = CONVERT_RGB32_888;
current_format = GL_RGBA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_INT_8_8_8_8;
} else {
convert_type = NO_CONVERSION;
current_format = GL_BGRA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_INT_8_8_8_8_REV;
error = TRUE;
}
} else {
error = TRUE;
if ((src_pf->u2.dwRBitMask == 0x00FF0000) &&
(src_pf->u3.dwGBitMask == 0x0000FF00) &&
(src_pf->u4.dwBBitMask == 0x000000FF)) {
if (need_alpha_ck == TRUE) {
convert_type = CONVERT_RGB32_888;
current_format = GL_RGBA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_INT_8_8_8_8;
} else {
convert_type = NO_CONVERSION;
current_format = GL_BGRA;
internal_format = GL_RGBA;
current_pixel_format = GL_UNSIGNED_INT_8_8_8_8_REV;
}
} else {
error = TRUE;
}
}
} else {
error = TRUE;
@ -795,8 +814,8 @@ HRESULT upload_surface_to_tex_memory_init(IDirectDrawSurfaceImpl *surf_ptr, GLui
}
if (error == TRUE) {
ERR("Unsupported pixel format for textures : \n");
if (ERR_ON(ddraw)) {
ERR(" unsupported pixel format for textures : \n");
DDRAW_dump_pixelformat(src_pf);
}
return DDERR_INVALIDPIXELFORMAT;