- Stencil mapping now works (it helps to actually allocate a stencil
buffer). - Texture mapping corrected if no real texture bound. - Code now detects which opengl extensions are present - to be extended later. - More debug tracepoints.
This commit is contained in:
parent
dfbaa901c2
commit
ca6bcdcc99
|
@ -63,9 +63,6 @@ IDirect3D8* WINAPI Direct3DCreate8(UINT SDKVersion)
|
|||
|
||||
TRACE("SDKVersion = %x, Created Direct3D object at %p\n", SDKVersion, object);
|
||||
|
||||
/* Dump out the gl supported features
|
||||
TRACE("GL_Extensions reported: %s\n", glGetString(GL_EXTENSIONS)); */
|
||||
|
||||
return (IDirect3D8 *)object;
|
||||
}
|
||||
|
||||
|
|
|
@ -311,7 +311,6 @@ struct IDirect3DDevice8Impl
|
|||
Display *display;
|
||||
Window win;
|
||||
|
||||
void *dummyTexture[8];
|
||||
UINT dummyTextureName[8];
|
||||
|
||||
};
|
||||
|
|
|
@ -515,8 +515,10 @@ GLenum StencilOp(DWORD op) {
|
|||
case D3DSTENCILOP_INCRSAT : return GL_INCR;
|
||||
case D3DSTENCILOP_DECRSAT : return GL_DECR;
|
||||
case D3DSTENCILOP_INVERT : return GL_INVERT;
|
||||
case D3DSTENCILOP_INCR : return GL_INCR; /* Fixme - needs to support wrap */
|
||||
case D3DSTENCILOP_DECR : return GL_DECR; /* Fixme - needs to support wrap */
|
||||
case D3DSTENCILOP_INCR : FIXME("Unsupported stencil op %ld\n", op);
|
||||
return GL_INCR; /* Fixme - needs to support wrap */
|
||||
case D3DSTENCILOP_DECR : FIXME("Unsupported stencil op %ld\n", op);
|
||||
return GL_DECR; /* Fixme - needs to support wrap */
|
||||
default:
|
||||
FIXME("Invalid stencil op %ld\n", op);
|
||||
return GL_ALWAYS;
|
||||
|
@ -1130,8 +1132,6 @@ HRESULT WINAPI IDirect3DDevice8Impl_Clear(LPDIRECT3DDEVICE8 iface, DWORD Count
|
|||
curRect->x1, curRect->y2, curRect->x2 - curRect->x1, curRect->y2 - curRect->y1);
|
||||
glScissor(curRect->x1, curRect->y2, curRect->x2 - curRect->x1, curRect->y2 - curRect->y1);
|
||||
checkGLcall("glScissor");
|
||||
} else {
|
||||
TRACE("Clearing screen with glClear to color %lx\n", Color);
|
||||
}
|
||||
|
||||
/* Clear the whole screen */
|
||||
|
@ -1148,6 +1148,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_Clear(LPDIRECT3DDEVICE8 iface, DWORD Count
|
|||
}
|
||||
|
||||
if (Flags & D3DCLEAR_TARGET) {
|
||||
TRACE("Clearing screen with glClear to color %lx\n", Color);
|
||||
glClearColor(((Color >> 16) & 0xFF) / 255.0, ((Color >> 8) & 0xFF) / 255.0,
|
||||
((Color >> 0) & 0xFF) / 255.0, ((Color >> 24) & 0xFF) / 255.0);
|
||||
checkGLcall("glClearColor");
|
||||
|
@ -2050,6 +2051,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
|
|||
case D3DRS_STENCILWRITEMASK :
|
||||
{
|
||||
glStencilMask(Value);
|
||||
TRACE("glStencilMask(%lu)\n", Value);
|
||||
checkGLcall("glStencilMask");
|
||||
}
|
||||
break;
|
||||
|
@ -2826,26 +2828,28 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
|
|||
} else {
|
||||
|
||||
/* Enable only the appropriate texture dimension */
|
||||
if (This->StateBlock.textureDimensions[Stage] == GL_TEXTURE_1D) {
|
||||
glEnable(GL_TEXTURE_1D);
|
||||
checkGLcall("Enable GL_TEXTURE_1D");
|
||||
} else {
|
||||
glDisable(GL_TEXTURE_1D);
|
||||
checkGLcall("Disable GL_TEXTURE_1D");
|
||||
}
|
||||
if (This->StateBlock.textureDimensions[Stage] == GL_TEXTURE_2D) {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
checkGLcall("Enable GL_TEXTURE_2D");
|
||||
} else {
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
checkGLcall("Disable GL_TEXTURE_2D");
|
||||
}
|
||||
if (This->StateBlock.textureDimensions[Stage] == GL_TEXTURE_3D) {
|
||||
glEnable(GL_TEXTURE_3D);
|
||||
checkGLcall("Enable GL_TEXTURE_3D");
|
||||
} else {
|
||||
glDisable(GL_TEXTURE_3D);
|
||||
checkGLcall("Disable GL_TEXTURE_3D");
|
||||
if (Type==D3DTSS_ALPHAOP && Value != D3DTOP_DISABLE) {
|
||||
if (This->StateBlock.textureDimensions[Stage] == GL_TEXTURE_1D) {
|
||||
glEnable(GL_TEXTURE_1D);
|
||||
checkGLcall("Enable GL_TEXTURE_1D");
|
||||
} else {
|
||||
glDisable(GL_TEXTURE_1D);
|
||||
checkGLcall("Disable GL_TEXTURE_1D");
|
||||
}
|
||||
if (This->StateBlock.textureDimensions[Stage] == GL_TEXTURE_2D) {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
checkGLcall("Enable GL_TEXTURE_2D");
|
||||
} else {
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
checkGLcall("Disable GL_TEXTURE_2D");
|
||||
}
|
||||
if (This->StateBlock.textureDimensions[Stage] == GL_TEXTURE_3D) {
|
||||
glEnable(GL_TEXTURE_3D);
|
||||
checkGLcall("Enable GL_TEXTURE_3D");
|
||||
} else {
|
||||
glDisable(GL_TEXTURE_3D);
|
||||
checkGLcall("Disable GL_TEXTURE_3D");
|
||||
}
|
||||
}
|
||||
|
||||
/* Now set up the operand correctly */
|
||||
|
@ -2867,7 +2871,6 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
|
|||
/* Correct scale */
|
||||
if (Type == D3DTSS_ALPHAOP) glTexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE, Scale);
|
||||
else glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, Scale);
|
||||
|
||||
glTexEnvi(GL_TEXTURE_ENV, Parm, GL_MODULATE);
|
||||
break;
|
||||
|
||||
|
@ -2875,12 +2878,15 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
|
|||
glTexEnvi(GL_TEXTURE_ENV, Parm, GL_ADD);
|
||||
break;
|
||||
|
||||
|
||||
case D3DTOP_ADDSIGNED2X : Scale = Scale * 2; /* Drop through */
|
||||
case D3DTOP_ADDSIGNED :
|
||||
glTexEnvi(GL_TEXTURE_ENV, Parm, GL_ADD_SIGNED_EXT);
|
||||
break;
|
||||
|
||||
case D3DTOP_DOTPRODUCT3 :
|
||||
/*glTexEnvi(GL_TEXTURE_ENV, Parm, GL_DOT3_RGBA);
|
||||
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA);");
|
||||
break;*/
|
||||
|
||||
case D3DTOP_SUBTRACT :
|
||||
/* glTexEnvi(GL_TEXTURE_ENV, Parm, GL_SUBTRACT); Missing? */
|
||||
|
@ -2899,7 +2905,6 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
|
|||
case D3DTOP_MODULATEINVCOLOR_ADDALPHA :
|
||||
case D3DTOP_BUMPENVMAP :
|
||||
case D3DTOP_BUMPENVMAPLUMINANCE :
|
||||
case D3DTOP_DOTPRODUCT3 :
|
||||
case D3DTOP_MULTIPLYADD :
|
||||
case D3DTOP_LERP :
|
||||
default:
|
||||
|
@ -3467,14 +3472,12 @@ void CreateStateBlock(LPDIRECT3DDEVICE8 iface) {
|
|||
texture stage, but disable all stages by default. Hence if a stage is enabled
|
||||
then the default texture will kick in until replaced by a SetTexture call */
|
||||
for (i=0; i<8; i++) {
|
||||
GLubyte white = 255;
|
||||
|
||||
/* Make appropriate texture active */
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + i);
|
||||
checkGLcall("glActiveTextureARB");
|
||||
|
||||
/* Define 64 dummy bytes for the texture */
|
||||
This->dummyTexture[i] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 64);
|
||||
|
||||
/* Generate an opengl texture name */
|
||||
glGenTextures(1, &This->dummyTextureName[i]);
|
||||
checkGLcall("glGenTextures");
|
||||
|
@ -3485,7 +3488,7 @@ void CreateStateBlock(LPDIRECT3DDEVICE8 iface) {
|
|||
glBindTexture(GL_TEXTURE_1D, This->dummyTextureName[i]);
|
||||
checkGLcall("glBindTexture");
|
||||
|
||||
glTexImage1D(GL_TEXTURE_1D, 1, GL_ALPHA8, 1, 0, GL_ALPHA, GL_BYTE, &This->dummyTexture[i]);
|
||||
glTexImage1D(GL_TEXTURE_1D, 0, GL_LUMINANCE, 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, &white);
|
||||
checkGLcall("glTexImage1D");
|
||||
|
||||
/* Reapply all the texture state information to this texture */
|
||||
|
|
|
@ -337,7 +337,9 @@ HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps (LPDIRECT3D8 iface,
|
|||
|
||||
pCaps->ExtentsAdjust = 0;
|
||||
|
||||
pCaps->StencilCaps = 0;
|
||||
pCaps->StencilCaps = D3DSTENCILCAPS_DECRSAT | D3DSTENCILCAPS_INCRSAT |
|
||||
D3DSTENCILCAPS_INVERT | D3DSTENCILCAPS_KEEP |
|
||||
D3DSTENCILCAPS_REPLACE | D3DSTENCILCAPS_ZERO /* | D3DSTENCILCAPS_DECR | D3DSTENCILCAPS_INCR */;
|
||||
|
||||
pCaps->FVFCaps = D3DFVFCAPS_PSIZE | 0x80000;
|
||||
pCaps->TextureOpCaps = 0xFFFFFFFF;
|
||||
|
@ -380,6 +382,7 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
|
|||
IDirect3DDevice8** ppReturnedDeviceInterface) {
|
||||
IDirect3DDevice8Impl *object;
|
||||
HWND whichHWND;
|
||||
const char *GL_Extensions = NULL;
|
||||
|
||||
ICOM_THIS(IDirect3D8Impl,iface);
|
||||
TRACE("(%p)->(Adptr:%d, DevType: %x, FocusHwnd: %p, BehFlags: %lx, PresParms: %p, RetDevInt: %p)\n", This, Adapter, DeviceType,
|
||||
|
@ -412,8 +415,8 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
|
|||
/* Initialize openGl */
|
||||
{
|
||||
HDC hDc;
|
||||
int dblBuf[]={GLX_RGBA,GLX_DEPTH_SIZE,16,GLX_DOUBLEBUFFER,None};
|
||||
/*int dblBuf[]={GLX_RGBA,GLX_DEPTH_SIZE,16, None}; // Useful for debugging */
|
||||
int dblBuf[]={GLX_STENCIL_SIZE,8,GLX_RGBA,GLX_DEPTH_SIZE,16,GLX_DOUBLEBUFFER,None};
|
||||
/* FIXME: Handle stencil appropriately via EnableAutoDepthStencil / AutoDepthStencilFormat */
|
||||
|
||||
/* Which hwnd are we using? */
|
||||
/* if (pPresentationParameters->Windowed) { */
|
||||
|
@ -436,6 +439,7 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
|
|||
ENTER_GL();
|
||||
object->visInfo = glXChooseVisual(object->display, DefaultScreen(object->display), dblBuf);
|
||||
object->glCtx = glXCreateContext(object->display, object->visInfo, NULL, GL_TRUE);
|
||||
|
||||
LEAVE_GL();
|
||||
ReleaseDC(whichHWND, hDc);
|
||||
|
||||
|
@ -502,12 +506,32 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
|
|||
glEnable(GL_LIGHTING);
|
||||
checkGLcall("glEnable");
|
||||
|
||||
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
|
||||
checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);");
|
||||
|
||||
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
|
||||
checkGLcall("glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);");
|
||||
|
||||
/* Setup all the devices defaults */
|
||||
CreateStateBlock((LPDIRECT3DDEVICE8) object);
|
||||
|
||||
/* Parse the gl supported features, in theory enabling parts of our code appropriately */
|
||||
GL_Extensions = glGetString(GL_EXTENSIONS);
|
||||
TRACE("GL_Extensions reported:\n");
|
||||
|
||||
while (*GL_Extensions!=0x00) {
|
||||
const char *Start = GL_Extensions;
|
||||
char ThisExtn[256];
|
||||
|
||||
memset(ThisExtn, 0x00, sizeof(ThisExtn));
|
||||
while (*GL_Extensions!=' ' && *GL_Extensions!=0x00) {
|
||||
GL_Extensions++;
|
||||
}
|
||||
memcpy(ThisExtn, Start, (GL_Extensions-Start));
|
||||
TRACE (" %s\n", ThisExtn);
|
||||
if (*GL_Extensions==' ') GL_Extensions++;
|
||||
}
|
||||
|
||||
LEAVE_GL();
|
||||
|
||||
{ /* Set a default viewport */
|
||||
|
|
Loading…
Reference in New Issue