Commit b4a37991 authored by Raphael Junqueira's avatar Raphael Junqueira Committed by Alexandre Julliard

- implement SetRenderState D3DRS_FOGENABLE/D3DRS_RANGEFOGENABLE

- implement SetRenderState D3DRS_RANGEFOGENABLE - fix SetRenderState D3DRS_FOGVERTEXMODE Caps/Detection traces - fix IDirect3D8::GetAdapterIdentifier to use FillGLCaps and provide more exact infos (driver versions, vendor, ...) - split Fake GL Context creation from GetDeviceCaps for external use - add a new channel (d3d_caps) for all IDirect3D8 Caps/detection traces - rename fps channel to d3d_fps - high use of runtime detected OpenGL Caps instead of defines - update supported Caps using runtime detection
parent e2a90d9d
......@@ -357,6 +357,35 @@ typedef void (APIENTRY * PGLFNGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pn
typedef void (APIENTRY * PGLFNGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params);
typedef void (APIENTRY * PGLFNGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
typedef GLboolean (APIENTRY * PGLFNISPROGRAMARBPROC) (GLuint program);
/* GL_EXT_texture_compression_s3tc */
#ifndef GL_EXT_texture_compression_s3tc
#define GL_EXT_texture_compression_s3tc 1
#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
#endif
typedef void (APIENTRY * PGLFNCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
typedef void (APIENTRY * PGLFNCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
typedef void (APIENTRY * PGLFNCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
typedef void (APIENTRY * PGLFNCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
typedef void (APIENTRY * PGLFNCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
typedef void (APIENTRY * PGLFNCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
typedef void (APIENTRY * PGLFNGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img);
/* GL_EXT_stencil_wrap */
#ifndef GL_EXT_stencil_wrap
#define GL_EXT_stencil_wrap 1
#define GL_INCR_WRAP_EXT 0x8507
#define GL_DECR_WRAP_EXT 0x8508
#endif
/* GL_NV_fog_distance */
#ifndef GL_NV_fog_distance
#define GL_NV_fog_distance 1
#define GL_FOG_DISTANCE_MODE_NV 0x855A
#define GL_EYE_RADIAL_NV 0x855B
#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C
/* reuse GL_EYE_PLANE */
#endif
/*******
* OpenGL Official Version
......@@ -440,6 +469,7 @@ typedef enum _GL_SupportedExt {
/* NVIDIA */
NV_TEXTURE_ENV_COMBINE4,
NV_FRAGMENT_PROGRAM,
NV_FOG_DISTANCE,
NV_VERTEX_PROGRAM,
/* ATI */
ATI_TEXTURE_ENV_COMBINE3,
......@@ -569,6 +599,14 @@ typedef struct Direct3DVertexStridedData {
} u;
} Direct3DVertexStridedData;
typedef struct _WineD3D_GLContext {
GLXContext glCtx;
XVisualInfo* visInfo;
Display* display;
Drawable drawable;
DWORD ref;
} WineD3D_Context;
#define USE_GL_FUNC(type, pfn) type pfn;
typedef struct _GL_Info {
unsigned bIsFilled;
......
......@@ -44,7 +44,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DECLARE_DEBUG_CHANNEL(d3d_shader);
WINE_DECLARE_DEBUG_CHANNEL(fps);
WINE_DECLARE_DEBUG_CHANNEL(d3d_fps);
IDirect3DVertexShaderImpl* VertexShaders[64];
IDirect3DVertexShaderDeclarationImpl* VertexShaderDeclarations[64];
......@@ -497,7 +497,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_Present(LPDIRECT3DDEVICE8 iface,
TRACE("glXSwapBuffers called, Starting new frame\n");
/* FPS support */
if (TRACE_ON(fps))
if (TRACE_ON(d3d_fps))
{
static long prev_time, frames;
......@@ -505,7 +505,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_Present(LPDIRECT3DDEVICE8 iface,
frames++;
/* every 1.5 seconds */
if (time - prev_time > 1500) {
TRACE_(fps)("@ approx %.2ffps\n", 1000.0*frames/(time - prev_time));
TRACE_(d3d_fps)("@ approx %.2ffps\n", 1000.0*frames/(time - prev_time));
prev_time = time;
frames = 0;
}
......@@ -1809,6 +1809,16 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetLight(LPDIRECT3DDEVICE8 iface, DWORD In
/* FIXME: Range */
break;
case D3DLIGHT_DIRECTIONAL:
/* Direction */
object->lightPosn[0] = -pLight->Direction.x;
object->lightPosn[1] = -pLight->Direction.y;
object->lightPosn[2] = -pLight->Direction.z;
object->lightPosn[3] = 0.0;
object->exponent = 0.0f;
object->cutoff = 180.0f;
break;
case D3DLIGHT_SPOT:
/* Position */
object->lightPosn[0] = pLight->Position.x;
......@@ -1841,16 +1851,6 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetLight(LPDIRECT3DDEVICE8 iface, DWORD In
/* FIXME: Range */
break;
case D3DLIGHT_DIRECTIONAL:
/* Direction */
object->lightPosn[0] = -pLight->Direction.x;
object->lightPosn[1] = -pLight->Direction.y;
object->lightPosn[2] = -pLight->Direction.z;
object->lightPosn[3] = 0.0;
object->exponent = 0.0f;
object->cutoff = 180.0f;
break;
default:
FIXME("Unrecognized light type %d\n", pLight->Type);
}
......@@ -2686,7 +2686,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
case D3DRS_FOGENABLE :
{
if (Value && This->StateBlock->renderstate[D3DRS_FOGTABLEMODE] != D3DFOG_NONE) {
if (Value/* && This->StateBlock->renderstate[D3DRS_FOGTABLEMODE] != D3DFOG_NONE*/) {
glEnable(GL_FOG);
checkGLcall("glEnable GL_FOG");
} else {
......@@ -2696,6 +2696,16 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
}
break;
case D3DRS_RANGEFOGENABLE :
{
if (Value) {
TRACE("Enabled RANGEFOG");
} else {
TRACE("Disabled RANGEFOG");
}
}
break;
case D3DRS_FOGCOLOR :
{
float col[4];
......@@ -2708,14 +2718,35 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
case D3DRS_FOGTABLEMODE :
{
glHint(GL_FOG_HINT, GL_NICEST);
switch (Value) {
case D3DFOG_NONE: /* I don't know what to do here */ checkGLcall("glFogi(GL_FOG_MODE, GL_EXP"); break;
case D3DFOG_EXP: glFogi(GL_FOG_MODE, GL_EXP); checkGLcall("glFogi(GL_FOG_MODE, GL_EXP"); break;
case D3DFOG_EXP2: glFogi(GL_FOG_MODE, GL_EXP2); checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2"); break;
case D3DFOG_LINEAR: glFogi(GL_FOG_MODE, GL_LINEAR); checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR"); break;
default:
FIXME("Unsupported Value(%lu) for D3DRS_FOGTABLEMODE!\n", Value);
}
if (GL_SUPPORT(NV_FOG_DISTANCE)) {
glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV);
}
}
break;
case D3DRS_FOGVERTEXMODE :
{
glHint(GL_FOG_HINT, GL_FASTEST);
switch (Value) {
case D3DFOG_NONE: /* I don't know what to do here */ break;
case D3DFOG_NONE: /* I don't know what to do here */ checkGLcall("glFogi(GL_FOG_MODE, GL_EXP"); break;
case D3DFOG_EXP: glFogi(GL_FOG_MODE, GL_EXP); checkGLcall("glFogi(GL_FOG_MODE, GL_EXP"); break;
case D3DFOG_EXP2: glFogi(GL_FOG_MODE, GL_EXP2); checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2"); break;
case D3DFOG_LINEAR: glFogi(GL_FOG_MODE, GL_LINEAR); checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR"); break;
default:
FIXME("Unsupported Value(%lu) for D3DRS_FOGTABLEMODE!\n", Value);
}
if (GL_SUPPORT(NV_FOG_DISTANCE)) {
glFogi(GL_FOG_DISTANCE_MODE_NV, This->StateBlock->renderstate[D3DRS_RANGEFOGENABLE] ? GL_EYE_RADIAL_NV : GL_EYE_PLANE_ABSOLUTE_NV);
}
}
break;
......@@ -2930,7 +2961,6 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
case D3DRS_LASTPIXEL :
case D3DRS_ZVISIBLE :
case D3DRS_EDGEANTIALIAS :
case D3DRS_RANGEFOGENABLE :
case D3DRS_WRAP0 :
case D3DRS_WRAP1 :
case D3DRS_WRAP2 :
......@@ -2939,7 +2969,6 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
case D3DRS_WRAP5 :
case D3DRS_WRAP6 :
case D3DRS_WRAP7 :
case D3DRS_FOGVERTEXMODE :
case D3DRS_LOCALVIEWER :
case D3DRS_SOFTWAREVERTEXPROCESSING :
case D3DRS_POINTSPRITEENABLE :
......
......@@ -474,11 +474,8 @@ ICOM_VTABLE(IDirect3DSurface8) Direct3DSurface8_Vtbl =
HRESULT WINAPI IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface, GLenum gl_target, GLenum gl_level) {
ICOM_THIS(IDirect3DSurface8Impl,iface);
if ((This->myDesc.Format == D3DFMT_P8 || This->myDesc.Format == D3DFMT_A8P8)
#if defined(GL_EXT_paletted_texture)
&& !GL_SUPPORT_DEV(EXT_PALETTED_TEXTURE, This->Device)
#endif
) {
if ((This->myDesc.Format == D3DFMT_P8 || This->myDesc.Format == D3DFMT_A8P8) &&
!GL_SUPPORT_DEV(EXT_PALETTED_TEXTURE, This->Device)) {
/**
* wanted a paletted texture and not really support it in HW
* so software emulation code begin
......@@ -532,7 +529,6 @@ HRESULT WINAPI IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface, GLenu
if (This->myDesc.Format == D3DFMT_DXT1 ||
This->myDesc.Format == D3DFMT_DXT3 ||
This->myDesc.Format == D3DFMT_DXT5) {
#if defined(GL_EXT_texture_compression_s3tc)
if (GL_SUPPORT_DEV(EXT_TEXTURE_COMPRESSION_S3TC, This->Device)) {
TRACE("Calling glCompressedTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, sz=%d, Mem=%p\n",
gl_target,
......@@ -546,7 +542,7 @@ HRESULT WINAPI IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface, GLenu
ENTER_GL();
glCompressedTexImage2DARB(gl_target,
glCompressedTexImage2D(gl_target,
gl_level,
D3DFmt2GLIntFmt(This->Device, This->myDesc.Format),
This->myDesc.Width,
......@@ -557,10 +553,9 @@ HRESULT WINAPI IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface, GLenu
checkGLcall("glCommpressedTexTexImage2D");
LEAVE_GL();
}
#else
} else {
FIXME("Using DXT1/3/5 without advertized support\n");
#endif
}
} else {
TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
gl_target,
......
......@@ -417,7 +417,6 @@ SHORT D3DFmtGetBpp(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
GLint D3DFmt2GLIntFmt(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
GLint retVal = 0;
#if defined(GL_EXT_texture_compression_s3tc)
if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) {
switch (fmt) {
case D3DFMT_DXT1: retVal = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; break;
......@@ -428,7 +427,6 @@ GLint D3DFmt2GLIntFmt(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
break;
}
}
#endif
if (retVal == 0) {
switch (fmt) {
......@@ -453,7 +451,6 @@ GLint D3DFmt2GLIntFmt(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
GLenum D3DFmt2GLFmt(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
GLenum retVal = 0;
#if defined(GL_EXT_texture_compression_s3tc)
if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) {
switch (fmt) {
case D3DFMT_DXT1: retVal = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; break;
......@@ -464,7 +461,6 @@ GLenum D3DFmt2GLFmt(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
break;
}
}
#endif
if (retVal == 0) {
switch (fmt) {
......@@ -490,7 +486,6 @@ GLenum D3DFmt2GLFmt(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
GLenum D3DFmt2GLType(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
GLenum retVal = 0;
#if defined(GL_EXT_texture_compression_s3tc)
if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) {
switch (fmt) {
case D3DFMT_DXT1: retVal = 0; break;
......@@ -501,7 +496,6 @@ GLenum D3DFmt2GLType(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
break;
}
}
#endif
if (retVal == 0) {
switch (fmt) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment