2000-04-09 16:30:50 +02:00
|
|
|
/* Direct3D Common functions
|
2002-03-10 00:29:33 +01:00
|
|
|
* Copyright (c) 1998 Lionel ULMER
|
|
|
|
*
|
|
|
|
* This file contains all MESA common code
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-11-06 21:57:11 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2003-06-05 01:22:13 +02:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2000-04-09 16:30:50 +02:00
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
2002-12-05 21:33:07 +01:00
|
|
|
#include "objbase.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "wingdi.h"
|
2000-04-09 16:30:50 +02:00
|
|
|
#include "ddraw.h"
|
|
|
|
#include "d3d.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2000-04-09 16:30:50 +02:00
|
|
|
|
|
|
|
#include "mesa_private.h"
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-12-16 23:39:09 +01:00
|
|
|
GLenum convert_D3D_compare_to_GL(D3DCMPFUNC dwRenderState)
|
|
|
|
{
|
|
|
|
switch (dwRenderState) {
|
|
|
|
case D3DCMP_NEVER: return GL_NEVER;
|
|
|
|
case D3DCMP_LESS: return GL_LESS;
|
|
|
|
case D3DCMP_EQUAL: return GL_EQUAL;
|
|
|
|
case D3DCMP_LESSEQUAL: return GL_LEQUAL;
|
|
|
|
case D3DCMP_GREATER: return GL_GREATER;
|
|
|
|
case D3DCMP_NOTEQUAL: return GL_NOTEQUAL;
|
|
|
|
case D3DCMP_GREATEREQUAL: return GL_GEQUAL;
|
|
|
|
case D3DCMP_ALWAYS: return GL_ALWAYS;
|
2002-12-16 23:48:20 +01:00
|
|
|
default: ERR("Unexpected compare type %d !\n", dwRenderState);
|
2002-12-16 23:39:09 +01:00
|
|
|
}
|
2002-12-16 23:48:20 +01:00
|
|
|
return GL_ALWAYS;
|
2002-12-16 23:39:09 +01:00
|
|
|
}
|
|
|
|
|
2003-01-02 21:01:54 +01:00
|
|
|
GLenum convert_D3D_stencilop_to_GL(D3DSTENCILOP dwRenderState)
|
|
|
|
{
|
|
|
|
switch (dwRenderState) {
|
|
|
|
case D3DSTENCILOP_KEEP: return GL_KEEP;
|
|
|
|
case D3DSTENCILOP_ZERO: return GL_ZERO;
|
|
|
|
case D3DSTENCILOP_REPLACE: return GL_REPLACE;
|
|
|
|
case D3DSTENCILOP_INCRSAT: return GL_INCR;
|
|
|
|
case D3DSTENCILOP_DECRSAT: return GL_DECR;
|
|
|
|
case D3DSTENCILOP_INVERT: return GL_INVERT;
|
|
|
|
case D3DSTENCILOP_INCR: WARN("D3DSTENCILOP_INCR not properly handled !\n"); return GL_INCR;
|
|
|
|
case D3DSTENCILOP_DECR: WARN("D3DSTENCILOP_DECR not properly handled !\n"); return GL_DECR;
|
|
|
|
default: ERR("Unexpected compare type %d !\n", dwRenderState);
|
|
|
|
}
|
|
|
|
return GL_KEEP;
|
|
|
|
}
|
2002-12-16 23:39:09 +01:00
|
|
|
|
2003-01-08 00:08:31 +01:00
|
|
|
GLenum convert_D3D_blendop_to_GL(D3DBLEND dwRenderState)
|
2000-04-09 16:30:50 +02:00
|
|
|
{
|
2003-01-08 00:08:31 +01:00
|
|
|
switch ((D3DBLEND) dwRenderState) {
|
|
|
|
case D3DBLEND_ZERO: return GL_ZERO;
|
|
|
|
case D3DBLEND_ONE: return GL_ONE;
|
|
|
|
case D3DBLEND_SRCALPHA: return GL_SRC_ALPHA;
|
|
|
|
case D3DBLEND_INVSRCALPHA: return GL_ONE_MINUS_SRC_ALPHA;
|
|
|
|
case D3DBLEND_DESTALPHA: return GL_DST_ALPHA;
|
|
|
|
case D3DBLEND_INVDESTALPHA: return GL_ONE_MINUS_DST_ALPHA;
|
|
|
|
case D3DBLEND_DESTCOLOR: return GL_DST_COLOR;
|
|
|
|
case D3DBLEND_INVDESTCOLOR: return GL_ONE_MINUS_DST_COLOR;
|
|
|
|
case D3DBLEND_SRCALPHASAT: return GL_SRC_ALPHA_SATURATE;
|
|
|
|
case D3DBLEND_SRCCOLOR: return GL_SRC_COLOR;
|
|
|
|
case D3DBLEND_INVSRCCOLOR: return GL_ONE_MINUS_SRC_COLOR;
|
|
|
|
default: ERR("Unhandled blend mode %d !\n", dwRenderState); return GL_ZERO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_render_state(IDirect3DDeviceImpl* This,
|
|
|
|
D3DRENDERSTATETYPE dwRenderStateType, STATEBLOCK *lpStateBlock)
|
|
|
|
{
|
|
|
|
DWORD dwRenderState = lpStateBlock->render_state[dwRenderStateType - 1];
|
2003-05-20 05:58:01 +02:00
|
|
|
IDirect3DDeviceGLImpl *glThis = (IDirect3DDeviceGLImpl *) This;
|
|
|
|
|
2003-06-05 01:36:48 +02:00
|
|
|
TRACE("%s = %08lx\n", _get_renderstate(dwRenderStateType), dwRenderState);
|
2002-11-21 22:04:16 +01:00
|
|
|
|
|
|
|
/* First, all the stipple patterns */
|
|
|
|
if ((dwRenderStateType >= D3DRENDERSTATE_STIPPLEPATTERN00) &&
|
|
|
|
(dwRenderStateType <= D3DRENDERSTATE_STIPPLEPATTERN31)) {
|
|
|
|
ERR("Unhandled dwRenderStateType stipple %d!\n",dwRenderStateType);
|
|
|
|
} else {
|
|
|
|
ENTER_GL();
|
|
|
|
|
|
|
|
/* All others state variables */
|
|
|
|
switch (dwRenderStateType) {
|
|
|
|
case D3DRENDERSTATE_TEXTUREHANDLE: { /* 1 */
|
2002-12-15 02:17:59 +01:00
|
|
|
IDirectDrawSurfaceImpl *tex = (IDirectDrawSurfaceImpl*) dwRenderState;
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2003-01-08 00:08:31 +01:00
|
|
|
IDirect3DDevice7_SetTexture(ICOM_INTERFACE(This, IDirect3DDevice7),
|
2003-01-05 02:04:55 +01:00
|
|
|
0,
|
|
|
|
ICOM_INTERFACE(tex, IDirectDrawSurface7));
|
2002-11-21 22:04:16 +01:00
|
|
|
} break;
|
2003-07-08 23:10:01 +02:00
|
|
|
|
|
|
|
case D3DRENDERSTATE_ANTIALIAS: /* 2 */
|
|
|
|
if (dwRenderState)
|
|
|
|
ERR("D3DRENDERSTATE_ANTIALIAS not supported yet !\n");
|
|
|
|
break;
|
2002-12-17 00:09:23 +01:00
|
|
|
|
2002-12-16 23:39:09 +01:00
|
|
|
case D3DRENDERSTATE_TEXTUREADDRESSU: /* 44 */
|
|
|
|
case D3DRENDERSTATE_TEXTUREADDRESSV: /* 45 */
|
|
|
|
case D3DRENDERSTATE_TEXTUREADDRESS: { /* 3 */
|
2003-01-08 00:08:31 +01:00
|
|
|
D3DTEXTURESTAGESTATETYPE d3dTexStageStateType;
|
|
|
|
|
|
|
|
if (dwRenderStateType == D3DRENDERSTATE_TEXTUREADDRESS) d3dTexStageStateType = D3DTSS_ADDRESS;
|
|
|
|
else if (dwRenderStateType == D3DRENDERSTATE_TEXTUREADDRESSU) d3dTexStageStateType = D3DTSS_ADDRESSU;
|
|
|
|
else d3dTexStageStateType = D3DTSS_ADDRESSV;
|
|
|
|
|
|
|
|
IDirect3DDevice7_SetTextureStageState(ICOM_INTERFACE(This, IDirect3DDevice7),
|
|
|
|
0, d3dTexStageStateType,
|
|
|
|
dwRenderState);
|
2002-12-16 23:08:24 +01:00
|
|
|
} break;
|
|
|
|
|
2002-11-21 22:04:16 +01:00
|
|
|
case D3DRENDERSTATE_TEXTUREPERSPECTIVE: /* 4 */
|
|
|
|
if (dwRenderState)
|
|
|
|
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
|
|
|
else
|
|
|
|
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
|
|
|
break;
|
|
|
|
|
2002-12-23 03:09:20 +01:00
|
|
|
case D3DRENDERSTATE_WRAPU: /* 5 */
|
|
|
|
case D3DRENDERSTATE_WRAPV: /* 6 */
|
2003-05-17 20:30:27 +02:00
|
|
|
case D3DRENDERSTATE_WRAP0: /* 128 */
|
|
|
|
case D3DRENDERSTATE_WRAP1: /* 129 */
|
|
|
|
case D3DRENDERSTATE_WRAP2: /* 130 */
|
|
|
|
case D3DRENDERSTATE_WRAP3: /* 131 */
|
|
|
|
case D3DRENDERSTATE_WRAP4: /* 132 */
|
|
|
|
case D3DRENDERSTATE_WRAP5: /* 133 */
|
|
|
|
case D3DRENDERSTATE_WRAP6: /* 134 */
|
|
|
|
case D3DRENDERSTATE_WRAP7: /* 135 */
|
2002-12-23 03:09:20 +01:00
|
|
|
if (dwRenderState)
|
2003-05-17 20:30:27 +02:00
|
|
|
ERR("Texture WRAP modes unsupported by OpenGL.. Expect graphical glitches !\n");
|
2002-12-23 03:09:20 +01:00
|
|
|
break;
|
|
|
|
|
2002-11-21 22:04:16 +01:00
|
|
|
case D3DRENDERSTATE_ZENABLE: /* 7 */
|
2003-01-02 21:13:47 +01:00
|
|
|
/* To investigate : in OpenGL, if we disable the depth test, the Z buffer will NOT be
|
|
|
|
updated either.. No idea about what happens in D3D.
|
|
|
|
|
|
|
|
Maybe replacing the Z function by ALWAYS would be a better idea. */
|
2003-06-16 21:41:34 +02:00
|
|
|
if (dwRenderState == D3DZB_TRUE) {
|
|
|
|
if (glThis->depth_test == FALSE) {
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
glThis->depth_test = TRUE;
|
|
|
|
}
|
|
|
|
} else if (dwRenderState == D3DZB_FALSE) {
|
2004-12-09 15:07:59 +01:00
|
|
|
if (glThis->depth_test) {
|
2003-06-16 21:41:34 +02:00
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
glThis->depth_test = FALSE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (glThis->depth_test == FALSE) {
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
glThis->depth_test = TRUE;
|
|
|
|
}
|
2003-01-02 21:13:47 +01:00
|
|
|
WARN(" w-buffering not supported.\n");
|
|
|
|
}
|
2002-11-21 22:04:16 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DRENDERSTATE_FILLMODE: /* 8 */
|
|
|
|
switch ((D3DFILLMODE) dwRenderState) {
|
|
|
|
case D3DFILL_POINT:
|
|
|
|
glPolygonMode(GL_FRONT_AND_BACK,GL_POINT);
|
|
|
|
break;
|
|
|
|
case D3DFILL_WIREFRAME:
|
|
|
|
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
|
|
|
|
break;
|
|
|
|
case D3DFILL_SOLID:
|
|
|
|
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
|
|
|
|
break;
|
|
|
|
default:
|
2002-12-16 23:50:30 +01:00
|
|
|
ERR("Unhandled fill mode %ld !\n",dwRenderState);
|
2002-11-21 22:04:16 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DRENDERSTATE_SHADEMODE: /* 9 */
|
|
|
|
switch ((D3DSHADEMODE) dwRenderState) {
|
|
|
|
case D3DSHADE_FLAT:
|
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
break;
|
|
|
|
case D3DSHADE_GOURAUD:
|
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
break;
|
|
|
|
default:
|
2002-12-16 23:50:30 +01:00
|
|
|
ERR("Unhandled shade mode %ld !\n",dwRenderState);
|
2002-11-21 22:04:16 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DRENDERSTATE_ZWRITEENABLE: /* 14 */
|
2003-06-16 03:23:58 +02:00
|
|
|
if ((dwRenderState != FALSE) && (glThis->depth_mask == FALSE))
|
2002-11-21 22:04:16 +01:00
|
|
|
glDepthMask(GL_TRUE);
|
2003-06-16 03:23:58 +02:00
|
|
|
else if ((dwRenderState == FALSE) && (glThis->depth_mask != FALSE))
|
2002-11-21 22:04:16 +01:00
|
|
|
glDepthMask(GL_FALSE);
|
2003-06-16 03:23:58 +02:00
|
|
|
glThis->depth_mask = dwRenderState;
|
2002-11-21 22:04:16 +01:00
|
|
|
break;
|
2002-12-16 23:39:09 +01:00
|
|
|
|
|
|
|
case D3DRENDERSTATE_ALPHATESTENABLE: /* 15 */
|
2003-06-16 03:23:58 +02:00
|
|
|
if ((dwRenderState != 0) && (glThis->alpha_test == FALSE))
|
2002-12-16 23:39:09 +01:00
|
|
|
glEnable(GL_ALPHA_TEST);
|
2003-06-16 03:23:58 +02:00
|
|
|
else if ((dwRenderState == 0) && (glThis->alpha_test != FALSE))
|
2002-12-16 23:39:09 +01:00
|
|
|
glDisable(GL_ALPHA_TEST);
|
2003-06-16 03:23:58 +02:00
|
|
|
glThis->alpha_test = dwRenderState;
|
2002-12-16 23:39:09 +01:00
|
|
|
break;
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2003-01-08 00:08:31 +01:00
|
|
|
case D3DRENDERSTATE_TEXTUREMAG: { /* 17 */
|
|
|
|
DWORD tex_mag = 0xFFFFFFFF;
|
|
|
|
|
2002-11-21 22:04:16 +01:00
|
|
|
switch ((D3DTEXTUREFILTER) dwRenderState) {
|
|
|
|
case D3DFILTER_NEAREST:
|
2003-01-08 00:08:31 +01:00
|
|
|
tex_mag = D3DTFG_POINT;
|
2002-11-21 22:04:16 +01:00
|
|
|
break;
|
|
|
|
case D3DFILTER_LINEAR:
|
2003-01-08 00:08:31 +01:00
|
|
|
tex_mag = D3DTFG_LINEAR;
|
2002-11-21 22:04:16 +01:00
|
|
|
break;
|
|
|
|
default:
|
2002-12-16 23:50:30 +01:00
|
|
|
ERR("Unhandled texture mag %ld !\n",dwRenderState);
|
2002-11-21 22:04:16 +01:00
|
|
|
}
|
|
|
|
|
2003-01-08 00:08:31 +01:00
|
|
|
if (tex_mag != 0xFFFFFFFF) {
|
|
|
|
IDirect3DDevice7_SetTextureStageState(ICOM_INTERFACE(This, IDirect3DDevice7), 0, D3DTSS_MAGFILTER, tex_mag);
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case D3DRENDERSTATE_TEXTUREMIN: { /* 18 */
|
|
|
|
DWORD tex_min = 0xFFFFFFFF;
|
|
|
|
|
2002-11-21 22:04:16 +01:00
|
|
|
switch ((D3DTEXTUREFILTER) dwRenderState) {
|
|
|
|
case D3DFILTER_NEAREST:
|
2003-01-08 00:08:31 +01:00
|
|
|
tex_min = D3DTFN_POINT;
|
2002-11-21 22:04:16 +01:00
|
|
|
break;
|
|
|
|
case D3DFILTER_LINEAR:
|
2003-01-08 00:08:31 +01:00
|
|
|
tex_min = D3DTFN_LINEAR;
|
2002-11-21 22:04:16 +01:00
|
|
|
break;
|
|
|
|
default:
|
2002-12-16 23:50:30 +01:00
|
|
|
ERR("Unhandled texture min %ld !\n",dwRenderState);
|
2003-01-08 00:08:31 +01:00
|
|
|
}
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2003-01-08 00:08:31 +01:00
|
|
|
if (tex_min != 0xFFFFFFFF) {
|
|
|
|
IDirect3DDevice7_SetTextureStageState(ICOM_INTERFACE(This, IDirect3DDevice7), 0, D3DTSS_MINFILTER, tex_min);
|
2002-11-21 22:04:16 +01:00
|
|
|
}
|
2003-01-08 00:08:31 +01:00
|
|
|
} break;
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2003-01-08 00:08:31 +01:00
|
|
|
case D3DRENDERSTATE_SRCBLEND: /* 19 */
|
2002-11-21 22:04:16 +01:00
|
|
|
case D3DRENDERSTATE_DESTBLEND: /* 20 */
|
2003-01-08 00:08:31 +01:00
|
|
|
glBlendFunc(convert_D3D_blendop_to_GL(lpStateBlock->render_state[D3DRENDERSTATE_SRCBLEND - 1]),
|
|
|
|
convert_D3D_blendop_to_GL(lpStateBlock->render_state[D3DRENDERSTATE_DESTBLEND - 1]));
|
2002-11-21 22:04:16 +01:00
|
|
|
break;
|
|
|
|
|
2003-06-05 01:38:22 +02:00
|
|
|
case D3DRENDERSTATE_TEXTUREMAPBLEND: { /* 21 */
|
|
|
|
IDirect3DDevice7 *d3ddev = ICOM_INTERFACE(This, IDirect3DDevice7);
|
|
|
|
|
2002-11-21 22:04:16 +01:00
|
|
|
switch ((D3DTEXTUREBLEND) dwRenderState) {
|
2003-06-04 23:52:46 +02:00
|
|
|
case D3DTBLEND_DECAL:
|
2003-06-16 03:23:58 +02:00
|
|
|
if (glThis->current_tex_env != GL_REPLACE) {
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
|
|
|
glThis->current_tex_env = GL_REPLACE;
|
|
|
|
}
|
2003-06-05 01:38:22 +02:00
|
|
|
break;
|
|
|
|
case D3DTBLEND_DECALALPHA:
|
2003-06-16 03:23:58 +02:00
|
|
|
if (glThis->current_tex_env != GL_REPLACE) {
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
|
|
|
glThis->current_tex_env = GL_DECAL;
|
|
|
|
}
|
2003-06-04 23:52:46 +02:00
|
|
|
break;
|
2002-11-21 22:04:16 +01:00
|
|
|
case D3DTBLEND_MODULATE:
|
2003-06-16 03:23:58 +02:00
|
|
|
if (glThis->current_tex_env != GL_MODULATE) {
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
|
|
glThis->current_tex_env = GL_MODULATE;
|
|
|
|
}
|
2003-06-05 01:38:22 +02:00
|
|
|
break;
|
2002-11-21 22:04:16 +01:00
|
|
|
case D3DTBLEND_MODULATEALPHA:
|
2003-06-05 01:38:22 +02:00
|
|
|
IDirect3DDevice7_SetTextureStageState(d3ddev, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
|
|
|
IDirect3DDevice7_SetTextureStageState(d3ddev, 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
|
|
|
IDirect3DDevice7_SetTextureStageState(d3ddev, 0, D3DTSS_COLORARG2, D3DTA_CURRENT);
|
|
|
|
IDirect3DDevice7_SetTextureStageState(d3ddev, 0, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
|
|
|
|
IDirect3DDevice7_SetTextureStageState(d3ddev, 0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
|
|
|
IDirect3DDevice7_SetTextureStageState(d3ddev, 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
2003-01-02 20:45:23 +01:00
|
|
|
break;
|
2002-11-21 22:04:16 +01:00
|
|
|
default:
|
2003-01-08 00:08:31 +01:00
|
|
|
ERR("Unhandled texture environment %ld !\n",dwRenderState);
|
2002-11-21 22:04:16 +01:00
|
|
|
}
|
2003-06-05 01:38:22 +02:00
|
|
|
} break;
|
2002-11-21 22:04:16 +01:00
|
|
|
|
|
|
|
case D3DRENDERSTATE_CULLMODE: /* 22 */
|
|
|
|
switch ((D3DCULL) dwRenderState) {
|
|
|
|
case D3DCULL_NONE:
|
2003-06-16 03:23:58 +02:00
|
|
|
if (glThis->cull_face != 0) {
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
glThis->cull_face = 0;
|
|
|
|
}
|
2002-11-21 22:04:16 +01:00
|
|
|
break;
|
|
|
|
case D3DCULL_CW:
|
2003-06-16 03:23:58 +02:00
|
|
|
if (glThis->cull_face == 0) {
|
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
glThis->cull_face = 1;
|
|
|
|
}
|
2003-01-02 21:05:48 +01:00
|
|
|
glFrontFace(GL_CCW);
|
2003-01-02 20:45:23 +01:00
|
|
|
glCullFace(GL_BACK);
|
2002-11-21 22:04:16 +01:00
|
|
|
break;
|
|
|
|
case D3DCULL_CCW:
|
2003-06-16 03:23:58 +02:00
|
|
|
if (glThis->cull_face == 0) {
|
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
glThis->cull_face = 1;
|
|
|
|
}
|
2003-01-02 21:05:48 +01:00
|
|
|
glFrontFace(GL_CW);
|
2003-01-02 20:45:23 +01:00
|
|
|
glCullFace(GL_BACK);
|
2002-11-21 22:04:16 +01:00
|
|
|
break;
|
|
|
|
default:
|
2002-12-16 23:50:30 +01:00
|
|
|
ERR("Unhandled cull mode %ld !\n",dwRenderState);
|
2002-11-21 22:04:16 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DRENDERSTATE_ZFUNC: /* 23 */
|
2002-12-16 23:39:09 +01:00
|
|
|
glDepthFunc(convert_D3D_compare_to_GL(dwRenderState));
|
|
|
|
break;
|
|
|
|
|
2003-11-11 01:31:16 +01:00
|
|
|
case D3DRENDERSTATE_ALPHAREF: /* 24 */
|
|
|
|
case D3DRENDERSTATE_ALPHAFUNC: { /* 25 */
|
|
|
|
GLenum func = convert_D3D_compare_to_GL(lpStateBlock->render_state[D3DRENDERSTATE_ALPHAFUNC - 1]);
|
|
|
|
GLclampf ref = (lpStateBlock->render_state[D3DRENDERSTATE_ALPHAREF - 1] & 0x000000FF) / 255.0;
|
|
|
|
|
|
|
|
if ((func != glThis->current_alpha_test_func) || (ref != glThis->current_alpha_test_ref)) {
|
|
|
|
glAlphaFunc(func, ref);
|
|
|
|
glThis->current_alpha_test_func = func;
|
|
|
|
glThis->current_alpha_test_ref = ref;
|
|
|
|
}
|
|
|
|
}
|
2002-11-21 22:04:16 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DRENDERSTATE_DITHERENABLE: /* 26 */
|
|
|
|
if (dwRenderState)
|
|
|
|
glEnable(GL_DITHER);
|
|
|
|
else
|
|
|
|
glDisable(GL_DITHER);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DRENDERSTATE_ALPHABLENDENABLE: /* 27 */
|
2003-06-16 03:23:58 +02:00
|
|
|
if ((dwRenderState != 0) && (glThis->blending == 0)) {
|
2002-11-21 22:04:16 +01:00
|
|
|
glEnable(GL_BLEND);
|
2003-06-16 03:23:58 +02:00
|
|
|
} else if ((dwRenderState == 0) && (glThis->blending != 0)) {
|
2002-11-21 22:04:16 +01:00
|
|
|
glDisable(GL_BLEND);
|
2003-01-02 20:45:23 +01:00
|
|
|
}
|
2003-06-16 03:23:58 +02:00
|
|
|
glThis->blending = dwRenderState;
|
2003-11-11 01:31:16 +01:00
|
|
|
|
|
|
|
/* Hack for some old games ... */
|
|
|
|
if (glThis->version == 1) {
|
|
|
|
lpStateBlock->render_state[D3DRENDERSTATE_COLORKEYENABLE - 1] = dwRenderState;
|
|
|
|
}
|
2002-11-21 22:04:16 +01:00
|
|
|
break;
|
2002-12-17 00:09:23 +01:00
|
|
|
|
|
|
|
case D3DRENDERSTATE_FOGENABLE: /* 28 */
|
2003-01-23 02:21:50 +01:00
|
|
|
/* Nothing to do here. Only the storage matters :-) */
|
2002-12-17 00:09:23 +01:00
|
|
|
break;
|
2002-11-21 22:04:16 +01:00
|
|
|
|
2002-12-17 00:09:23 +01:00
|
|
|
case D3DRENDERSTATE_SPECULARENABLE: /* 29 */
|
|
|
|
if (dwRenderState)
|
|
|
|
ERR(" Specular Lighting not supported yet.\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DRENDERSTATE_SUBPIXEL: /* 31 */
|
|
|
|
case D3DRENDERSTATE_SUBPIXELX: /* 32 */
|
|
|
|
/* We do not support this anyway, so why protest :-) */
|
2003-01-23 02:21:50 +01:00
|
|
|
break;
|
2002-12-17 00:09:23 +01:00
|
|
|
|
2002-12-24 02:03:04 +01:00
|
|
|
case D3DRENDERSTATE_STIPPLEDALPHA: /* 33 */
|
|
|
|
if (dwRenderState)
|
|
|
|
ERR(" Stippled Alpha not supported yet.\n");
|
|
|
|
break;
|
|
|
|
|
2002-12-17 00:09:23 +01:00
|
|
|
case D3DRENDERSTATE_FOGCOLOR: { /* 34 */
|
2003-01-23 02:21:50 +01:00
|
|
|
GLfloat color[4];
|
|
|
|
color[0] = ((dwRenderState >> 16) & 0xFF)/255.0f;
|
|
|
|
color[1] = ((dwRenderState >> 8) & 0xFF)/255.0f;
|
|
|
|
color[2] = ((dwRenderState >> 0) & 0xFF)/255.0f;
|
|
|
|
color[3] = ((dwRenderState >> 24) & 0xFF)/255.0f;
|
|
|
|
glFogfv(GL_FOG_COLOR,color);
|
|
|
|
/* Note: glFogiv does not seem to work */
|
2002-12-17 00:09:23 +01:00
|
|
|
} break;
|
|
|
|
|
2003-01-23 02:21:50 +01:00
|
|
|
case D3DRENDERSTATE_FOGTABLEMODE: /* 35 */
|
|
|
|
case D3DRENDERSTATE_FOGVERTEXMODE: /* 140 */
|
|
|
|
case D3DRENDERSTATE_FOGSTART: /* 36 */
|
|
|
|
case D3DRENDERSTATE_FOGEND: /* 37 */
|
|
|
|
/* Nothing to do here. Only the storage matters :-) */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DRENDERSTATE_FOGDENSITY: /* 38 */
|
|
|
|
glFogi(GL_FOG_DENSITY,*(float*)&dwRenderState);
|
|
|
|
break;
|
|
|
|
|
2002-11-21 22:04:16 +01:00
|
|
|
case D3DRENDERSTATE_COLORKEYENABLE: /* 41 */
|
2003-11-11 01:31:16 +01:00
|
|
|
/* Nothing done here, only storage matters. */
|
2002-11-21 22:04:16 +01:00
|
|
|
break;
|
|
|
|
|
2003-08-05 21:18:19 +02:00
|
|
|
case D3DRENDERSTATE_MIPMAPLODBIAS: /* 46 */
|
|
|
|
IDirect3DDevice7_SetTextureStageState(ICOM_INTERFACE(This, IDirect3DDevice7),
|
|
|
|
0, D3DTSS_MIPMAPLODBIAS,
|
|
|
|
dwRenderState);
|
|
|
|
break;
|
|
|
|
|
2002-12-17 00:09:23 +01:00
|
|
|
case D3DRENDERSTATE_ZBIAS: /* 47 */
|
|
|
|
/* This is a tad bit hacky.. But well, no idea how to do it better in OpenGL :-/ */
|
|
|
|
if (dwRenderState == 0) {
|
|
|
|
glDisable(GL_POLYGON_OFFSET_FILL);
|
|
|
|
glDisable(GL_POLYGON_OFFSET_LINE);
|
|
|
|
glDisable(GL_POLYGON_OFFSET_POINT);
|
|
|
|
} else {
|
|
|
|
glEnable(GL_POLYGON_OFFSET_FILL);
|
|
|
|
glEnable(GL_POLYGON_OFFSET_LINE);
|
|
|
|
glEnable(GL_POLYGON_OFFSET_POINT);
|
|
|
|
glPolygonOffset(1.0, dwRenderState * 1.0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-21 22:04:16 +01:00
|
|
|
case D3DRENDERSTATE_FLUSHBATCH: /* 50 */
|
|
|
|
break;
|
|
|
|
|
2003-01-02 21:01:54 +01:00
|
|
|
case D3DRENDERSTATE_STENCILENABLE: /* 52 */
|
2003-06-16 03:23:58 +02:00
|
|
|
if ((dwRenderState != 0) && (glThis->stencil_test == 0))
|
2003-01-08 00:08:31 +01:00
|
|
|
glEnable(GL_STENCIL_TEST);
|
2003-06-16 03:23:58 +02:00
|
|
|
else if ((dwRenderState == 0) && (glThis->stencil_test != 0))
|
2003-01-02 21:01:54 +01:00
|
|
|
glDisable(GL_STENCIL_TEST);
|
2003-06-16 03:23:58 +02:00
|
|
|
glThis->stencil_test = dwRenderState;
|
2003-01-02 21:01:54 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DRENDERSTATE_STENCILFAIL: /* 53 */
|
|
|
|
case D3DRENDERSTATE_STENCILZFAIL: /* 54 */
|
|
|
|
case D3DRENDERSTATE_STENCILPASS: /* 55 */
|
2003-01-08 00:08:31 +01:00
|
|
|
glStencilOp(convert_D3D_stencilop_to_GL(lpStateBlock->render_state[D3DRENDERSTATE_STENCILFAIL - 1]),
|
|
|
|
convert_D3D_stencilop_to_GL(lpStateBlock->render_state[D3DRENDERSTATE_STENCILZFAIL - 1]),
|
|
|
|
convert_D3D_stencilop_to_GL(lpStateBlock->render_state[D3DRENDERSTATE_STENCILPASS - 1]));
|
2003-01-02 21:01:54 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DRENDERSTATE_STENCILFUNC: /* 56 */
|
|
|
|
case D3DRENDERSTATE_STENCILREF: /* 57 */
|
|
|
|
case D3DRENDERSTATE_STENCILMASK: /* 58 */
|
2003-01-08 00:08:31 +01:00
|
|
|
glStencilFunc(convert_D3D_compare_to_GL(lpStateBlock->render_state[D3DRENDERSTATE_STENCILFUNC - 1]),
|
|
|
|
lpStateBlock->render_state[D3DRENDERSTATE_STENCILREF - 1],
|
|
|
|
lpStateBlock->render_state[D3DRENDERSTATE_STENCILMASK - 1]);
|
2003-01-02 21:01:54 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DRENDERSTATE_STENCILWRITEMASK: /* 59 */
|
|
|
|
glStencilMask(dwRenderState);
|
|
|
|
break;
|
|
|
|
|
2003-05-20 04:15:24 +02:00
|
|
|
case D3DRENDERSTATE_TEXTUREFACTOR: /* 60 */
|
|
|
|
/* Only the storage matters... */
|
|
|
|
break;
|
|
|
|
|
2003-01-08 00:08:31 +01:00
|
|
|
case D3DRENDERSTATE_CLIPPING: /* 136 */
|
|
|
|
case D3DRENDERSTATE_CLIPPLANEENABLE: { /* 152 */
|
2003-01-07 20:42:26 +01:00
|
|
|
GLint i;
|
|
|
|
DWORD mask, runner;
|
|
|
|
|
2003-01-08 00:08:31 +01:00
|
|
|
if (dwRenderStateType == D3DRENDERSTATE_CLIPPING) {
|
|
|
|
mask = ((dwRenderState) ?
|
2003-05-20 05:58:01 +02:00
|
|
|
(This->state_block.render_state[D3DRENDERSTATE_CLIPPLANEENABLE - 1]) : (0x00000000));
|
2003-01-07 20:42:26 +01:00
|
|
|
} else {
|
|
|
|
mask = dwRenderState;
|
|
|
|
}
|
2003-01-08 00:08:31 +01:00
|
|
|
for (i = 0, runner = 0x00000001; i < This->max_clipping_planes; i++, runner = (runner << 1)) {
|
2003-01-07 20:42:26 +01:00
|
|
|
if (mask & runner) {
|
2003-05-20 05:58:01 +02:00
|
|
|
GLint enabled;
|
|
|
|
glGetIntegerv(GL_CLIP_PLANE0 + i, &enabled);
|
|
|
|
if (enabled == GL_FALSE) {
|
|
|
|
glEnable(GL_CLIP_PLANE0 + i);
|
|
|
|
/* Need to force a transform change so that this clipping plane parameters are sent
|
|
|
|
* properly to GL.
|
|
|
|
*/
|
|
|
|
glThis->transform_state = GL_TRANSFORM_NONE;
|
|
|
|
}
|
2003-01-07 20:42:26 +01:00
|
|
|
} else {
|
|
|
|
glDisable(GL_CLIP_PLANE0 + i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-01-03 20:10:48 +01:00
|
|
|
break;
|
|
|
|
|
2002-12-24 02:03:04 +01:00
|
|
|
case D3DRENDERSTATE_LIGHTING: /* 137 */
|
2003-06-16 03:23:58 +02:00
|
|
|
/* Nothing to do, only storage matters... */
|
2002-12-24 02:03:04 +01:00
|
|
|
break;
|
2003-01-02 21:01:54 +01:00
|
|
|
|
|
|
|
case D3DRENDERSTATE_AMBIENT: { /* 139 */
|
|
|
|
float light[4];
|
|
|
|
|
|
|
|
light[0] = ((dwRenderState >> 16) & 0xFF) / 255.0;
|
|
|
|
light[1] = ((dwRenderState >> 8) & 0xFF) / 255.0;
|
|
|
|
light[2] = ((dwRenderState >> 0) & 0xFF) / 255.0;
|
|
|
|
light[3] = ((dwRenderState >> 24) & 0xFF) / 255.0;
|
|
|
|
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, (float *) light);
|
|
|
|
} break;
|
|
|
|
|
2003-02-12 22:35:06 +01:00
|
|
|
case D3DRENDERSTATE_COLORVERTEX: /* 141 */
|
|
|
|
/* Nothing to do here.. Only storage matters */
|
|
|
|
break;
|
|
|
|
|
2003-01-02 21:01:54 +01:00
|
|
|
case D3DRENDERSTATE_LOCALVIEWER: /* 142 */
|
|
|
|
if (dwRenderState)
|
|
|
|
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
|
|
|
|
else
|
|
|
|
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DRENDERSTATE_NORMALIZENORMALS: /* 143 */
|
|
|
|
if (dwRenderState) {
|
|
|
|
glEnable(GL_NORMALIZE);
|
|
|
|
glEnable(GL_RESCALE_NORMAL);
|
|
|
|
} else {
|
|
|
|
glDisable(GL_NORMALIZE);
|
|
|
|
glDisable(GL_RESCALE_NORMAL);
|
|
|
|
}
|
|
|
|
break;
|
2002-12-24 02:03:04 +01:00
|
|
|
|
2003-01-03 22:08:50 +01:00
|
|
|
case D3DRENDERSTATE_DIFFUSEMATERIALSOURCE: /* 145 */
|
2003-01-03 22:03:15 +01:00
|
|
|
case D3DRENDERSTATE_SPECULARMATERIALSOURCE: /* 146 */
|
|
|
|
case D3DRENDERSTATE_AMBIENTMATERIALSOURCE: /* 147 */
|
|
|
|
case D3DRENDERSTATE_EMISSIVEMATERIALSOURCE: /* 148 */
|
2003-01-08 00:08:31 +01:00
|
|
|
/* Nothing to do here. Only the storage matters :-) */
|
2003-01-03 22:03:15 +01:00
|
|
|
break;
|
|
|
|
|
2002-11-21 22:04:16 +01:00
|
|
|
default:
|
2003-05-12 05:09:17 +02:00
|
|
|
ERR("Unhandled dwRenderStateType %s (%08x) value : %08lx !\n",
|
|
|
|
_get_renderstate(dwRenderStateType), dwRenderStateType, dwRenderState);
|
2002-11-21 22:04:16 +01:00
|
|
|
}
|
|
|
|
LEAVE_GL();
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
}
|
2003-01-03 22:08:50 +01:00
|
|
|
|
2003-01-08 00:08:31 +01:00
|
|
|
void store_render_state(IDirect3DDeviceImpl *This,
|
|
|
|
D3DRENDERSTATETYPE dwRenderStateType, DWORD dwRenderState, STATEBLOCK *lpStateBlock)
|
2003-01-03 22:08:50 +01:00
|
|
|
{
|
|
|
|
TRACE("%s = %08lx\n", _get_renderstate(dwRenderStateType), dwRenderState);
|
2003-01-08 00:08:31 +01:00
|
|
|
|
|
|
|
/* Some special cases first.. */
|
|
|
|
if (dwRenderStateType == D3DRENDERSTATE_SRCBLEND) {
|
|
|
|
if (dwRenderState == D3DBLEND_BOTHSRCALPHA) {
|
|
|
|
lpStateBlock->render_state[D3DRENDERSTATE_SRCBLEND - 1] = D3DBLEND_SRCALPHA;
|
2004-03-27 02:36:26 +01:00
|
|
|
lpStateBlock->render_state[D3DRENDERSTATE_DESTBLEND - 1] = D3DBLEND_INVSRCALPHA;
|
2003-01-08 00:08:31 +01:00
|
|
|
return;
|
|
|
|
} else if (dwRenderState == D3DBLEND_BOTHINVSRCALPHA) {
|
|
|
|
lpStateBlock->render_state[D3DRENDERSTATE_SRCBLEND - 1] = D3DBLEND_INVSRCALPHA;
|
2004-03-27 02:36:26 +01:00
|
|
|
lpStateBlock->render_state[D3DRENDERSTATE_DESTBLEND - 1] = D3DBLEND_SRCALPHA;
|
2003-01-08 00:08:31 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else if (dwRenderStateType == D3DRENDERSTATE_TEXTUREADDRESS) {
|
|
|
|
lpStateBlock->render_state[D3DRENDERSTATE_TEXTUREADDRESSU - 1] = dwRenderState;
|
|
|
|
lpStateBlock->render_state[D3DRENDERSTATE_TEXTUREADDRESSV - 1] = dwRenderState;
|
2003-05-17 20:30:27 +02:00
|
|
|
} else if (dwRenderStateType == D3DRENDERSTATE_WRAPU) {
|
|
|
|
if (dwRenderState)
|
|
|
|
lpStateBlock->render_state[D3DRENDERSTATE_WRAP0] |= D3DWRAP_U;
|
|
|
|
else
|
|
|
|
lpStateBlock->render_state[D3DRENDERSTATE_WRAP0] &= ~D3DWRAP_U;
|
|
|
|
} else if (dwRenderStateType == D3DRENDERSTATE_WRAPV) {
|
|
|
|
if (dwRenderState)
|
|
|
|
lpStateBlock->render_state[D3DRENDERSTATE_WRAP0] |= D3DWRAP_V;
|
|
|
|
else
|
|
|
|
lpStateBlock->render_state[D3DRENDERSTATE_WRAP0] &= ~D3DWRAP_V;
|
2003-01-08 00:08:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Default case */
|
|
|
|
lpStateBlock->render_state[dwRenderStateType - 1] = dwRenderState;
|
2003-01-03 22:08:50 +01:00
|
|
|
}
|
|
|
|
|
2003-01-08 00:08:31 +01:00
|
|
|
void get_render_state(IDirect3DDeviceImpl *This,
|
|
|
|
D3DRENDERSTATETYPE dwRenderStateType, LPDWORD lpdwRenderState, STATEBLOCK *lpStateBlock)
|
2003-01-03 22:08:50 +01:00
|
|
|
{
|
2003-01-08 00:08:31 +01:00
|
|
|
*lpdwRenderState = lpStateBlock->render_state[dwRenderStateType - 1];
|
2003-01-03 22:08:50 +01:00
|
|
|
if (TRACE_ON(ddraw))
|
|
|
|
TRACE("%s = %08lx\n", _get_renderstate(dwRenderStateType), *lpdwRenderState);
|
|
|
|
}
|
|
|
|
|
2003-01-08 00:08:31 +01:00
|
|
|
void apply_render_state(IDirect3DDeviceImpl *This, STATEBLOCK *lpStateBlock)
|
2003-01-03 22:08:50 +01:00
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
TRACE("(%p,%p)\n", This, lpStateBlock);
|
2003-01-08 00:08:31 +01:00
|
|
|
for(i = 0; i < HIGHEST_RENDER_STATE; i++)
|
2003-01-03 22:08:50 +01:00
|
|
|
if (lpStateBlock->set_flags.render_state[i])
|
2003-01-08 00:08:31 +01:00
|
|
|
set_render_state(This, i + 1, lpStateBlock);
|
2003-01-03 22:08:50 +01:00
|
|
|
}
|
2003-06-05 01:22:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Texture management code.
|
|
|
|
|
|
|
|
- upload_surface_to_tex_memory_init initialize the code and computes the GL formats
|
|
|
|
according to the surface description.
|
|
|
|
|
|
|
|
- upload_surface_to_tex_memory does the real upload. If one buffer is split over
|
|
|
|
multiple textures, this can be called multiple times after the '_init' call. 'rect'
|
|
|
|
can be NULL if the whole buffer needs to be upload.
|
|
|
|
|
|
|
|
- upload_surface_to_tex_memory_release does the clean-up.
|
|
|
|
|
|
|
|
These functions are called in the following cases :
|
|
|
|
- texture management (ie to upload a D3D texture to GL when it changes).
|
|
|
|
- flush of the 'in-memory' frame buffer to the GL frame buffer using the texture
|
|
|
|
engine.
|
|
|
|
- use of the texture engine to simulate Blits to the 3D Device.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
NO_CONVERSION,
|
|
|
|
CONVERT_PALETTED,
|
|
|
|
CONVERT_CK_565,
|
|
|
|
CONVERT_CK_5551,
|
|
|
|
CONVERT_CK_4444,
|
|
|
|
CONVERT_CK_4444_ARGB,
|
|
|
|
CONVERT_CK_1555,
|
|
|
|
CONVERT_555,
|
|
|
|
CONVERT_CK_RGB24,
|
|
|
|
CONVERT_CK_8888,
|
|
|
|
CONVERT_CK_8888_ARGB,
|
|
|
|
CONVERT_RGB32_888
|
|
|
|
} CONVERT_TYPES;
|
|
|
|
|
|
|
|
/* Note : we suppose that all the code calling this is protected by the GL lock... Otherwise bad things
|
|
|
|
may happen :-) */
|
|
|
|
static GLenum current_format;
|
|
|
|
static GLenum current_pixel_format;
|
|
|
|
static CONVERT_TYPES convert_type;
|
|
|
|
static IDirectDrawSurfaceImpl *current_surface;
|
|
|
|
static GLuint current_level;
|
2003-06-05 01:26:53 +02:00
|
|
|
static DWORD current_tex_width;
|
|
|
|
static DWORD current_tex_height;
|
2003-07-11 05:50:43 +02:00
|
|
|
static GLuint current_alignement_constraints;
|
2003-06-23 05:34:34 +02:00
|
|
|
static int current_storage_width;
|
2003-06-05 01:22:13 +02:00
|
|
|
|
|
|
|
HRESULT upload_surface_to_tex_memory_init(IDirectDrawSurfaceImpl *surf_ptr, GLuint level, GLenum *current_internal_format,
|
2003-06-05 01:24:59 +02:00
|
|
|
BOOLEAN need_to_alloc, BOOLEAN need_alpha_ck, DWORD tex_width, DWORD tex_height)
|
2003-06-05 01:22:13 +02:00
|
|
|
{
|
|
|
|
const DDPIXELFORMAT * const src_pf = &(surf_ptr->surface_desc.u4.ddpfPixelFormat);
|
|
|
|
BOOL error = FALSE;
|
|
|
|
BOOL colorkey_active = need_alpha_ck && (surf_ptr->surface_desc.dwFlags & DDSD_CKSRCBLT);
|
|
|
|
GLenum internal_format = GL_LUMINANCE; /* A bogus value to be sure to have a nice Mesa warning :-) */
|
2003-06-05 01:24:59 +02:00
|
|
|
BYTE bpp = GET_BPP(surf_ptr->surface_desc);
|
2003-06-05 01:43:29 +02:00
|
|
|
BOOL sub_texture = TRUE;
|
2003-06-23 05:34:34 +02:00
|
|
|
|
2003-06-05 01:22:13 +02:00
|
|
|
current_surface = surf_ptr;
|
|
|
|
current_level = level;
|
|
|
|
|
2004-07-30 20:54:32 +02:00
|
|
|
if (src_pf->dwFlags & DDPF_FOURCC) {
|
|
|
|
GLenum retVal;
|
|
|
|
int size = surf_ptr->surface_desc.u1.dwLinearSize;
|
|
|
|
int width = surf_ptr->surface_desc.dwWidth;
|
|
|
|
int height = surf_ptr->surface_desc.dwHeight;
|
|
|
|
LPVOID buffer = surf_ptr->surface_desc.lpSurface;
|
|
|
|
|
|
|
|
switch (src_pf->dwFourCC) {
|
|
|
|
case MAKE_FOURCC('D','X','T','1'): retVal = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; break;
|
|
|
|
case MAKE_FOURCC('D','X','T','3'): retVal = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; break;
|
|
|
|
case MAKE_FOURCC('D','X','T','5'): retVal = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; break;
|
|
|
|
default:
|
|
|
|
FIXME("FourCC Not supported\n");
|
|
|
|
return DD_OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GL_extensions.s3tc_compressed_texture) {
|
|
|
|
GL_extensions.glCompressedTexImage2D(GL_TEXTURE_2D, current_level, retVal, width, height, 0, size, buffer);
|
|
|
|
} else
|
|
|
|
ERR("Trying to upload S3TC texture whereas the device does not have support for it\n");
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2003-06-05 01:24:59 +02:00
|
|
|
/* First, do some sanity checks ... */
|
|
|
|
if ((surf_ptr->surface_desc.u1.lPitch % bpp) != 0) {
|
|
|
|
FIXME("Warning : pitch is not a multiple of BPP - not supported yet !\n");
|
2003-07-11 05:50:43 +02:00
|
|
|
} else {
|
|
|
|
/* In that case, no need to have any alignement constraints... */
|
|
|
|
if (current_alignement_constraints != 1) {
|
|
|
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
|
|
|
current_alignement_constraints = 1;
|
|
|
|
}
|
2003-06-05 01:24:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Note: we only check width here as you cannot have width non-zero while height is set to zero */
|
2003-06-05 01:43:29 +02:00
|
|
|
if (tex_width == 0) {
|
|
|
|
sub_texture = FALSE;
|
|
|
|
|
2003-06-05 01:24:59 +02:00
|
|
|
tex_width = surf_ptr->surface_desc.dwWidth;
|
|
|
|
tex_height = surf_ptr->surface_desc.dwHeight;
|
|
|
|
}
|
|
|
|
|
2003-06-05 01:26:53 +02:00
|
|
|
current_tex_width = tex_width;
|
|
|
|
current_tex_height = tex_height;
|
|
|
|
|
2003-06-05 01:22:13 +02:00
|
|
|
if (src_pf->dwFlags & DDPF_PALETTEINDEXED8) {
|
|
|
|
/* ****************
|
|
|
|
Paletted Texture
|
|
|
|
**************** */
|
|
|
|
current_format = GL_RGBA;
|
|
|
|
internal_format = GL_RGBA;
|
|
|
|
current_pixel_format = GL_UNSIGNED_BYTE;
|
|
|
|
convert_type = CONVERT_PALETTED;
|
|
|
|
} else if (src_pf->dwFlags & DDPF_RGB) {
|
|
|
|
/* ************
|
|
|
|
RGB Textures
|
|
|
|
************ */
|
|
|
|
if (src_pf->u1.dwRGBBitCount == 8) {
|
2003-06-05 01:36:48 +02:00
|
|
|
if ((src_pf->dwFlags & DDPF_ALPHAPIXELS) &&
|
|
|
|
(src_pf->u5.dwRGBAlphaBitMask != 0x00)) {
|
2003-06-05 01:22:13 +02:00
|
|
|
error = TRUE;
|
2003-06-05 01:36:48 +02:00
|
|
|
} 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 :-) */
|
2004-01-27 01:01:43 +01:00
|
|
|
FIXME(" ColorKeying not supported in the RGB 332 format !\n");
|
2003-06-05 01:36:48 +02:00
|
|
|
}
|
2003-06-05 01:22:13 +02:00
|
|
|
current_format = GL_RGB;
|
|
|
|
internal_format = GL_RGB;
|
2003-06-05 01:36:48 +02:00
|
|
|
current_pixel_format = GL_UNSIGNED_BYTE_3_3_2;
|
2003-06-05 01:22:13 +02:00
|
|
|
convert_type = NO_CONVERSION;
|
|
|
|
} else {
|
2003-06-05 01:36:48 +02:00
|
|
|
error = TRUE;
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
2003-06-05 01:36:48 +02:00
|
|
|
}
|
|
|
|
} else if (src_pf->u1.dwRGBBitCount == 16) {
|
|
|
|
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;
|
|
|
|
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)) {
|
2003-06-05 01:22:13 +02:00
|
|
|
current_format = GL_RGBA;
|
|
|
|
internal_format = GL_RGBA;
|
|
|
|
current_pixel_format = GL_UNSIGNED_SHORT_4_4_4_4;
|
2003-06-05 01:36:48 +02:00
|
|
|
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;
|
|
|
|
}
|
2003-06-05 01:22:13 +02:00
|
|
|
} else {
|
2003-06-05 01:36:48 +02:00
|
|
|
error = TRUE;
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
2003-06-05 01:36:48 +02:00
|
|
|
} 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;
|
2003-06-05 01:22:13 +02:00
|
|
|
current_format = GL_RGBA;
|
|
|
|
internal_format = GL_RGBA;
|
|
|
|
current_pixel_format = GL_UNSIGNED_SHORT_5_5_5_1;
|
|
|
|
} else {
|
2003-06-05 01:36:48 +02:00
|
|
|
error = TRUE;
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (src_pf->u1.dwRGBBitCount == 24) {
|
2003-06-05 01:36:48 +02:00
|
|
|
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;
|
|
|
|
}
|
2003-06-05 01:22:13 +02:00
|
|
|
} else {
|
2003-06-05 01:36:48 +02:00
|
|
|
error = TRUE;
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (src_pf->u1.dwRGBBitCount == 32) {
|
2003-06-05 01:36:48 +02:00
|
|
|
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;
|
|
|
|
}
|
2003-06-05 01:22:13 +02:00
|
|
|
current_format = GL_RGBA;
|
|
|
|
internal_format = GL_RGBA;
|
|
|
|
current_pixel_format = GL_UNSIGNED_INT_8_8_8_8;
|
2003-06-05 01:36:48 +02:00
|
|
|
} 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;
|
|
|
|
}
|
2003-06-05 01:22:13 +02:00
|
|
|
} else {
|
2003-06-05 01:36:48 +02:00
|
|
|
error = TRUE;
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
2003-06-05 01:36:48 +02:00
|
|
|
} else {
|
|
|
|
if ((src_pf->u2.dwRBitMask == 0x00FF0000) &&
|
|
|
|
(src_pf->u3.dwGBitMask == 0x0000FF00) &&
|
|
|
|
(src_pf->u4.dwBBitMask == 0x000000FF)) {
|
2004-12-09 15:07:59 +01:00
|
|
|
if (need_alpha_ck) {
|
2003-06-05 01:36:48 +02:00
|
|
|
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;
|
|
|
|
}
|
2003-06-05 01:22:13 +02:00
|
|
|
} else {
|
2003-06-05 01:36:48 +02:00
|
|
|
error = TRUE;
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
error = TRUE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
error = TRUE;
|
|
|
|
}
|
|
|
|
|
2004-12-09 15:07:59 +01:00
|
|
|
if (error) {
|
2003-06-05 01:36:48 +02:00
|
|
|
ERR("Unsupported pixel format for textures : \n");
|
2003-06-05 01:22:13 +02:00
|
|
|
if (ERR_ON(ddraw)) {
|
|
|
|
DDRAW_dump_pixelformat(src_pf);
|
|
|
|
}
|
|
|
|
return DDERR_INVALIDPIXELFORMAT;
|
|
|
|
} else {
|
|
|
|
if ((need_to_alloc) ||
|
|
|
|
(internal_format != *current_internal_format)) {
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, level, internal_format,
|
2003-06-05 01:24:59 +02:00
|
|
|
tex_width, tex_height, 0,
|
2003-06-05 01:22:13 +02:00
|
|
|
current_format, current_pixel_format, NULL);
|
|
|
|
*current_internal_format = internal_format;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-09 15:07:59 +01:00
|
|
|
if (sub_texture && (convert_type == NO_CONVERSION)) {
|
2003-06-23 05:34:34 +02:00
|
|
|
current_storage_width = surf_ptr->surface_desc.u1.lPitch / bpp;
|
2003-06-05 01:43:29 +02:00
|
|
|
} else {
|
|
|
|
if (surf_ptr->surface_desc.u1.lPitch == (surf_ptr->surface_desc.dwWidth * bpp)) {
|
2003-06-23 05:34:34 +02:00
|
|
|
current_storage_width = 0;
|
2003-06-05 01:43:29 +02:00
|
|
|
} else {
|
2003-06-23 05:34:34 +02:00
|
|
|
current_storage_width = surf_ptr->surface_desc.u1.lPitch / bpp;
|
|
|
|
}
|
2003-06-05 01:43:29 +02:00
|
|
|
}
|
2003-06-23 05:34:34 +02:00
|
|
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, current_storage_width);
|
|
|
|
|
2003-11-17 21:02:33 +01:00
|
|
|
TRACE(" initialized texture upload for level %d with conversion %d.\n", current_level, convert_type);
|
|
|
|
|
2003-06-05 01:22:13 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2003-06-05 01:26:53 +02:00
|
|
|
HRESULT upload_surface_to_tex_memory(RECT *rect, DWORD xoffset, DWORD yoffset, void **temp_buffer)
|
2003-06-05 01:22:13 +02:00
|
|
|
{
|
|
|
|
const DDSURFACEDESC * const src_d = (DDSURFACEDESC *)&(current_surface->surface_desc);
|
|
|
|
void *surf_buffer = NULL;
|
2003-06-05 01:26:53 +02:00
|
|
|
RECT lrect;
|
|
|
|
DWORD width, height;
|
|
|
|
BYTE bpp = GET_BPP(current_surface->surface_desc);
|
2003-06-05 01:43:29 +02:00
|
|
|
int line_increase;
|
|
|
|
|
2003-06-05 01:26:53 +02:00
|
|
|
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;
|
2003-06-05 01:24:59 +02:00
|
|
|
|
2004-07-30 20:54:32 +02:00
|
|
|
if (current_surface->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_FOURCC) {
|
|
|
|
GLint retVal;
|
|
|
|
int size = current_surface->surface_desc.u1.dwLinearSize;
|
|
|
|
int width_ = current_surface->surface_desc.dwWidth;
|
|
|
|
int height_ = current_surface->surface_desc.dwHeight;
|
|
|
|
LPVOID buffer = current_surface->surface_desc.lpSurface;
|
|
|
|
|
|
|
|
switch (current_surface->surface_desc.u4.ddpfPixelFormat.dwFourCC) {
|
|
|
|
case MAKE_FOURCC('D','X','T','1'): retVal = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; break;
|
|
|
|
case MAKE_FOURCC('D','X','T','3'): retVal = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; break;
|
|
|
|
case MAKE_FOURCC('D','X','T','5'): retVal = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; break;
|
|
|
|
default:
|
|
|
|
FIXME("Not supported\n");
|
|
|
|
return DD_OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GL_extensions.s3tc_compressed_texture) {
|
|
|
|
/* GL_extensions.glCompressedTexSubImage2D(GL_TEXTURE_2D, current_level, xoffset, yoffset, width, height, retVal, (unsigned char*)temp_buffer); */
|
|
|
|
GL_extensions.glCompressedTexImage2D(GL_TEXTURE_2D, current_level, retVal, width_, height_, 0, size, buffer);
|
|
|
|
} else
|
|
|
|
ERR("Trying to upload S3TC texture whereas the device does not have support for it\n");
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2003-06-05 01:43:29 +02:00
|
|
|
/* Used when converting stuff */
|
2003-07-11 05:50:43 +02:00
|
|
|
line_increase = src_d->u1.lPitch - (width * bpp);
|
2003-11-11 01:31:16 +01:00
|
|
|
|
2003-06-05 01:22:13 +02:00
|
|
|
switch (convert_type) {
|
|
|
|
case CONVERT_PALETTED: {
|
|
|
|
IDirectDrawPaletteImpl* pal = current_surface->palette;
|
|
|
|
BYTE table[256][4];
|
2004-09-08 03:23:57 +02:00
|
|
|
unsigned int i;
|
|
|
|
unsigned int x, y;
|
2003-06-05 01:26:53 +02:00
|
|
|
BYTE *src = (BYTE *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
|
|
|
|
|
2003-06-05 01:22:13 +02:00
|
|
|
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");
|
|
|
|
memset(table, 0, 256 * 4);
|
|
|
|
} else {
|
|
|
|
/* Get the surface's palette */
|
|
|
|
for (i = 0; i < 256; i++) {
|
|
|
|
table[i][0] = pal->palents[i].peRed;
|
|
|
|
table[i][1] = pal->palents[i].peGreen;
|
|
|
|
table[i][2] = pal->palents[i].peBlue;
|
|
|
|
if ((src_d->dwFlags & DDSD_CKSRCBLT) &&
|
|
|
|
(i >= src_d->ddckCKSrcBlt.dwColorSpaceLowValue) &&
|
|
|
|
(i <= src_d->ddckCKSrcBlt.dwColorSpaceHighValue))
|
|
|
|
/* We should maybe here put a more 'neutral' color than the standard bright purple
|
|
|
|
one often used by application to prevent the nice purple borders when bi-linear
|
|
|
|
filtering is on */
|
|
|
|
table[i][3] = 0x00;
|
|
|
|
else
|
|
|
|
table[i][3] = 0xFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*temp_buffer == NULL)
|
|
|
|
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
2003-06-05 01:26:53 +02:00
|
|
|
current_tex_width * current_tex_height * sizeof(DWORD));
|
2003-06-05 01:22:13 +02:00
|
|
|
dst = (BYTE *) *temp_buffer;
|
2003-06-05 01:43:29 +02:00
|
|
|
|
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = 0; x < width; x++) {
|
|
|
|
BYTE color = *src++;
|
|
|
|
*dst++ = table[color][0];
|
|
|
|
*dst++ = table[color][1];
|
|
|
|
*dst++ = table[color][2];
|
|
|
|
*dst++ = table[color][3];
|
|
|
|
}
|
|
|
|
src += line_increase;
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case CONVERT_CK_565: {
|
|
|
|
/* Converting the 565 format in 5551 packed to emulate color-keying.
|
|
|
|
|
|
|
|
Note : in all these conversion, it would be best to average the averaging
|
|
|
|
pixels to get the color of the pixel that will be color-keyed to
|
|
|
|
prevent 'color bleeding'. This will be done later on if ever it is
|
|
|
|
too visible.
|
|
|
|
|
|
|
|
Note2: when using color-keying + alpha, are the alpha bits part of the
|
|
|
|
color-space or not ?
|
|
|
|
*/
|
2004-09-08 03:23:57 +02:00
|
|
|
unsigned int x, y;
|
2003-06-05 01:26:53 +02:00
|
|
|
WORD *src = (WORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
|
2003-06-05 01:22:13 +02:00
|
|
|
|
2003-06-05 01:31:39 +02:00
|
|
|
if (*temp_buffer == NULL)
|
2003-06-05 01:22:13 +02:00
|
|
|
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
2003-06-05 01:26:53 +02:00
|
|
|
current_tex_width * current_tex_height * sizeof(WORD));
|
2003-06-05 01:22:13 +02:00
|
|
|
dst = (WORD *) *temp_buffer;
|
|
|
|
|
2003-06-05 01:43:29 +02:00
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = 0; x < width; x++) {
|
|
|
|
WORD color = *src++;
|
2003-11-11 01:31:16 +01:00
|
|
|
*dst = ((color & 0xFFC0) | ((color & 0x1F) << 1));
|
2003-06-05 01:43:29 +02:00
|
|
|
if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
|
|
|
|
(color > src_d->ddckCKSrcBlt.dwColorSpaceHighValue))
|
|
|
|
*dst |= 0x0001;
|
|
|
|
dst++;
|
|
|
|
}
|
2003-07-11 05:50:43 +02:00
|
|
|
src = (WORD *) (((BYTE *) src) + line_increase);
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case CONVERT_CK_5551: {
|
|
|
|
/* Change the alpha value of the color-keyed pixels to emulate color-keying. */
|
2004-09-08 03:23:57 +02:00
|
|
|
unsigned int x, y;
|
2003-06-05 01:26:53 +02:00
|
|
|
WORD *src = (WORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
|
2003-06-05 01:22:13 +02:00
|
|
|
|
2003-06-05 01:31:39 +02:00
|
|
|
if (*temp_buffer == NULL)
|
2003-06-05 01:22:13 +02:00
|
|
|
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
2003-06-05 01:26:53 +02:00
|
|
|
current_tex_width * current_tex_height * sizeof(WORD));
|
2003-06-05 01:22:13 +02:00
|
|
|
dst = (WORD *) *temp_buffer;
|
|
|
|
|
2003-06-05 01:43:29 +02:00
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = 0; x < width; x++) {
|
|
|
|
WORD color = *src++;
|
|
|
|
*dst = color & 0xFFFE;
|
|
|
|
if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
|
|
|
|
(color > src_d->ddckCKSrcBlt.dwColorSpaceHighValue))
|
|
|
|
*dst |= color & 0x0001;
|
|
|
|
dst++;
|
|
|
|
}
|
2003-07-11 05:50:43 +02:00
|
|
|
src = (WORD *) (((BYTE *) src) + line_increase);
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case CONVERT_CK_4444: {
|
|
|
|
/* Change the alpha value of the color-keyed pixels to emulate color-keying. */
|
2004-09-08 03:23:57 +02:00
|
|
|
unsigned int x, y;
|
2003-06-05 01:26:53 +02:00
|
|
|
WORD *src = (WORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
|
2003-06-05 01:22:13 +02:00
|
|
|
|
2003-06-05 01:31:39 +02:00
|
|
|
if (*temp_buffer == NULL)
|
2003-06-05 01:22:13 +02:00
|
|
|
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
2003-06-05 01:26:53 +02:00
|
|
|
current_tex_width * current_tex_height * sizeof(WORD));
|
2003-06-05 01:22:13 +02:00
|
|
|
dst = (WORD *) *temp_buffer;
|
|
|
|
|
2003-06-05 01:43:29 +02:00
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = 0; x < width; x++) {
|
|
|
|
WORD color = *src++;
|
|
|
|
*dst = color & 0xFFF0;
|
|
|
|
if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
|
|
|
|
(color > src_d->ddckCKSrcBlt.dwColorSpaceHighValue))
|
|
|
|
*dst |= color & 0x000F;
|
|
|
|
dst++;
|
|
|
|
}
|
2003-07-11 05:50:43 +02:00
|
|
|
src = (WORD *) (((BYTE *) src) + line_increase);
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case CONVERT_CK_4444_ARGB: {
|
|
|
|
/* Move the four Alpha bits... */
|
2004-09-08 03:23:57 +02:00
|
|
|
unsigned int x, y;
|
2003-06-05 01:26:53 +02:00
|
|
|
WORD *src = (WORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
|
2003-06-05 01:22:13 +02:00
|
|
|
|
2003-06-05 01:38:22 +02:00
|
|
|
if (*temp_buffer == NULL)
|
2003-06-05 01:22:13 +02:00
|
|
|
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
2003-06-05 01:26:53 +02:00
|
|
|
current_tex_width * current_tex_height * sizeof(WORD));
|
2003-06-05 01:22:13 +02:00
|
|
|
dst = (WORD *) *temp_buffer;
|
|
|
|
|
2003-06-05 01:43:29 +02:00
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = 0; x < width; x++) {
|
|
|
|
WORD color = *src++;
|
|
|
|
*dst = (color & 0x0FFF) << 4;
|
|
|
|
if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
|
|
|
|
(color > src_d->ddckCKSrcBlt.dwColorSpaceHighValue))
|
|
|
|
*dst |= (color & 0xF000) >> 12;
|
|
|
|
dst++;
|
|
|
|
}
|
2003-07-11 05:50:43 +02:00
|
|
|
src = (WORD *) (((BYTE *) src) + line_increase);
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case CONVERT_CK_1555: {
|
2004-09-08 03:23:57 +02:00
|
|
|
unsigned int x, y;
|
2003-06-05 01:26:53 +02:00
|
|
|
WORD *src = (WORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
|
2003-06-05 01:22:13 +02:00
|
|
|
|
2003-06-05 01:31:39 +02:00
|
|
|
if (*temp_buffer == NULL)
|
2003-06-05 01:22:13 +02:00
|
|
|
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
2003-06-05 01:26:53 +02:00
|
|
|
current_tex_width * current_tex_height * sizeof(WORD));
|
2003-06-05 01:22:13 +02:00
|
|
|
dst = (WORD *) *temp_buffer;
|
|
|
|
|
2003-06-05 01:43:29 +02:00
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = 0; x < width; x++) {
|
|
|
|
WORD color = *src++;
|
|
|
|
*dst = (color & 0x7FFF) << 1;
|
|
|
|
if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
|
|
|
|
(color > src_d->ddckCKSrcBlt.dwColorSpaceHighValue))
|
|
|
|
*dst |= (color & 0x8000) >> 15;
|
|
|
|
dst++;
|
|
|
|
}
|
2003-07-11 05:50:43 +02:00
|
|
|
src = (WORD *) (((BYTE *) src) + line_increase);
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case CONVERT_555: {
|
|
|
|
/* Converting the 0555 format in 5551 packed */
|
2004-09-08 03:23:57 +02:00
|
|
|
unsigned int x, y;
|
2003-06-05 01:26:53 +02:00
|
|
|
WORD *src = (WORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
|
2003-06-05 01:22:13 +02:00
|
|
|
|
2003-06-05 01:31:39 +02:00
|
|
|
if (*temp_buffer == NULL)
|
2003-06-05 01:22:13 +02:00
|
|
|
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
2003-06-05 01:26:53 +02:00
|
|
|
current_tex_width * current_tex_height * sizeof(WORD));
|
2003-06-05 01:22:13 +02:00
|
|
|
dst = (WORD *) *temp_buffer;
|
|
|
|
|
|
|
|
if (src_d->dwFlags & DDSD_CKSRCBLT) {
|
2003-06-05 01:43:29 +02:00
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = 0; x < width; x++) {
|
|
|
|
WORD color = *src++;
|
|
|
|
*dst = (color & 0x7FFF) << 1;
|
|
|
|
if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
|
|
|
|
(color > src_d->ddckCKSrcBlt.dwColorSpaceHighValue))
|
|
|
|
*dst |= 0x0001;
|
|
|
|
dst++;
|
|
|
|
}
|
2003-07-11 05:50:43 +02:00
|
|
|
src = (WORD *) (((BYTE *) src) + line_increase);
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
|
|
|
} else {
|
2003-06-05 01:43:29 +02:00
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = 0; x < width; x++) {
|
|
|
|
WORD color = *src++;
|
|
|
|
*dst++ = ((color & 0x7FFF) << 1) | 0x0001;
|
|
|
|
}
|
2003-07-11 05:50:43 +02:00
|
|
|
src = (WORD *) (((BYTE *) src) + line_increase);
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case CONVERT_CK_RGB24: {
|
|
|
|
/* This is a pain :-) */
|
2004-09-08 03:23:57 +02:00
|
|
|
unsigned int x, y;
|
2003-06-05 01:26:53 +02:00
|
|
|
BYTE *src = (BYTE *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top));
|
2003-06-05 01:22:13 +02:00
|
|
|
DWORD *dst;
|
2004-11-19 19:05:15 +01:00
|
|
|
|
2003-06-05 01:31:39 +02:00
|
|
|
if (*temp_buffer == NULL)
|
2003-06-05 01:22:13 +02:00
|
|
|
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
2003-06-05 01:26:53 +02:00
|
|
|
current_tex_width * current_tex_height * sizeof(DWORD));
|
2003-06-05 01:22:13 +02:00
|
|
|
dst = (DWORD *) *temp_buffer;
|
|
|
|
|
2003-06-05 01:43:29 +02:00
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = 0; x < width; x++) {
|
|
|
|
DWORD color = *((DWORD *) src) & 0x00FFFFFF;
|
|
|
|
src += 3;
|
2004-11-19 19:05:15 +01:00
|
|
|
*dst = color << 8;
|
2003-06-05 01:43:29 +02:00
|
|
|
if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
|
|
|
|
(color > src_d->ddckCKSrcBlt.dwColorSpaceHighValue))
|
|
|
|
*dst |= 0xFF;
|
|
|
|
dst++;
|
|
|
|
}
|
2003-07-11 05:50:43 +02:00
|
|
|
src += line_increase;
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case CONVERT_CK_8888: {
|
|
|
|
/* Just use the alpha component to handle color-keying... */
|
2004-09-08 03:23:57 +02:00
|
|
|
unsigned int x, y;
|
2003-06-05 01:26:53 +02:00
|
|
|
DWORD *src = (DWORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
|
2003-06-05 01:22:13 +02:00
|
|
|
|
2003-06-05 01:31:39 +02:00
|
|
|
if (*temp_buffer == NULL)
|
2003-06-05 01:22:13 +02:00
|
|
|
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
2003-06-05 01:26:53 +02:00
|
|
|
current_tex_width * current_tex_height * sizeof(DWORD));
|
2003-06-05 01:22:13 +02:00
|
|
|
dst = (DWORD *) *temp_buffer;
|
|
|
|
|
2003-06-05 01:43:29 +02:00
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = 0; x < width; x++) {
|
|
|
|
DWORD color = *src++;
|
|
|
|
*dst = color & 0xFFFFFF00;
|
|
|
|
if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
|
|
|
|
(color > src_d->ddckCKSrcBlt.dwColorSpaceHighValue))
|
|
|
|
*dst |= color & 0x000000FF;
|
|
|
|
dst++;
|
|
|
|
}
|
2003-07-11 05:50:43 +02:00
|
|
|
src = (DWORD *) (((BYTE *) src) + line_increase);
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case CONVERT_CK_8888_ARGB: {
|
2004-09-08 03:23:57 +02:00
|
|
|
unsigned int x, y;
|
2003-06-05 01:26:53 +02:00
|
|
|
DWORD *src = (DWORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
|
2003-06-05 01:22:13 +02:00
|
|
|
|
2003-06-05 01:31:39 +02:00
|
|
|
if (*temp_buffer == NULL)
|
2003-06-05 01:22:13 +02:00
|
|
|
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
2003-06-05 01:26:53 +02:00
|
|
|
current_tex_width * current_tex_height * sizeof(DWORD));
|
2003-06-05 01:22:13 +02:00
|
|
|
dst = (DWORD *) *temp_buffer;
|
|
|
|
|
2003-06-05 01:43:29 +02:00
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = 0; x < width; x++) {
|
|
|
|
DWORD color = *src++;
|
|
|
|
*dst = (color & 0x00FFFFFF) << 8;
|
|
|
|
if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
|
|
|
|
(color > src_d->ddckCKSrcBlt.dwColorSpaceHighValue))
|
|
|
|
*dst |= (color & 0xFF000000) >> 24;
|
|
|
|
dst++;
|
|
|
|
}
|
2003-07-11 05:50:43 +02:00
|
|
|
src = (DWORD *) (((BYTE *) src) + line_increase);
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case CONVERT_RGB32_888: {
|
|
|
|
/* Just add an alpha component and handle color-keying... */
|
2004-09-08 03:23:57 +02:00
|
|
|
unsigned int x, y;
|
2003-06-05 01:26:53 +02:00
|
|
|
DWORD *src = (DWORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst;
|
2003-06-05 01:22:13 +02:00
|
|
|
|
2003-06-05 01:31:39 +02:00
|
|
|
if (*temp_buffer == NULL)
|
2003-06-05 01:22:13 +02:00
|
|
|
*temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
2003-06-05 01:26:53 +02:00
|
|
|
current_tex_width * current_tex_height * sizeof(DWORD));
|
2003-06-05 01:22:13 +02:00
|
|
|
dst = (DWORD *) *temp_buffer;
|
|
|
|
|
|
|
|
if (src_d->dwFlags & DDSD_CKSRCBLT) {
|
2003-06-05 01:43:29 +02:00
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = 0; x < width; x++) {
|
|
|
|
DWORD color = *src++;
|
|
|
|
*dst = color << 8;
|
|
|
|
if ((color < src_d->ddckCKSrcBlt.dwColorSpaceLowValue) ||
|
|
|
|
(color > src_d->ddckCKSrcBlt.dwColorSpaceHighValue))
|
|
|
|
*dst |= 0xFF;
|
|
|
|
dst++;
|
|
|
|
}
|
2003-07-11 05:50:43 +02:00
|
|
|
src = (DWORD *) (((BYTE *) src) + line_increase);
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
|
|
|
} else {
|
2003-06-05 01:43:29 +02:00
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = 0; x < width; x++) {
|
|
|
|
*dst++ = (*src++ << 8) | 0xFF;
|
|
|
|
}
|
2003-07-11 05:50:43 +02:00
|
|
|
src = (DWORD *) (((BYTE *) src) + line_increase);
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case NO_CONVERSION:
|
2003-06-05 01:43:29 +02:00
|
|
|
/* Nothing to do here as the name suggests... Just set-up the buffer correctly */
|
2003-06-05 01:26:53 +02:00
|
|
|
surf_buffer = (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top));
|
2003-06-05 01:22:13 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (convert_type != NO_CONVERSION) {
|
2003-07-11 05:50:43 +02:00
|
|
|
/* When doing conversion, the storage is always of width 'width' as there will never
|
|
|
|
be any Pitch issue... For now :-)
|
|
|
|
*/
|
2003-06-05 01:22:13 +02:00
|
|
|
surf_buffer = *temp_buffer;
|
2003-07-11 05:50:43 +02:00
|
|
|
if (width != current_storage_width) {
|
|
|
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, width);
|
|
|
|
current_storage_width = width;
|
2003-06-05 01:43:29 +02:00
|
|
|
}
|
2003-06-05 01:22:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
glTexSubImage2D(GL_TEXTURE_2D,
|
|
|
|
current_level,
|
2003-06-05 01:26:53 +02:00
|
|
|
xoffset, yoffset,
|
|
|
|
width, height,
|
2003-06-05 01:22:13 +02:00
|
|
|
current_format,
|
|
|
|
current_pixel_format,
|
|
|
|
surf_buffer);
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT upload_surface_to_tex_memory_release(void)
|
|
|
|
{
|
|
|
|
current_surface = NULL;
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|