- added RECT support to the texture upload code

- use the common code for the FB Unlock code
This commit is contained in:
Lionel Ulmer 2003-06-04 23:26:53 +00:00 committed by Alexandre Julliard
parent 3383ce5d51
commit 97140ba2d1
4 changed files with 102 additions and 94 deletions

View File

@ -357,6 +357,9 @@ GL_IDirect3DDeviceImpl_7_3T_2T_1T_Release(LPDIRECT3DDEVICE7 iface)
HeapFree(GetProcessHeap(), 0, This->view_mat);
HeapFree(GetProcessHeap(), 0, This->proj_mat);
if (glThis->surface_ptr)
HeapFree(GetProcessHeap(), 0, glThis->surface_ptr);
DeleteCriticalSection(&(This->crit));
ENTER_GL();
@ -2896,13 +2899,13 @@ static void d3ddevice_lock_update(IDirectDrawSurfaceImpl* This, LPCRECT pRect, D
#define UNLOCK_TEX_SIZE 256
static void d3ddevice_flush_to_frame_buffer(IDirect3DDeviceImpl *d3d_dev, LPCRECT pRect, IDirectDrawSurfaceImpl *surf) {
GLenum buffer_type, buffer_color;
RECT loc_rect;
IDirect3DDeviceGLImpl* gl_d3d_dev = (IDirect3DDeviceGLImpl*) d3d_dev;
GLint depth_test, alpha_test, cull_face, lighting, min_tex, max_tex, tex_env, blend, stencil_test, fog;
GLint depth_test, alpha_test, cull_face, lighting, tex_env, blend, stencil_test, fog;
GLuint initial_texture;
GLint tex_state;
int x, y;
BOOLEAN initial = FALSE;
/* Note : no need here to lock the 'device critical section' as we are already protected by
the GL critical section. */
@ -2913,6 +2916,24 @@ static void d3ddevice_flush_to_frame_buffer(IDirect3DDeviceImpl *d3d_dev, LPCREC
loc_rect.right = surf->surface_desc.dwWidth;
TRACE(" flushing memory back to the frame-buffer (%ld,%ld) x (%ld,%ld).\n", loc_rect.top, loc_rect.left, loc_rect.right, loc_rect.bottom);
glGetIntegerv(GL_TEXTURE_BINDING_2D, &initial_texture);
if (gl_d3d_dev->unlock_tex == 0) {
glGenTextures(1, &gl_d3d_dev->unlock_tex);
glBindTexture(GL_TEXTURE_2D, gl_d3d_dev->unlock_tex);
initial = TRUE;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
} else {
glBindTexture(GL_TEXTURE_2D, gl_d3d_dev->unlock_tex);
}
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) {
ERR(" unsupported pixel format at frame buffer flush.\n");
glBindTexture(GL_TEXTURE_2D, initial_texture);
return;
}
glGetIntegerv(GL_DEPTH_TEST, &depth_test);
glGetIntegerv(GL_ALPHA_TEST, &alpha_test);
@ -2920,36 +2941,13 @@ static void d3ddevice_flush_to_frame_buffer(IDirect3DDeviceImpl *d3d_dev, LPCREC
glGetIntegerv(GL_CULL_FACE, &cull_face);
glGetIntegerv(GL_LIGHTING, &lighting);
glGetIntegerv(GL_BLEND, &blend);
glGetIntegerv(GL_TEXTURE_BINDING_2D, &initial_texture);
glGetIntegerv(GL_TEXTURE_2D, &tex_state);
glGetIntegerv(GL_FOG, &fog);
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &max_tex);
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &min_tex);
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &tex_env);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
/* TODO: scissor test if ever we use it ! */
if ((surf->surface_desc.u4.ddpfPixelFormat.u1.dwRGBBitCount == 16) &&
(surf->surface_desc.u4.ddpfPixelFormat.u2.dwRBitMask == 0xF800) &&
(surf->surface_desc.u4.ddpfPixelFormat.u3.dwGBitMask == 0x07E0) &&
(surf->surface_desc.u4.ddpfPixelFormat.u4.dwBBitMask == 0x001F) &&
(surf->surface_desc.u4.ddpfPixelFormat.u5.dwRGBAlphaBitMask == 0x0000)) {
buffer_type = GL_UNSIGNED_SHORT_5_6_5;
buffer_color = GL_RGB;
} else if ((surf->surface_desc.u4.ddpfPixelFormat.u1.dwRGBBitCount == 32) &&
(surf->surface_desc.u4.ddpfPixelFormat.u2.dwRBitMask == 0x00FF0000) &&
(surf->surface_desc.u4.ddpfPixelFormat.u3.dwGBitMask == 0x0000FF00) &&
(surf->surface_desc.u4.ddpfPixelFormat.u4.dwBBitMask == 0x000000FF) &&
(surf->surface_desc.u4.ddpfPixelFormat.u5.dwRGBAlphaBitMask == 0x00000000)) {
buffer_type = GL_UNSIGNED_BYTE;
buffer_color = GL_BGRA;
glPixelStorei(GL_UNPACK_SWAP_BYTES, TRUE);
} else {
ERR(" unsupported pixel format at frame buffer flush.\n");
return;
}
gl_d3d_dev->transform_state = GL_TRANSFORM_ORTHO;
d3ddevice_set_ortho(d3d_dev);
@ -2960,40 +2958,26 @@ static void d3ddevice_flush_to_frame_buffer(IDirect3DDeviceImpl *d3d_dev, LPCREC
glViewport(0, 0, d3d_dev->surface->surface_desc.dwWidth, d3d_dev->surface->surface_desc.dwHeight);
glScissor(loc_rect.left, surf->surface_desc.dwHeight - loc_rect.bottom,
loc_rect.right - loc_rect.left, loc_rect.bottom - loc_rect.top);
if (gl_d3d_dev->unlock_tex == 0) {
glGenTextures(1, &gl_d3d_dev->unlock_tex);
glBindTexture(GL_TEXTURE_2D, gl_d3d_dev->unlock_tex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
UNLOCK_TEX_SIZE, UNLOCK_TEX_SIZE, 0,
GL_RGB, buffer_type, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
} else {
glBindTexture(GL_TEXTURE_2D, gl_d3d_dev->unlock_tex);
}
glPixelStorei(GL_UNPACK_ROW_LENGTH, surf->surface_desc.dwWidth);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glDisable(GL_LIGHTING);
glDisable(GL_CULL_FACE);
glDisable(GL_ALPHA_TEST);
glDisable(GL_STENCIL_TEST);
glDisable(GL_BLEND);
glDisable(GL_FOG);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
for (x = loc_rect.left; x < loc_rect.right; x += UNLOCK_TEX_SIZE) {
for (y = loc_rect.top; y < loc_rect.bottom; y += UNLOCK_TEX_SIZE) {
/* First, upload the texture... */
int w = (x + UNLOCK_TEX_SIZE > surf->surface_desc.dwWidth) ? (surf->surface_desc.dwWidth - x) : UNLOCK_TEX_SIZE;
int h = (y + UNLOCK_TEX_SIZE > surf->surface_desc.dwHeight) ? (surf->surface_desc.dwHeight - y) : UNLOCK_TEX_SIZE;
glTexSubImage2D(GL_TEXTURE_2D,
0,
0, 0,
w, h,
buffer_color,
buffer_type,
((char *) surf->surface_desc.lpSurface) + (x * GET_BPP(surf->surface_desc)) + (y * surf->surface_desc.u1.lPitch));
RECT flush_rect;
flush_rect.left = x;
flush_rect.top = y;
flush_rect.right = (x + UNLOCK_TEX_SIZE > surf->surface_desc.dwWidth) ? surf->surface_desc.dwWidth : (x + UNLOCK_TEX_SIZE);
flush_rect.bottom = (y + UNLOCK_TEX_SIZE > surf->surface_desc.dwHeight) ? surf->surface_desc.dwHeight : (y + UNLOCK_TEX_SIZE);
upload_surface_to_tex_memory(&flush_rect, 0, 0, &(gl_d3d_dev->surface_ptr));
glBegin(GL_QUADS);
glColor3ub(0xFF, 0xFF, 0xFF);
glTexCoord2f(0.0, 0.0);
@ -3008,6 +2992,7 @@ static void d3ddevice_flush_to_frame_buffer(IDirect3DDeviceImpl *d3d_dev, LPCREC
}
}
upload_surface_to_tex_memory_release();
/* And restore all the various states modified by this code */
if (depth_test != 0) glEnable(GL_DEPTH_TEST);

View File

@ -121,7 +121,7 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *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) {
upload_surface_to_tex_memory(NULL, &(gl_surf_ptr->surface_ptr));
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;
}
@ -232,7 +232,7 @@ gltex_bltfast(IDirectDrawSurfaceImpl *surf_ptr, DWORD dstx,
/* 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) {
upload_surface_to_tex_memory(NULL, &(gl_surf_ptr->surface_ptr));
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 {
@ -245,7 +245,7 @@ gltex_bltfast(IDirectDrawSurfaceImpl *surf_ptr, DWORD dstx,
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) {
upload_surface_to_tex_memory(NULL, &(gl_surf_ptr->surface_ptr));
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 {

View File

@ -574,6 +574,8 @@ static GLenum current_pixel_format;
static CONVERT_TYPES convert_type;
static IDirectDrawSurfaceImpl *current_surface;
static GLuint current_level;
static DWORD current_tex_width;
static DWORD current_tex_height;
HRESULT upload_surface_to_tex_memory_init(IDirectDrawSurfaceImpl *surf_ptr, GLuint level, GLenum *current_internal_format,
BOOLEAN need_to_alloc, BOOLEAN need_alpha_ck, DWORD tex_width, DWORD tex_height)
@ -605,6 +607,9 @@ HRESULT upload_surface_to_tex_memory_init(IDirectDrawSurfaceImpl *surf_ptr, GLui
tex_height = surf_ptr->surface_desc.dwHeight;
}
current_tex_width = tex_width;
current_tex_height = tex_height;
if (src_pf->dwFlags & DDPF_PALETTEINDEXED8) {
/* ****************
Paletted Texture
@ -808,18 +813,32 @@ HRESULT upload_surface_to_tex_memory_init(IDirectDrawSurfaceImpl *surf_ptr, GLui
return DD_OK;
}
HRESULT upload_surface_to_tex_memory(RECT *rect, void **temp_buffer)
HRESULT upload_surface_to_tex_memory(RECT *rect, DWORD xoffset, DWORD yoffset, void **temp_buffer)
{
const DDSURFACEDESC * const src_d = (DDSURFACEDESC *)&(current_surface->surface_desc);
void *surf_buffer = NULL;
RECT lrect;
DWORD width, height;
BYTE bpp = GET_BPP(current_surface->surface_desc);
if (rect == NULL) {
lrect.top = 0;
lrect.left = 0;
lrect.bottom = current_tex_height;
lrect.right = current_tex_width;
rect = &lrect;
}
width = rect->right - rect->left;
height = rect->bottom - rect->top;
switch (convert_type) {
case CONVERT_PALETTED: {
IDirectDrawPaletteImpl* pal = current_surface->palette;
BYTE table[256][4];
int i;
BYTE *src = (BYTE *) src_d->lpSurface, *dst;
BYTE *src = (BYTE *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
if (pal == NULL) {
/* Upload a black texture. The real one will be uploaded on palette change */
WARN("Palettized texture Loading with a NULL palette !\n");
@ -844,10 +863,10 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, void **temp_buffer)
if (*temp_buffer == NULL)
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
src_d->dwWidth * src_d->dwHeight * sizeof(DWORD));
current_tex_width * current_tex_height * sizeof(DWORD));
dst = (BYTE *) *temp_buffer;
for (i = 0; i < src_d->dwHeight * src_d->dwWidth; i++) {
for (i = 0; i < height * width; i++) {
BYTE color = *src++;
*dst++ = table[color][0];
*dst++ = table[color][1];
@ -868,14 +887,14 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, void **temp_buffer)
color-space or not ?
*/
DWORD i;
WORD *src = (WORD *) src_d->lpSurface, *dst;
WORD *src = (WORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
if (*temp_buffer != NULL)
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
src_d->dwWidth * src_d->dwHeight * sizeof(WORD));
current_tex_width * current_tex_height * sizeof(WORD));
dst = (WORD *) *temp_buffer;
for (i = 0; i < src_d->dwHeight * src_d->dwWidth; i++) {
for (i = 0; i < height * width; i++) {
WORD color = *src++;
*dst = ((color & 0xFFC0) | ((color & 0x1F) << 1));
if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
@ -888,14 +907,14 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, void **temp_buffer)
case CONVERT_CK_5551: {
/* Change the alpha value of the color-keyed pixels to emulate color-keying. */
DWORD i;
WORD *src = (WORD *) src_d->lpSurface, *dst;
WORD *src = (WORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
if (*temp_buffer != NULL)
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
src_d->dwWidth * src_d->dwHeight * sizeof(WORD));
current_tex_width * current_tex_height * sizeof(WORD));
dst = (WORD *) *temp_buffer;
for (i = 0; i < src_d->dwHeight * src_d->dwWidth; i++) {
for (i = 0; i < height * width; i++) {
WORD color = *src++;
*dst = color & 0xFFFE;
if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
@ -908,14 +927,14 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, void **temp_buffer)
case CONVERT_CK_4444: {
/* Change the alpha value of the color-keyed pixels to emulate color-keying. */
DWORD i;
WORD *src = (WORD *) src_d->lpSurface, *dst;
WORD *src = (WORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
if (*temp_buffer != NULL)
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
src_d->dwWidth * src_d->dwHeight * sizeof(WORD));
current_tex_width * current_tex_height * sizeof(WORD));
dst = (WORD *) *temp_buffer;
for (i = 0; i < src_d->dwHeight * src_d->dwWidth; i++) {
for (i = 0; i < height * width; i++) {
WORD color = *src++;
*dst = color & 0xFFF0;
if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
@ -928,14 +947,14 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, void **temp_buffer)
case CONVERT_CK_4444_ARGB: {
/* Move the four Alpha bits... */
DWORD i;
WORD *src = (WORD *) src_d->lpSurface, *dst;
WORD *src = (WORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
if (*temp_buffer != NULL)
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
src_d->dwWidth * src_d->dwHeight * sizeof(WORD));
current_tex_width * current_tex_height * sizeof(WORD));
dst = (WORD *) *temp_buffer;
for (i = 0; i < src_d->dwHeight * src_d->dwWidth; i++) {
for (i = 0; i < height * width; i++) {
WORD color = *src++;
*dst = (color & 0x0FFF) << 4;
if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
@ -947,14 +966,14 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, void **temp_buffer)
case CONVERT_CK_1555: {
DWORD i;
WORD *src = (WORD *) src_d->lpSurface, *dst;
WORD *src = (WORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
if (*temp_buffer != NULL)
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
src_d->dwWidth * src_d->dwHeight * sizeof(WORD));
current_tex_width * current_tex_height * sizeof(WORD));
dst = (WORD *) *temp_buffer;
for (i = 0; i < src_d->dwHeight * src_d->dwWidth; i++) {
for (i = 0; i < height * width; i++) {
WORD color = *src++;
*dst = (color & 0x7FFF) << 1;
if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
@ -967,15 +986,15 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, void **temp_buffer)
case CONVERT_555: {
/* Converting the 0555 format in 5551 packed */
DWORD i;
WORD *src = (WORD *) src_d->lpSurface, *dst;
WORD *src = (WORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
if (*temp_buffer != NULL)
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
src_d->dwWidth * src_d->dwHeight * sizeof(WORD));
current_tex_width * current_tex_height * sizeof(WORD));
dst = (WORD *) *temp_buffer;
if (src_d->dwFlags & DDSD_CKSRCBLT) {
for (i = 0; i < src_d->dwHeight * src_d->dwWidth; i++) {
for (i = 0; i < height * width; i++) {
WORD color = *src++;
*dst = (color & 0x7FFF) << 1;
if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
@ -984,7 +1003,7 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, void **temp_buffer)
dst++;
}
} else {
for (i = 0; i < src_d->dwHeight * src_d->dwWidth; i++) {
for (i = 0; i < height * width; i++) {
WORD color = *src++;
*dst++ = ((color & 0x7FFF) << 1) | 0x0001;
}
@ -995,15 +1014,15 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, void **temp_buffer)
case CONVERT_CK_RGB24: {
/* This is a pain :-) */
DWORD i;
BYTE *src = (BYTE *) src_d->lpSurface;
BYTE *src = (BYTE *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top));
DWORD *dst;
if (*temp_buffer != NULL)
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
src_d->dwWidth * src_d->dwHeight * sizeof(DWORD));
current_tex_width * current_tex_height * sizeof(DWORD));
dst = (DWORD *) *temp_buffer;
for (i = 0; i < src_d->dwHeight * src_d->dwWidth; i++) {
for (i = 0; i < height * width; i++) {
DWORD color = *((DWORD *) src) & 0x00FFFFFF;
src += 3;
*dst = *src++ << 8;
@ -1017,14 +1036,14 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, void **temp_buffer)
case CONVERT_CK_8888: {
/* Just use the alpha component to handle color-keying... */
DWORD i;
DWORD *src = (DWORD *) src_d->lpSurface, *dst;
DWORD *src = (DWORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
if (*temp_buffer != NULL)
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
src_d->dwWidth * src_d->dwHeight * sizeof(DWORD));
current_tex_width * current_tex_height * sizeof(DWORD));
dst = (DWORD *) *temp_buffer;
for (i = 0; i < src_d->dwHeight * src_d->dwWidth; i++) {
for (i = 0; i < height * width; i++) {
DWORD color = *src++;
*dst = color & 0xFFFFFF00;
if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
@ -1036,14 +1055,14 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, void **temp_buffer)
case CONVERT_CK_8888_ARGB: {
DWORD i;
DWORD *src = (DWORD *) src_d->lpSurface, *dst;
DWORD *src = (DWORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
if (*temp_buffer != NULL)
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
src_d->dwWidth * src_d->dwHeight * sizeof(DWORD));
current_tex_width * current_tex_height * sizeof(DWORD));
dst = (DWORD *) *temp_buffer;
for (i = 0; i < src_d->dwHeight * src_d->dwWidth; i++) {
for (i = 0; i < height * width; i++) {
DWORD color = *src++;
*dst = (color & 0x00FFFFFF) << 8;
if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
@ -1056,15 +1075,15 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, void **temp_buffer)
case CONVERT_RGB32_888: {
/* Just add an alpha component and handle color-keying... */
DWORD i;
DWORD *src = (DWORD *) src_d->lpSurface, *dst;
DWORD *src = (DWORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
if (*temp_buffer != NULL)
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
src_d->dwWidth * src_d->dwHeight * sizeof(DWORD));
current_tex_width * current_tex_height * sizeof(DWORD));
dst = (DWORD *) *temp_buffer;
if (src_d->dwFlags & DDSD_CKSRCBLT) {
for (i = 0; i < src_d->dwHeight * src_d->dwWidth; i++) {
for (i = 0; i < height * width; i++) {
DWORD color = *src++;
*dst = color << 8;
if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
@ -1073,7 +1092,7 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, void **temp_buffer)
dst++;
}
} else {
for (i = 0; i < src_d->dwHeight * src_d->dwWidth; i++) {
for (i = 0; i < height * width; i++) {
*dst++ = (*src++ << 8) | 0xFF;
}
}
@ -1081,7 +1100,7 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, void **temp_buffer)
case NO_CONVERSION:
/* Nothing to do here as the name suggests... This just prevents a compiler warning */
surf_buffer = src_d->lpSurface;
surf_buffer = (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top));
break;
}
@ -1091,8 +1110,8 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, void **temp_buffer)
glTexSubImage2D(GL_TEXTURE_2D,
current_level,
0, 0,
src_d->dwWidth, src_d->dwHeight,
xoffset, yoffset,
width, height,
current_format,
current_pixel_format,
surf_buffer);

View File

@ -105,7 +105,11 @@ typedef struct IDirect3DDeviceGLImpl
Display *display;
Drawable drawable;
/* Variables used for the flush to frame-buffer code using the texturing code */
GLuint unlock_tex;
void *surface_ptr;
GLenum current_internal_format;
SURFACE_STATE state, front_state;
IDirectDrawSurfaceImpl *lock_surf, *front_lock_surf;
} IDirect3DDeviceGLImpl;
@ -149,7 +153,7 @@ extern void apply_render_state(IDirect3DDeviceImpl* This, STATEBLOCK* lpStateBlo
/* Memory to texture conversion code. Split in three functions to do some optimizations. */
extern HRESULT upload_surface_to_tex_memory_init(IDirectDrawSurfaceImpl *surface, GLuint level, GLenum *prev_internal_format,
BOOLEAN need_to_alloc, BOOLEAN need_alpha_ck, DWORD tex_width, DWORD tex_height);
extern HRESULT upload_surface_to_tex_memory(RECT *rect, void **temp_buffer);
extern HRESULT upload_surface_to_tex_memory(RECT *rect, DWORD xoffset, DWORD yoffset, void **temp_buffer);
extern HRESULT upload_surface_to_tex_memory_release(void);
#endif /* HAVE_OPENGL */