- allow application to load palette-less textures
- handle palette change of loaded textures - some changes in the ExecuteBuffer
This commit is contained in:
parent
bb9837d2a4
commit
b07df8a198
@ -217,12 +217,12 @@ static void execute(IDirect3DExecuteBufferImpl *This,
|
|||||||
|
|
||||||
switch (current->bOpcode) {
|
switch (current->bOpcode) {
|
||||||
case D3DOP_POINT: {
|
case D3DOP_POINT: {
|
||||||
TRACE("POINT-s (%d)\n", count);
|
WARN("POINT-s (%d)\n", count);
|
||||||
instr += count * size;
|
instr += count * size;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case D3DOP_LINE: {
|
case D3DOP_LINE: {
|
||||||
TRACE("LINE-s (%d)\n", count);
|
WARN("LINE-s (%d)\n", count);
|
||||||
instr += count * size;
|
instr += count * size;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -278,37 +278,31 @@ static void execute(IDirect3DExecuteBufferImpl *This,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case D3DVT_TLVERTEX: {
|
case D3DVT_TLVERTEX: {
|
||||||
GLdouble height, width, minZ, maxZ;
|
GLdouble height, width;
|
||||||
|
GLfloat trans_mat[16];
|
||||||
|
|
||||||
/* First, disable lighting */
|
/* First, disable lighting */
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
|
|
||||||
/* Then do not put any transformation matrixes */
|
width = lpDevice->surface->surface_desc.dwWidth;
|
||||||
|
height = lpDevice->surface->surface_desc.dwHeight;
|
||||||
|
|
||||||
|
/* The X axis is straighforward.. For the Y axis, we need to convert 'D3D' screen coordinates
|
||||||
|
to OpenGL screen coordinates (ie the upper left corner is not the same).
|
||||||
|
For Z, the mystery is what should it be mapped to ? Ie should the resulting range be between
|
||||||
|
-1.0 and 1.0 (as the X and Y coordinates) or between 0.0 and 1.0 ? */
|
||||||
|
trans_mat[ 0] = 2.0 / width; trans_mat[ 4] = 0.0; trans_mat[ 8] = 0.0; trans_mat[12] = -1.0;
|
||||||
|
trans_mat[ 1] = 0.0; trans_mat[ 5] = -2.0 / height; trans_mat[ 9] = 0.0; trans_mat[13] = 1.0;
|
||||||
|
trans_mat[ 2] = 0.0; trans_mat[ 6] = 0.0; trans_mat[10] = 1.0; trans_mat[14] = -1.0;
|
||||||
|
trans_mat[ 3] = 0.0; trans_mat[ 7] = 0.0; trans_mat[11] = 0.0; trans_mat[15] = 1.0;
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadMatrixf(trans_mat);
|
||||||
|
|
||||||
if (lpViewport == NULL) {
|
/* Remove also fogging... */
|
||||||
ERR("No current viewport !\n");
|
glDisable(GL_FOG);
|
||||||
/* Using standard values */
|
|
||||||
height = 640.0;
|
|
||||||
width = 480.0;
|
|
||||||
minZ = -10.0;
|
|
||||||
maxZ = 10.0;
|
|
||||||
} else {
|
|
||||||
height = (GLdouble) lpViewport->viewports.vp1.dwHeight;
|
|
||||||
width = (GLdouble) lpViewport->viewports.vp1.dwWidth;
|
|
||||||
minZ = (GLdouble) lpViewport->viewports.vp1.dvMinZ;
|
|
||||||
maxZ = (GLdouble) lpViewport->viewports.vp1.dvMaxZ;
|
|
||||||
|
|
||||||
if (minZ == maxZ) {
|
|
||||||
/* I do not know why, but many Dx 3.0 games have minZ = maxZ = 0.0 */
|
|
||||||
minZ = 0.0;
|
|
||||||
maxZ = 1.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
glOrtho(0.0, width, height, 0.0, -minZ, -maxZ);
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -335,7 +329,7 @@ static void execute(IDirect3DExecuteBufferImpl *This,
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case D3DOP_MATRIXLOAD:
|
case D3DOP_MATRIXLOAD:
|
||||||
TRACE("MATRIXLOAD-s (%d)\n", count);
|
WARN("MATRIXLOAD-s (%d)\n", count);
|
||||||
instr += count * size;
|
instr += count * size;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -440,23 +434,23 @@ static void execute(IDirect3DExecuteBufferImpl *This,
|
|||||||
} break ;
|
} break ;
|
||||||
|
|
||||||
case D3DLIGHTSTATE_COLORMODEL: {
|
case D3DLIGHTSTATE_COLORMODEL: {
|
||||||
TRACE(" COLORMODEL\n");
|
WARN(" COLORMODEL\n");
|
||||||
} break ;
|
} break ;
|
||||||
|
|
||||||
case D3DLIGHTSTATE_FOGMODE: {
|
case D3DLIGHTSTATE_FOGMODE: {
|
||||||
TRACE(" FOGMODE\n");
|
WARN(" FOGMODE\n");
|
||||||
} break ;
|
} break ;
|
||||||
|
|
||||||
case D3DLIGHTSTATE_FOGSTART: {
|
case D3DLIGHTSTATE_FOGSTART: {
|
||||||
TRACE(" FOGSTART\n");
|
WARN(" FOGSTART\n");
|
||||||
} break ;
|
} break ;
|
||||||
|
|
||||||
case D3DLIGHTSTATE_FOGEND: {
|
case D3DLIGHTSTATE_FOGEND: {
|
||||||
TRACE(" FOGEND\n");
|
WARN(" FOGEND\n");
|
||||||
} break ;
|
} break ;
|
||||||
|
|
||||||
case D3DLIGHTSTATE_FOGDENSITY: {
|
case D3DLIGHTSTATE_FOGDENSITY: {
|
||||||
TRACE(" FOGDENSITY\n");
|
WARN(" FOGDENSITY\n");
|
||||||
} break ;
|
} break ;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -605,7 +599,7 @@ static void execute(IDirect3DExecuteBufferImpl *This,
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case D3DOP_TEXTURELOAD: {
|
case D3DOP_TEXTURELOAD: {
|
||||||
TRACE("TEXTURELOAD-s (%d)\n", count);
|
WARN("TEXTURELOAD-s (%d)\n", count);
|
||||||
|
|
||||||
instr += count * size;
|
instr += count * size;
|
||||||
} break;
|
} break;
|
||||||
@ -640,7 +634,7 @@ static void execute(IDirect3DExecuteBufferImpl *This,
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case D3DOP_SPAN: {
|
case D3DOP_SPAN: {
|
||||||
TRACE("SPAN-s (%d)\n", count);
|
WARN("SPAN-s (%d)\n", count);
|
||||||
|
|
||||||
instr += count * size;
|
instr += count * size;
|
||||||
} break;
|
} break;
|
||||||
@ -737,7 +731,7 @@ Main_IDirect3DExecuteBufferImpl_1_Lock(LPDIRECT3DEXECUTEBUFFER iface,
|
|||||||
{
|
{
|
||||||
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
|
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
|
||||||
DWORD dwSize;
|
DWORD dwSize;
|
||||||
TRACE("(%p/%p)->(%p): stub!\n", This, iface, lpDesc);
|
TRACE("(%p/%p)->(%p)\n", This, iface, lpDesc);
|
||||||
|
|
||||||
dwSize = lpDesc->dwSize;
|
dwSize = lpDesc->dwSize;
|
||||||
memset(lpDesc, 0, dwSize);
|
memset(lpDesc, 0, dwSize);
|
||||||
|
@ -177,10 +177,10 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *This, BOOLEAN init_upload) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (pal == NULL) {
|
if (pal == NULL) {
|
||||||
ERR("Palettized texture Loading with a NULL palette !\n");
|
/* Upload a black texture. The real one will be uploaded on palette change */
|
||||||
glBindTexture(GL_TEXTURE_2D, current_texture);
|
WARN("Palettized texture Loading with a NULL palette !\n");
|
||||||
return D3DERR_INVALIDPALETTE;
|
memset(table, 0, 256 * 4);
|
||||||
}
|
} else {
|
||||||
/* Get the surface's palette */
|
/* Get the surface's palette */
|
||||||
for (i = 0; i < 256; i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
table[i][0] = pal->palents[i].peRed;
|
table[i][0] = pal->palents[i].peRed;
|
||||||
@ -193,6 +193,7 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *This, BOOLEAN init_upload) {
|
|||||||
else
|
else
|
||||||
table[i][3] = 0xFF;
|
table[i][3] = 0xFF;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ptr_ColorTableEXT != NULL) {
|
if (ptr_ColorTableEXT != NULL) {
|
||||||
/* use Paletted Texture Extension */
|
/* use Paletted Texture Extension */
|
||||||
@ -373,6 +374,19 @@ Main_IDirect3DTextureImpl_2_1T_Load(LPDIRECT3DTEXTURE2 iface,
|
|||||||
return DD_OK;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void gltex_set_palette(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal)
|
||||||
|
{
|
||||||
|
IDirect3DTextureGLImpl *glThis = (IDirect3DTextureGLImpl *) This->tex_private;
|
||||||
|
|
||||||
|
/* First call the previous set_palette function */
|
||||||
|
glThis->set_palette(This, pal);
|
||||||
|
|
||||||
|
/* Then re-upload the texture to OpenGL */
|
||||||
|
ENTER_GL();
|
||||||
|
gltex_upload_texture(This, glThis->first_unlock);
|
||||||
|
LEAVE_GL();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gltex_final_release(IDirectDrawSurfaceImpl *This)
|
gltex_final_release(IDirectDrawSurfaceImpl *This)
|
||||||
{
|
{
|
||||||
@ -415,12 +429,12 @@ gltex_unlock_update(IDirectDrawSurfaceImpl* This, LPCRECT pRect)
|
|||||||
{
|
{
|
||||||
IDirect3DTextureGLImpl *glThis = (IDirect3DTextureGLImpl *) This->tex_private;
|
IDirect3DTextureGLImpl *glThis = (IDirect3DTextureGLImpl *) This->tex_private;
|
||||||
|
|
||||||
|
glThis->unlock_update(This, pRect);
|
||||||
|
|
||||||
ENTER_GL();
|
ENTER_GL();
|
||||||
gltex_upload_texture(This, glThis->first_unlock);
|
gltex_upload_texture(This, glThis->first_unlock);
|
||||||
LEAVE_GL();
|
LEAVE_GL();
|
||||||
glThis->first_unlock = FALSE;
|
glThis->first_unlock = FALSE;
|
||||||
|
|
||||||
glThis->unlock_update(This, pRect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT WINAPI
|
HRESULT WINAPI
|
||||||
@ -490,7 +504,22 @@ GL_IDirect3DTextureImpl_2_1T_Load(LPDIRECT3DTEXTURE2 iface,
|
|||||||
|
|
||||||
/* Suppress the ALLOCONLOAD flag */
|
/* Suppress the ALLOCONLOAD flag */
|
||||||
This->surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_ALLOCONLOAD;
|
This->surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_ALLOCONLOAD;
|
||||||
|
|
||||||
|
/* After seeing some logs, not sure at all about this... */
|
||||||
|
if (This->palette == NULL) {
|
||||||
This->palette = lpD3DTextureImpl->palette;
|
This->palette = lpD3DTextureImpl->palette;
|
||||||
|
if (lpD3DTextureImpl->palette != NULL) IDirectDrawPalette_AddRef(ICOM_INTERFACE(lpD3DTextureImpl->palette,
|
||||||
|
IDirectDrawPalette));
|
||||||
|
} else {
|
||||||
|
if (lpD3DTextureImpl->palette != NULL) {
|
||||||
|
PALETTEENTRY palent[256];
|
||||||
|
IDirectDrawPalette *pal_int = ICOM_INTERFACE(lpD3DTextureImpl->palette, IDirectDrawPalette);
|
||||||
|
IDirectDrawPalette_AddRef(pal_int);
|
||||||
|
IDirectDrawPalette_GetEntries(pal_int, 0, 0, 256, palent);
|
||||||
|
IDirectDrawPalette_SetEntries(ICOM_INTERFACE(This->palette, IDirectDrawPalette),
|
||||||
|
0, 0, 256, palent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Copy one surface on the other */
|
/* Copy one surface on the other */
|
||||||
dst_d = (DDSURFACEDESC *)&(This->surface_desc);
|
dst_d = (DDSURFACEDESC *)&(This->surface_desc);
|
||||||
@ -676,6 +705,7 @@ HRESULT d3dtexture_create(IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOL
|
|||||||
private->final_release = surf->final_release;
|
private->final_release = surf->final_release;
|
||||||
private->lock_update = surf->lock_update;
|
private->lock_update = surf->lock_update;
|
||||||
private->unlock_update = surf->unlock_update;
|
private->unlock_update = surf->unlock_update;
|
||||||
|
private->set_palette = surf->set_palette;
|
||||||
|
|
||||||
/* If at creation, we can optimize stuff and wait the first 'unlock' to upload a valid stuff to OpenGL.
|
/* If at creation, we can optimize stuff and wait the first 'unlock' to upload a valid stuff to OpenGL.
|
||||||
Otherwise, it will be uploaded here (and may be invalid). */
|
Otherwise, it will be uploaded here (and may be invalid). */
|
||||||
@ -688,6 +718,7 @@ HRESULT d3dtexture_create(IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOL
|
|||||||
surf->unlock_update = gltex_unlock_update;
|
surf->unlock_update = gltex_unlock_update;
|
||||||
surf->tex_private = private;
|
surf->tex_private = private;
|
||||||
surf->aux_setcolorkey_cb = gltex_setcolorkey_cb;
|
surf->aux_setcolorkey_cb = gltex_setcolorkey_cb;
|
||||||
|
surf->set_palette = gltex_set_palette;
|
||||||
|
|
||||||
ENTER_GL();
|
ENTER_GL();
|
||||||
if (surf->mipmap_level == 0) {
|
if (surf->mipmap_level == 0) {
|
||||||
|
@ -100,6 +100,10 @@ HRESULT Main_DirectDrawSurface_late_allocate(IDirectDrawSurfaceImpl* This)
|
|||||||
|
|
||||||
static void Main_DirectDrawSurface_Destroy(IDirectDrawSurfaceImpl* This)
|
static void Main_DirectDrawSurface_Destroy(IDirectDrawSurfaceImpl* This)
|
||||||
{
|
{
|
||||||
|
if (This->palette) {
|
||||||
|
IDirectDrawPalette_Release(ICOM_INTERFACE(This->palette, IDirectDrawPalette));
|
||||||
|
This->palette = NULL;
|
||||||
|
}
|
||||||
This->final_release(This);
|
This->final_release(This);
|
||||||
if (This->private != This+1) HeapFree(GetProcessHeap(), 0, This->private);
|
if (This->private != This+1) HeapFree(GetProcessHeap(), 0, This->private);
|
||||||
if (This->tex_private) HeapFree(GetProcessHeap(), 0, This->tex_private);
|
if (This->tex_private) HeapFree(GetProcessHeap(), 0, This->tex_private);
|
||||||
|
@ -100,6 +100,7 @@ typedef struct IDirect3DTextureGLImpl
|
|||||||
void (*final_release)(struct IDirectDrawSurfaceImpl *This);
|
void (*final_release)(struct IDirectDrawSurfaceImpl *This);
|
||||||
void (*lock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags);
|
void (*lock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags);
|
||||||
void (*unlock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
|
void (*unlock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
|
||||||
|
void (*set_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal);
|
||||||
} IDirect3DTextureGLImpl;
|
} IDirect3DTextureGLImpl;
|
||||||
|
|
||||||
typedef struct IDirect3DDeviceGLImpl
|
typedef struct IDirect3DDeviceGLImpl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user