2 * IDirect3D8 implementation
4 * Copyright 2002 Jason Edmeades
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #define NONAMELESSUNION
24 #define NONAMELESSSTRUCT
29 #include "wine/debug.h"
30 #include "wine/unicode.h"
32 #include "d3d8_private.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
36 /* x11drv GDI escapes */
37 #define X11DRV_ESCAPE 6789
38 enum x11drv_escape_codes
40 X11DRV_GET_DISPLAY
, /* get X11 display for a DC */
41 X11DRV_GET_DRAWABLE
, /* get current drawable for a DC */
42 X11DRV_GET_FONT
, /* get current X font for a DC */
46 static const int modes
[NUM_MODES
][4] = {
79 static const D3DFORMAT device_formats
[NUM_FORMATS
] = {
90 /* retrieve the X display to use on a given DC */
91 inline static Display
*get_display( HDC hdc
)
94 enum x11drv_escape_codes escape
= X11DRV_GET_DISPLAY
;
96 if (!ExtEscape( hdc
, X11DRV_ESCAPE
, sizeof(escape
), (LPCSTR
)&escape
,
97 sizeof(display
), (LPSTR
)&display
)) display
= NULL
;
102 /* IDirect3D IUnknown parts follow: */
103 HRESULT WINAPI
IDirect3D8Impl_QueryInterface(LPDIRECT3D8 iface
,REFIID riid
,LPVOID
*ppobj
)
105 ICOM_THIS(IDirect3D8Impl
,iface
);
107 if (IsEqualGUID(riid
, &IID_IUnknown
)
108 || IsEqualGUID(riid
, &IID_IDirect3D8
)) {
109 IDirect3D8Impl_AddRef(iface
);
114 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
115 return E_NOINTERFACE
;
118 ULONG WINAPI
IDirect3D8Impl_AddRef(LPDIRECT3D8 iface
) {
119 ICOM_THIS(IDirect3D8Impl
,iface
);
120 TRACE("(%p) : AddRef from %ld\n", This
, This
->ref
);
121 return ++(This
->ref
);
124 ULONG WINAPI
IDirect3D8Impl_Release(LPDIRECT3D8 iface
) {
125 ICOM_THIS(IDirect3D8Impl
,iface
);
126 ULONG ref
= --This
->ref
;
127 TRACE("(%p) : ReleaseRef to %ld\n", This
, This
->ref
);
129 HeapFree(GetProcessHeap(), 0, This
);
133 /* IDirect3D Interface follow: */
134 HRESULT WINAPI
IDirect3D8Impl_RegisterSoftwareDevice (LPDIRECT3D8 iface
, void* pInitializeFunction
) {
135 ICOM_THIS(IDirect3D8Impl
,iface
);
136 FIXME("(%p)->(%p): stub\n", This
, pInitializeFunction
);
140 UINT WINAPI
IDirect3D8Impl_GetAdapterCount (LPDIRECT3D8 iface
) {
141 ICOM_THIS(IDirect3D8Impl
,iface
);
142 /* FIXME: Set to one for now to imply the display */
143 TRACE("(%p): Mostly stub, only returns primary display\n", This
);
147 HRESULT WINAPI
IDirect3D8Impl_GetAdapterIdentifier (LPDIRECT3D8 iface
,
148 UINT Adapter
, DWORD Flags
, D3DADAPTER_IDENTIFIER8
* pIdentifier
) {
149 ICOM_THIS(IDirect3D8Impl
,iface
);
151 TRACE("(%p}->(Adapter: %d, Flags: %lx, pId=%p)\n", This
, Adapter
, Flags
, pIdentifier
);
153 if (Adapter
>= IDirect3D8Impl_GetAdapterCount(iface
)) {
154 return D3DERR_INVALIDCALL
;
157 if (Adapter
== 0) { /* Display */
158 strcpy(pIdentifier
->Driver
, "Display");
159 strcpy(pIdentifier
->Description
, "Direct3D Display");
160 pIdentifier
->DriverVersion
.s
.HighPart
= 1;
161 pIdentifier
->DriverVersion
.s
.LowPart
= 0;
162 pIdentifier
->VendorId
= 0;
163 pIdentifier
->DeviceId
= 0;
164 pIdentifier
->SubSysId
= 0;
165 pIdentifier
->Revision
= 0;
166 /*FIXME: memcpy(&pIdentifier->DeviceIdentifier, ??, sizeof(??GUID)); */
167 if (Flags
& D3DENUM_NO_WHQL_LEVEL
) {
168 pIdentifier
->WHQLLevel
= 0;
170 pIdentifier
->WHQLLevel
= 1;
173 FIXME("Adapter not primary display\n");
179 UINT WINAPI
IDirect3D8Impl_GetAdapterModeCount (LPDIRECT3D8 iface
,
181 ICOM_THIS(IDirect3D8Impl
,iface
);
183 TRACE("(%p}->(Adapter: %d)\n", This
, Adapter
);
185 if (Adapter
>= IDirect3D8Impl_GetAdapterCount(iface
)) {
186 return D3DERR_INVALIDCALL
;
189 if (Adapter
== 0) { /* Display */
190 int maxWidth
= GetSystemMetrics(SM_CXSCREEN
);
191 int maxHeight
= GetSystemMetrics(SM_CYSCREEN
);
194 for (i
= 0; i
< NUM_MODES
; i
++) {
195 if (modes
[i
][0] > maxWidth
|| modes
[i
][1] > maxHeight
) {
196 TRACE("(%p}->(Adapter: %d) => %d\n", This
, Adapter
, i
+ 1);
200 TRACE("(%p}->(Adapter: %d) => %d\n", This
, Adapter
, NUM_MODES
);
201 return NUM_MODES
+ 1;
203 FIXME("Adapter not primary display\n");
209 HRESULT WINAPI
IDirect3D8Impl_EnumAdapterModes (LPDIRECT3D8 iface
,
210 UINT Adapter
, UINT Mode
, D3DDISPLAYMODE
* pMode
) {
211 ICOM_THIS(IDirect3D8Impl
,iface
);
213 TRACE("(%p}->(Adapter:%d, mode:%d, pMode:%p)\n", This
, Adapter
, Mode
, pMode
);
215 if (Adapter
>= IDirect3D8Impl_GetAdapterCount(iface
)) {
216 return D3DERR_INVALIDCALL
;
219 if (Adapter
== 0) { /* Display */
224 pMode
->Width
= GetSystemMetrics(SM_CXSCREEN
);
225 pMode
->Height
= GetSystemMetrics(SM_CYSCREEN
);
226 pMode
->RefreshRate
= 85; /*FIXME: How to identify? */
228 } else if (Mode
< (NUM_MODES
+ 1)) {
229 pMode
->Width
= modes
[Mode
- 1][0];
230 pMode
->Height
= modes
[Mode
- 1][1];
231 pMode
->RefreshRate
= modes
[Mode
- 1][2];
232 bpp
= modes
[Mode
- 1][3];
234 TRACE("Requested mode out of range %d\n", Mode
);
235 return D3DERR_INVALIDCALL
;
238 hdc
= CreateDCA("DISPLAY", NULL
, NULL
, NULL
);
239 bpp
= min(GetDeviceCaps(hdc
, BITSPIXEL
), bpp
);
243 case 8: pMode
->Format
= D3DFMT_R3G3B2
; break;
244 case 16: pMode
->Format
= D3DFMT_R5G6B5
; break;
245 case 24: /* pMode->Format = D3DFMT_R5G6B5; break;*/ /* Make 24bit appear as 32 bit */
246 case 32: pMode
->Format
= D3DFMT_A8R8G8B8
; break;
247 default: pMode
->Format
= D3DFMT_UNKNOWN
;
249 TRACE("W %d H %d rr %d fmt (%x,%s) bpp %u\n", pMode
->Width
, pMode
->Height
, pMode
->RefreshRate
, pMode
->Format
, debug_d3dformat(pMode
->Format
), bpp
);
252 FIXME("Adapter not primary display\n");
258 HRESULT WINAPI
IDirect3D8Impl_GetAdapterDisplayMode (LPDIRECT3D8 iface
,
259 UINT Adapter
, D3DDISPLAYMODE
* pMode
) {
260 ICOM_THIS(IDirect3D8Impl
,iface
);
261 TRACE("(%p}->(Adapter: %d, pMode: %p)\n", This
, Adapter
, pMode
);
263 if (Adapter
>= IDirect3D8Impl_GetAdapterCount(iface
)) {
264 return D3DERR_INVALIDCALL
;
267 if (Adapter
== 0) { /* Display */
271 pMode
->Width
= GetSystemMetrics(SM_CXSCREEN
);
272 pMode
->Height
= GetSystemMetrics(SM_CYSCREEN
);
273 pMode
->RefreshRate
= 85; /*FIXME: How to identify? */
275 hdc
= CreateDCA("DISPLAY", NULL
, NULL
, NULL
);
276 bpp
= GetDeviceCaps(hdc
, BITSPIXEL
);
280 case 8: pMode
->Format
= D3DFMT_R3G3B2
; break;
281 case 16: pMode
->Format
= D3DFMT_R5G6B5
; break;
282 case 24: /*pMode->Format = D3DFMT_R5G6B5; break;*/ /* Make 24bit appear as 32 bit */
283 case 32: pMode
->Format
= D3DFMT_A8R8G8B8
; break;
284 default: pMode
->Format
= D3DFMT_UNKNOWN
;
288 FIXME("Adapter not primary display\n");
291 TRACE("returning w:%d, h:%d, ref:%d, fmt:%x\n", pMode
->Width
,
292 pMode
->Height
, pMode
->RefreshRate
, pMode
->Format
);
296 HRESULT WINAPI
IDirect3D8Impl_CheckDeviceType (LPDIRECT3D8 iface
,
297 UINT Adapter
, D3DDEVTYPE CheckType
, D3DFORMAT DisplayFormat
,
298 D3DFORMAT BackBufferFormat
, BOOL Windowed
) {
299 ICOM_THIS(IDirect3D8Impl
,iface
);
300 FIXME("(%p)->(Adptr:%d, CheckType:(%x,%s), DispFmt:(%x,%s), BackBuf:(%x,%s), Win?%d): stub\n",
303 CheckType
, debug_d3ddevicetype(CheckType
),
304 DisplayFormat
, debug_d3dformat(DisplayFormat
),
305 BackBufferFormat
, debug_d3dformat(BackBufferFormat
),
310 HRESULT WINAPI
IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 iface
,
311 UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT AdapterFormat
,
312 DWORD Usage
, D3DRESOURCETYPE RType
, D3DFORMAT CheckFormat
) {
313 ICOM_THIS(IDirect3D8Impl
,iface
);
314 FIXME("(%p)->(Adptr:%d, DevType:(%u,%s), AdptFmt:(%u,%s), Use:(%lu,%s), ResTyp:(%x,%s), CheckFmt:(%u,%s))\n",
317 DeviceType
, debug_d3ddevicetype(DeviceType
),
318 AdapterFormat
, debug_d3dformat(AdapterFormat
),
319 Usage
, debug_d3dusage(Usage
),
320 RType
, debug_d3dressourcetype(RType
),
321 CheckFormat
, debug_d3dformat(CheckFormat
));
323 switch (CheckFormat
) {
331 case D3DFMT_X8L8V8U8
:
334 /* Since we do not support these formats right now, don't pretend to. */
335 return D3DERR_NOTAVAILABLE
;
343 HRESULT WINAPI
IDirect3D8Impl_CheckDeviceMultiSampleType(LPDIRECT3D8 iface
,
344 UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT SurfaceFormat
,
345 BOOL Windowed
, D3DMULTISAMPLE_TYPE MultiSampleType
) {
346 ICOM_THIS(IDirect3D8Impl
,iface
);
347 FIXME("(%p)->(Adptr:%d, DevType:(%x,%s), SurfFmt:(%x,%s), Win?%d, MultiSamp:%x)\n",
350 DeviceType
, debug_d3ddevicetype(DeviceType
),
351 SurfaceFormat
, debug_d3dformat(SurfaceFormat
),
355 if (D3DMULTISAMPLE_NONE
== MultiSampleType
)
357 return D3DERR_NOTAVAILABLE
;
360 HRESULT WINAPI
IDirect3D8Impl_CheckDepthStencilMatch(LPDIRECT3D8 iface
,
361 UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT AdapterFormat
,
362 D3DFORMAT RenderTargetFormat
, D3DFORMAT DepthStencilFormat
) {
363 ICOM_THIS(IDirect3D8Impl
,iface
);
364 FIXME("(%p)->(Adptr:%d, DevType:(%x,%s), AdptFmt:(%x,%s), RendrTgtFmt:(%x,%s), DepthStencilFmt:(%x,%s))\n",
367 DeviceType
, debug_d3ddevicetype(DeviceType
),
368 AdapterFormat
, debug_d3dformat(AdapterFormat
),
369 RenderTargetFormat
, debug_d3dformat(RenderTargetFormat
),
370 DepthStencilFormat
, debug_d3dformat(DepthStencilFormat
));
373 switch (DepthStencilFormat
) {
379 * as i don't know how to really check hard caps of graphics cards
380 * i prefer to not permit 32bit zbuffers enumeration (as few cards can do it)
382 return D3DERR_NOTAVAILABLE
;
390 HRESULT WINAPI
IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface
, UINT Adapter
, D3DDEVTYPE DeviceType
, D3DCAPS8
* pCaps
) {
391 ICOM_THIS(IDirect3D8Impl
,iface
);
392 TRACE("(%p)->(Adptr:%d, DevType: %x, pCaps: %p)\n", This
, Adapter
, DeviceType
, pCaps
);
394 pCaps
->DeviceType
= (DeviceType
== D3DDEVTYPE_HAL
) ? D3DDEVTYPE_HAL
: D3DDEVTYPE_REF
; /* Not quite true, but use h/w supported by opengl I suppose */
395 pCaps
->AdapterOrdinal
= Adapter
;
398 pCaps
->Caps2
= D3DCAPS2_CANRENDERWINDOWED
;
399 pCaps
->Caps3
= D3DDEVCAPS_HWTRANSFORMANDLIGHT
;
400 pCaps
->PresentationIntervals
= D3DPRESENT_INTERVAL_IMMEDIATE
;
402 pCaps
->CursorCaps
= 0;
404 pCaps
->DevCaps
= D3DDEVCAPS_DRAWPRIMTLVERTEX
|
405 D3DDEVCAPS_HWTRANSFORMANDLIGHT
|
406 D3DDEVCAPS_PUREDEVICE
;
408 pCaps
->PrimitiveMiscCaps
= D3DPMISCCAPS_CULLCCW
|
409 D3DPMISCCAPS_CULLCW
|
410 D3DPMISCCAPS_COLORWRITEENABLE
|
411 D3DPMISCCAPS_CLIPTLVERTS
|
412 D3DPMISCCAPS_CLIPPLANESCALEDPOINTS
|
414 /*NOT: D3DPMISCCAPS_TSSARGTEMP*/
416 pCaps
->RasterCaps
= D3DPRASTERCAPS_DITHER
|
418 D3DPRASTERCAPS_FOGRANGE
;
420 D3DPRASTERCAPS_FOGVERTEX
421 D3DPRASTERCAPS_FOGTABLE
422 D3DPRASTERCAPS_MIPMAPLODBIAS
424 D3DPRASTERCAPS_ANISOTROPY
427 D3DPRASTERCAPS_COLORPERSPECTIVE
428 D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE
429 D3DPRASTERCAPS_ANTIALIASEDGES
430 D3DPRASTERCAPS_ZBUFFERLESSHSR
431 D3DPRASTERCAPS_WBUFFER */
433 pCaps
->ZCmpCaps
= D3DPCMPCAPS_ALWAYS
|
435 D3DPCMPCAPS_GREATER
|
436 D3DPCMPCAPS_GREATEREQUAL
|
438 D3DPCMPCAPS_LESSEQUAL
|
440 D3DPCMPCAPS_NOTEQUAL
;
442 pCaps
->SrcBlendCaps
= 0xFFFFFFFF; /*FIXME: Tidy up later */
443 pCaps
->DestBlendCaps
= 0xFFFFFFFF; /*FIXME: Tidy up later */
444 pCaps
->AlphaCmpCaps
= 0xFFFFFFFF; /*FIXME: Tidy up later */
446 pCaps
->ShadeCaps
= D3DPSHADECAPS_SPECULARGOURAUDRGB
|
447 D3DPSHADECAPS_COLORGOURAUDRGB
;
449 pCaps
->TextureCaps
= D3DPTEXTURECAPS_ALPHA
|
450 D3DPTEXTURECAPS_ALPHAPALETTE
|
451 D3DPTEXTURECAPS_POW2
|
452 D3DPTEXTURECAPS_VOLUMEMAP
|
453 D3DPTEXTURECAPS_MIPMAP
;
454 #if defined(GL_VERSION_1_3) || defined(GL_ARB_texture_cube_map)
455 pCaps
->TextureCaps
|= D3DPTEXTURECAPS_CUBEMAP
|
456 D3DPTEXTURECAPS_MIPCUBEMAP
|
457 D3DPTEXTURECAPS_CUBEMAP_POW2
;
460 pCaps
->TextureFilterCaps
= D3DPTFILTERCAPS_MAGFLINEAR
|
461 D3DPTFILTERCAPS_MAGFPOINT
|
462 D3DPTFILTERCAPS_MINFLINEAR
|
463 D3DPTFILTERCAPS_MINFPOINT
|
464 D3DPTFILTERCAPS_MIPFLINEAR
|
465 D3DPTFILTERCAPS_MIPFPOINT
;
467 pCaps
->CubeTextureFilterCaps
= 0;
468 pCaps
->VolumeTextureFilterCaps
= 0;
470 pCaps
->TextureAddressCaps
= D3DPTADDRESSCAPS_BORDER
|
471 D3DPTADDRESSCAPS_CLAMP
|
472 D3DPTADDRESSCAPS_WRAP
;
473 #if defined(GL_VERSION_1_3)
474 pCaps
->TextureAddressCaps
|= D3DPTADDRESSCAPS_MIRROR
;
477 D3DPTADDRESSCAPS_BORDER
478 D3DPTADDRESSCAPS_MIRRORONCE */
480 pCaps
->VolumeTextureAddressCaps
= 0;
482 pCaps
->LineCaps
= D3DLINECAPS_TEXTURE
|
491 glGetIntegerv(GL_MAX_TEXTURE_SIZE
, &gl_tex_size
);
492 pCaps
->MaxTextureWidth
= gl_tex_size
;
493 pCaps
->MaxTextureHeight
= gl_tex_size
;
496 pCaps
->MaxVolumeExtent
= 0;
498 pCaps
->MaxTextureRepeat
= 32768;
499 pCaps
->MaxTextureAspectRatio
= 32768;
500 pCaps
->MaxVertexW
= 1.0;
502 pCaps
->GuardBandLeft
= 0;
503 pCaps
->GuardBandTop
= 0;
504 pCaps
->GuardBandRight
= 0;
505 pCaps
->GuardBandBottom
= 0;
507 pCaps
->ExtentsAdjust
= 0;
509 pCaps
->StencilCaps
= D3DSTENCILCAPS_DECRSAT
|
510 D3DSTENCILCAPS_INCRSAT
|
511 D3DSTENCILCAPS_INVERT
|
512 D3DSTENCILCAPS_KEEP
|
513 D3DSTENCILCAPS_REPLACE
|
515 #if defined(GL_VERSION_1_4) || defined(GL_EXT_stencil_wrap)
516 pCaps
->StencilCaps
|= D3DSTENCILCAPS_DECR
|
520 pCaps
->FVFCaps
= D3DFVFCAPS_PSIZE
| 0x80000;
522 pCaps
->TextureOpCaps
= D3DTEXOPCAPS_ADD
|
523 D3DTEXOPCAPS_ADDSIGNED
|
524 D3DTEXOPCAPS_ADDSIGNED2X
|
525 D3DTEXOPCAPS_MODULATE
|
526 D3DTEXOPCAPS_MODULATE2X
|
527 D3DTEXOPCAPS_MODULATE4X
|
528 D3DTEXOPCAPS_SELECTARG1
|
529 D3DTEXOPCAPS_SELECTARG2
|
530 D3DTEXOPCAPS_DISABLE
;
531 #if defined(GL_VERSION_1_3)
532 pCaps
->TextureOpCaps
|= D3DTEXOPCAPS_DOTPRODUCT3
|
533 D3DTEXOPCAPS_SUBTRACT
;
536 D3DTEXOPCAPS_ADDSMOOTH
537 D3DTEXOPCAPS_BLENDCURRENTALPHA
538 D3DTEXOPCAPS_BLENDDIFFUSEALPHA
539 D3DTEXOPCAPS_BLENDFACTORALPHA
540 D3DTEXOPCAPS_BLENDTEXTUREALPHA
541 D3DTEXOPCAPS_BLENDTEXTUREALPHAPM
542 D3DTEXOPCAPS_BUMPENVMAP
543 D3DTEXOPCAPS_BUMPENVMAPLUMINANCE
545 D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
546 D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
547 D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR
548 D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA
549 D3DTEXOPCAPS_MULTIPLYADD
550 D3DTEXOPCAPS_PREMODULATE */
556 #if defined(GL_VERSION_1_3)
557 glGetIntegerv(GL_MAX_TEXTURE_UNITS
, &gl_max
);
559 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB
, &gl_max
);
561 TRACE("GLCaps: GL_MAX_TEXTURE_UNITS_ARB=%d\n", gl_max
);
562 pCaps
->MaxTextureBlendStages
= min(8, gl_max
);
563 pCaps
->MaxSimultaneousTextures
= min(8, gl_max
);
565 glGetIntegerv(GL_MAX_CLIP_PLANES
, &gl_max
);
566 pCaps
->MaxUserClipPlanes
= min(MAX_CLIPPLANES
, gl_max
);
567 TRACE("GLCaps: GL_MAX_CLIP_PLANES=%ld\n", pCaps
->MaxUserClipPlanes
);
569 glGetIntegerv(GL_MAX_LIGHTS
, &gl_max
);
570 pCaps
->MaxActiveLights
= min(MAX_ACTIVE_LIGHTS
, gl_max
);
571 TRACE("GLCaps: GL_MAX_LIGHTS=%ld\n", pCaps
->MaxActiveLights
);
573 #if defined(GL_ARB_vertex_blend)
574 glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB
, &gl_max
);
575 pCaps
->MaxVertexBlendMatrices
= gl_max
;
576 pCaps
->MaxVertexBlendMatrixIndex
= 1;
578 pCaps
->MaxVertexBlendMatrices
= 0;
579 pCaps
->MaxVertexBlendMatrixIndex
= 1;
582 #if defined(GL_EXT_texture_filter_anisotropic)
583 glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
, &gl_max
);
584 pCaps
->MaxAnisotropy
= gl_max
;
586 pCaps
->MaxAnisotropy
= 0;
589 glGetFloatv(GL_POINT_SIZE_RANGE
, &gl_float
);
590 pCaps
->MaxPointSize
= gl_float
;
593 pCaps
->VertexProcessingCaps
= D3DVTXPCAPS_DIRECTIONALLIGHTS
|
594 D3DVTXPCAPS_MATERIALSOURCE7
|
595 D3DVTXPCAPS_POSITIONALLIGHTS
|
598 D3DVTXPCAPS_LOCALVIEWER
599 D3DVTXPCAPS_TWEENING */
601 pCaps
->MaxPrimitiveCount
= 0xFFFFFFFF;
602 pCaps
->MaxVertexIndex
= 0xFFFFFFFF;
603 pCaps
->MaxStreams
= MAX_STREAMS
;
604 pCaps
->MaxStreamStride
= 1024;
607 pCaps
->VertexShaderVersion
= D3DVS_VERSION(1,1);
608 pCaps
->MaxVertexShaderConst
= D3D8_VSHADER_MAX_CONSTANTS
;
610 pCaps
->VertexShaderVersion
= 0;
611 pCaps
->MaxVertexShaderConst
= D3D8_VSHADER_MAX_CONSTANTS
;
615 pCaps
->PixelShaderVersion
= D3DPS_VERSION(1,1);
616 pCaps
->MaxPixelShaderValue
= 1.0;
618 pCaps
->PixelShaderVersion
= 0;
619 pCaps
->MaxPixelShaderValue
= 0.0;
625 HMONITOR WINAPI
IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface
, UINT Adapter
) {
626 ICOM_THIS(IDirect3D8Impl
,iface
);
627 FIXME("(%p)->(Adptr:%d)\n", This
, Adapter
);
632 static void IDirect3D8Impl_FillGLCaps(LPDIRECT3D8 iface
, Display
* display
) {
633 const char *GL_Extensions
= NULL
;
634 const char *GLX_Extensions
= NULL
;
636 ICOM_THIS(IDirect3D8Impl
,iface
);
639 * Initialize openGL extension related variables
640 * with Default values
642 memset(&This
->gl_info
.supported
, 0, sizeof(This
->gl_info
.supported
));
643 This
->gl_info
.max_textures
= 1;
644 This
->gl_info
.ps_arb_version
= PS_VERSION_NOT_SUPPORTED
;
645 This
->gl_info
.vs_arb_version
= VS_VERSION_NOT_SUPPORTED
;
646 This
->gl_info
.vs_nv_version
= VS_VERSION_NOT_SUPPORTED
;
647 This
->gl_info
.vs_ati_version
= VS_VERSION_NOT_SUPPORTED
;
649 #define USE_GL_FUNC(type, pfn) This->gl_info.pfn = NULL;
653 /* Retrieve opengl defaults */
654 glGetIntegerv(GL_MAX_CLIP_PLANES
, &gl_max
);
655 This
->gl_info
.max_clipplanes
= min(MAX_CLIPPLANES
, gl_max
);
656 TRACE("ClipPlanes support - num Planes=%d\n", gl_max
);
658 glGetIntegerv(GL_MAX_LIGHTS
, &gl_max
);
659 This
->gl_info
.max_lights
= min(MAX_ACTIVE_LIGHTS
, gl_max
);
660 TRACE("Lights support - max lights=%d\n", gl_max
);
662 /* Parse the gl supported features, in theory enabling parts of our code appropriately */
663 GL_Extensions
= glGetString(GL_EXTENSIONS
);
664 FIXME("GL_Extensions reported:\n");
666 if (NULL
== GL_Extensions
) {
667 ERR(" GL_Extensions returns NULL\n");
669 while (*GL_Extensions
!= 0x00) {
670 const char *Start
= GL_Extensions
;
673 memset(ThisExtn
, 0x00, sizeof(ThisExtn
));
674 while (*GL_Extensions
!= ' ' && *GL_Extensions
!= 0x00) {
677 memcpy(ThisExtn
, Start
, (GL_Extensions
- Start
));
678 FIXME("- %s\n", ThisExtn
);
683 if (strcmp(ThisExtn
, "GL_ARB_fragment_program") == 0) {
684 This
->gl_info
.ps_arb_version
= PS_VERSION_11
;
685 FIXME(" FOUND: ARB Pixel Shader support - version=%02x\n", This
->gl_info
.ps_arb_version
);
686 This
->gl_info
.supported
[ARB_FRAGMENT_PROGRAM
] = TRUE
;
687 } else if (strcmp(ThisExtn
, "GL_ARB_multisample") == 0) {
688 FIXME(" FOUND: ARB Multisample support\n");
689 This
->gl_info
.supported
[ARB_MULTISAMPLE
] = TRUE
;
690 } else if (strcmp(ThisExtn
, "GL_ARB_multitexture") == 0) {
691 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB
, &gl_max
);
692 FIXME(" FOUND: ARB Multitexture support - GL_MAX_TEXTURE_UNITS_ARB=%u\n", gl_max
);
693 This
->gl_info
.supported
[ARB_MULTITEXTURE
] = TRUE
;
694 This
->gl_info
.max_textures
= min(8, gl_max
);
695 } else if (strcmp(ThisExtn
, "GL_ARB_texture_cube_map") == 0) {
696 FIXME(" FOUND: ARB Texture Cube Map support\n");
697 This
->gl_info
.supported
[ARB_TEXTURE_CUBE_MAP
] = TRUE
;
698 } else if (strcmp(ThisExtn
, "GL_ARB_texture_compression") == 0) {
699 FIXME(" FOUND: ARB Texture Compression support\n");
700 This
->gl_info
.supported
[ARB_TEXTURE_COMPRESSION
] = TRUE
;
701 } else if (strcmp(ThisExtn
, "GL_ARB_texture_env_combine") == 0) {
702 FIXME(" FOUND: EXT Texture Env combine support\n");
703 This
->gl_info
.supported
[ARB_TEXTURE_ENV_COMBINE
] = TRUE
;
704 } else if (strcmp(ThisExtn
, "GL_ARB_texture_env_dot3") == 0) {
705 if (FALSE
== This
->gl_info
.supported
[ARB_TEXTURE_ENV_DOT3
]) {
706 FIXME(" FOUND: EXT Dot3 support\n");
707 This
->gl_info
.supported
[ARB_TEXTURE_ENV_DOT3
] = TRUE
;
709 } else if (strstr(ThisExtn
, "GL_ARB_vertex_program")) {
710 This
->gl_info
.vs_arb_version
= VS_VERSION_11
;
711 FIXME(" FOUND: ARB Vertex Shader support - version=%02x\n", This
->gl_info
.vs_arb_version
);
712 This
->gl_info
.supported
[ARB_VERTEX_PROGRAM
] = TRUE
;
717 } else if (strcmp(ThisExtn
, "GL_EXT_fog_coord") == 0) {
718 FIXME(" FOUND: EXT Fog coord support\n");
719 This
->gl_info
.supported
[EXT_FOG_COORD
] = TRUE
;
720 } else if (strcmp(ThisExtn
, "GL_EXT_paletted_texture") == 0) { /* handle paletted texture extensions */
721 FIXME(" FOUND: EXT Paletted texture support\n");
722 This
->gl_info
.supported
[EXT_PALETTED_TEXTURE
] = TRUE
;
723 } else if (strcmp(ThisExtn
, "GL_EXT_point_parameters") == 0) {
724 FIXME(" FOUND: EXT Point parameters support\n");
725 This
->gl_info
.supported
[EXT_POINT_PARAMETERS
] = TRUE
;
726 } else if (strcmp(ThisExtn
, "GL_EXT_secondary_color") == 0) {
727 FIXME(" FOUND: EXT Secondary coord support\n");
728 This
->gl_info
.supported
[EXT_SECONDARY_COLOR
] = TRUE
;
729 } else if (strcmp(ThisExtn
, "GL_EXT_texture_compression_s3tc") == 0) {
730 FIXME(" FOUND: EXT Texture S3TC compression support\n");
731 This
->gl_info
.supported
[EXT_TEXTURE_COMPRESSION_S3TC
] = TRUE
;
732 } else if (strcmp(ThisExtn
, "GL_EXT_texture_env_dot3") == 0) {
733 if (FALSE
== This
->gl_info
.supported
[ARB_TEXTURE_ENV_DOT3
]) {
734 FIXME(" FOUND: EXT Dot3 support\n");
735 This
->gl_info
.supported
[ARB_TEXTURE_ENV_DOT3
] = TRUE
;
737 } else if (strcmp(ThisExtn
, "GL_EXT_texture_filter_anisotropic") == 0) {
738 FIXME(" FOUND: EXT Texture Anisotropic filter support\n");
739 This
->gl_info
.supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
] = TRUE
;
740 } else if (strcmp(ThisExtn
, "GL_EXT_texture_lod") == 0) {
741 FIXME(" FOUND: EXT Texture LOD support\n");
742 This
->gl_info
.supported
[EXT_TEXTURE_LOD
] = TRUE
;
743 } else if (strcmp(ThisExtn
, "GL_EXT_texture_lod_bias") == 0) {
744 FIXME(" FOUND: EXT Texture LOD bias support\n");
745 This
->gl_info
.supported
[EXT_TEXTURE_LOD_BIAS
] = TRUE
;
746 } else if (strcmp(ThisExtn
, "GL_EXT_vertex_weighting") == 0) {
747 FIXME(" FOUND: EXT Vertex weighting support\n");
748 This
->gl_info
.supported
[EXT_VERTEX_WEIGHTING
] = TRUE
;
753 } else if (strstr(ThisExtn
, "GL_NV_fragment_program")) {
754 This
->gl_info
.ps_nv_version
= PS_VERSION_11
;
755 FIXME(" FOUND: NVIDIA (NV) Pixel Shader support - version=%02x\n", This
->gl_info
.ps_nv_version
);
756 This
->gl_info
.supported
[NV_FRAGMENT_PROGRAM
] = TRUE
;
757 } else if (strstr(ThisExtn
, "GL_NV_vertex_program")) {
758 This
->gl_info
.vs_nv_version
= max(This
->gl_info
.vs_nv_version
, (0 == strcmp(ThisExtn
, "GL_NV_vertex_program1_1")) ? VS_VERSION_11
: VS_VERSION_10
);
759 This
->gl_info
.vs_nv_version
= max(This
->gl_info
.vs_nv_version
, (0 == strcmp(ThisExtn
, "GL_NV_vertex_program2")) ? VS_VERSION_20
: VS_VERSION_10
);
760 FIXME(" FOUND: NVIDIA (NV) Vertex Shader support - version=%02x\n", This
->gl_info
.vs_nv_version
);
761 This
->gl_info
.supported
[NV_VERTEX_PROGRAM
] = TRUE
;
767 } else if (strcmp(ThisExtn
, "GL_EXT_vertex_shader") == 0) {
768 This
->gl_info
.vs_ati_version
= VS_VERSION_11
;
769 FIXME(" FOUND: ATI (EXT) Vertex Shader support - version=%02x\n", This
->gl_info
.vs_ati_version
);
770 This
->gl_info
.supported
[EXT_VERTEX_SHADER
] = TRUE
;
774 if (*GL_Extensions
== ' ') GL_Extensions
++;
778 #define USE_GL_FUNC(type, pfn) This->gl_info.pfn = (type) glXGetProcAddressARB(#pfn);
782 GLX_Extensions
= glXQueryExtensionsString(display
, DefaultScreen(display
));
783 FIXME("GLX_Extensions reported:\n");
785 if (NULL
== GLX_Extensions
) {
786 ERR(" GLX_Extensions returns NULL\n");
788 while (*GLX_Extensions
!= 0x00) {
789 const char *Start
= GLX_Extensions
;
792 memset(ThisExtn
, 0x00, sizeof(ThisExtn
));
793 while (*GLX_Extensions
!= ' ' && *GLX_Extensions
!= 0x00) {
796 memcpy(ThisExtn
, Start
, (GLX_Extensions
- Start
));
797 FIXME("- %s\n", ThisExtn
);
798 if (*GLX_Extensions
== ' ') GLX_Extensions
++;
802 #define USE_GL_FUNC(type, pfn) This->gl_info.pfn = (type) glXGetProcAddressARB(#pfn);
808 HRESULT WINAPI
IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface
,
809 UINT Adapter
, D3DDEVTYPE DeviceType
, HWND hFocusWindow
,
810 DWORD BehaviourFlags
, D3DPRESENT_PARAMETERS
* pPresentationParameters
,
811 IDirect3DDevice8
** ppReturnedDeviceInterface
) {
812 IDirect3DDevice8Impl
*object
;
815 XVisualInfo
template;
817 ICOM_THIS(IDirect3D8Impl
,iface
);
818 TRACE("(%p)->(Adptr:%d, DevType: %x, FocusHwnd: %p, BehFlags: %lx, PresParms: %p, RetDevInt: %p)\n", This
, Adapter
, DeviceType
,
819 hFocusWindow
, BehaviourFlags
, pPresentationParameters
, ppReturnedDeviceInterface
);
821 /* Allocate the storage for the device */
822 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DDevice8Impl
));
823 if (NULL
== object
) {
824 return D3DERR_OUTOFVIDEOMEMORY
;
826 object
->lpVtbl
= &Direct3DDevice8_Vtbl
;
828 object
->direct3d8
= This
;
829 /** The device AddRef the direct3d8 Interface else crash in propers clients codes */
830 IDirect3D8_AddRef((LPDIRECT3D8
) object
->direct3d8
);
832 /** use StateBlock Factory here, for creating the startup stateBlock */
833 object
->StateBlock
= NULL
;
834 IDirect3DDeviceImpl_CreateStateBlock(object
, D3DSBT_ALL
, NULL
);
835 object
->UpdateStateBlock
= object
->StateBlock
;
837 /* Save the creation parameters */
838 object
->CreateParms
.AdapterOrdinal
= Adapter
;
839 object
->CreateParms
.DeviceType
= DeviceType
;
840 object
->CreateParms
.hFocusWindow
= hFocusWindow
;
841 object
->CreateParms
.BehaviorFlags
= BehaviourFlags
;
843 *ppReturnedDeviceInterface
= (LPDIRECT3DDEVICE8
) object
;
845 /* Initialize settings */
846 object
->PresentParms
.BackBufferCount
= 1; /* Opengl only supports one? */
847 object
->adapterNo
= Adapter
;
848 object
->devType
= DeviceType
;
850 /* Initialize openGl */
853 /*int dblBuf[] = {GLX_STENCIL_SIZE,8,GLX_RGBA,GLX_DEPTH_SIZE,16,GLX_DOUBLEBUFFER,None};*/
854 int dblBuf
[] = {GLX_RGBA
,
855 GLX_STENCIL_SIZE
, 8, /* 2 */
856 GLX_DEPTH_SIZE
, 16, /* 4 */
857 GLX_DOUBLEBUFFER
, None
};
858 /* FIXME: Handle stencil appropriately via EnableAutoDepthStencil / AutoDepthStencilFormat */
860 /* Which hwnd are we using? */
861 /* if (pPresentationParameters->Windowed) { */
862 whichHWND
= pPresentationParameters
->hDeviceWindow
;
864 whichHWND
= hFocusWindow
;
866 object
->win_handle
= whichHWND
;
867 object
->win
= (Window
)GetPropA( whichHWND
, "__wine_x11_client_window" );
870 * whichHWND = (HWND) GetDesktopWindow();
871 * object->win = (Window)GetPropA(whichHWND, "__wine_x11_whole_window" );
876 hDc
= GetDC(whichHWND
);
877 object
->display
= get_display(hDc
);
880 TRACE("(%p)->(DepthStencil:(%u,%s), BackBufferFormat:(%u,%s))\n", This
,
881 pPresentationParameters
->AutoDepthStencilFormat
, debug_d3dformat(pPresentationParameters
->AutoDepthStencilFormat
),
882 pPresentationParameters
->BackBufferFormat
, debug_d3dformat(pPresentationParameters
->BackBufferFormat
));
886 if (TRUE
== pPresentationParameters
->EnableAutoDepthStencil
) {
887 switch (pPresentationParameters
->AutoDepthStencilFormat
) {
888 case D3DFMT_D16_LOCKABLE
: dblBuf
[2] = 8; dblBuf
[4] = 16; break;
889 case D3DFMT_D16
: dblBuf
[2] = 8; dblBuf
[4] = 16; break;
890 case D3DFMT_D15S1
: dblBuf
[2] = 1; dblBuf
[4] = 16; break;
891 case D3DFMT_D24X4S4
: dblBuf
[2] = 4; dblBuf
[4] = 24; break;
892 case D3DFMT_D24S8
: dblBuf
[2] = 8; dblBuf
[4] = 24; break;
893 case D3DFMT_D24X8
: dblBuf
[2] = 8; dblBuf
[4] = 24; break;
894 case D3DFMT_D32
: dblBuf
[2] = 8; dblBuf
[4] = 32; break;
895 default: dblBuf
[2] = 8; dblBuf
[4] = 16; break;
899 switch (pPresentationParameters
->BackBufferFormat
) {
900 case D3DFMT_R3G3B2
: dblBuf
[6] = 3; dblBuf
[8] = 3; dblBuf
[10] = 2; dblBuf
[12] = 0; break;
901 case D3DFMT_R5G6B5
: dblBuf
[6] = 5; dblBuf
[8] = 6; dblBuf
[10] = 5; dblBuf
[12] = 0; break;
902 case D3DFMT_X1R5G5B5
: dblBuf
[6] = 5; dblBuf
[8] = 5; dblBuf
[10] = 5; dblBuf
[12] = 0; break;
903 case D3DFMT_A1R5G5B5
: dblBuf
[6] = 5; dblBuf
[8] = 5; dblBuf
[10] = 5; dblBuf
[12] = 1; break;
904 case D3DFMT_X4R4G4B4
: dblBuf
[6] = 4; dblBuf
[8] = 4; dblBuf
[10] = 4; dblBuf
[12] = 0; break;
905 case D3DFMT_R8G8B8
: dblBuf
[6] = 8; dblBuf
[8] = 8; dblBuf
[10] = 8; dblBuf
[12] = 0; break;
906 case D3DFMT_X8R8G8B8
: dblBuf
[6] = 8; dblBuf
[8] = 8; dblBuf
[10] = 8; dblBuf
[12] = 0; break;
907 case D3DFMT_A8R8G8B8
: dblBuf
[6] = 8; dblBuf
[8] = 8; dblBuf
[10] = 8; dblBuf
[12] = 8; break;
908 default: dblBuf
[6] = 5; dblBuf
[8] = 6; dblBuf
[10] = 5; dblBuf
[12] = 0; break;
913 object
->visInfo
= glXChooseVisual(object
->display
, DefaultScreen(object
->display
), dblBuf
);
914 if (NULL
== object
->visInfo
) {
915 FIXME("cannot choose needed glxVisual with Stencil Buffer\n");
918 * second try using wine initialized visual ...
919 * must be fixed reworking wine-glx init
921 template.visualid
= (VisualID
)GetPropA(GetDesktopWindow(), "__wine_x11_visual_id");
922 object
->visInfo
= XGetVisualInfo(object
->display
, VisualIDMask
, &template, &num
);
923 if (NULL
== object
->visInfo
) {
924 ERR("cannot really get XVisual\n");
926 return D3DERR_NOTAVAILABLE
;
929 object
->glCtx
= glXCreateContext(object
->display
, object
->visInfo
, NULL
, GL_TRUE
);
930 if (NULL
== object
->glCtx
) {
931 ERR("cannot create glxContext\n");
933 return D3DERR_NOTAVAILABLE
;
937 ReleaseDC(whichHWND
, hDc
);
940 if (object
->glCtx
== NULL
) {
941 ERR("Error in context creation !\n");
942 return D3DERR_INVALIDCALL
;
944 TRACE("Context created (HWND=%p, glContext=%p, Window=%ld, VisInfo=%p)\n",
945 whichHWND
, object
->glCtx
, object
->win
, object
->visInfo
);
948 /* If not windowed, need to go fullscreen, and resize the HWND to the appropriate */
950 if (!pPresentationParameters
->Windowed
) {
955 memset(&devmode
, 0, sizeof(DEVMODEW
));
956 devmode
.dmFields
= DM_BITSPERPEL
| DM_PELSWIDTH
| DM_PELSHEIGHT
;
957 MultiByteToWideChar(CP_ACP
, 0, "Gamers CG", -1, devmode
.dmDeviceName
, CCHDEVICENAME
);
958 hdc
= CreateDCA("DISPLAY", NULL
, NULL
, NULL
);
959 bpp
= GetDeviceCaps(hdc
, BITSPIXEL
);
961 devmode
.dmBitsPerPel
= (bpp
>= 24) ? 32 : bpp
;/*Stupid XVidMode cannot change bpp D3DFmtGetBpp(object, pPresentationParameters->BackBufferFormat);*/
962 devmode
.dmPelsWidth
= pPresentationParameters
->BackBufferWidth
;
963 devmode
.dmPelsHeight
= pPresentationParameters
->BackBufferHeight
;
964 ChangeDisplaySettingsExW(devmode
.dmDeviceName
, &devmode
, object
->win_handle
, CDS_FULLSCREEN
, NULL
);
966 FIXME("Requested full screen support not implemented, expect windowed operation\n");
969 /* Make popup window */
970 ShowWindow(whichHWND
, SW_HIDE
);
971 SetWindowLongA(whichHWND
, GWL_STYLE
, WS_POPUP
);
972 SetWindowPos(object
->win_handle
, HWND_TOP
, 0, 0,
973 pPresentationParameters
->BackBufferWidth
,
974 pPresentationParameters
->BackBufferHeight
, SWP_SHOWWINDOW
| SWP_FRAMECHANGED
);
975 ShowWindow(whichHWND
, SW_SHOW
);
978 TRACE("Creating back buffer\n");
979 /* MSDN: If Windowed is TRUE and either of the BackBufferWidth/Height values is zero,
980 then the corresponding dimension of the client area of the hDeviceWindow
981 (or the focus window, if hDeviceWindow is NULL) is taken. */
982 if (pPresentationParameters
->Windowed
&& ((pPresentationParameters
->BackBufferWidth
== 0) ||
983 (pPresentationParameters
->BackBufferHeight
== 0))) {
986 GetClientRect(whichHWND
, &Rect
);
988 if (pPresentationParameters
->BackBufferWidth
== 0) {
989 pPresentationParameters
->BackBufferWidth
= Rect
.right
;
990 TRACE("Updating width to %d\n", pPresentationParameters
->BackBufferWidth
);
992 if (pPresentationParameters
->BackBufferHeight
== 0) {
993 pPresentationParameters
->BackBufferHeight
= Rect
.bottom
;
994 TRACE("Updating height to %d\n", pPresentationParameters
->BackBufferHeight
);
998 /* Save the presentation parms now filled in correctly */
999 memcpy(&object
->PresentParms
, pPresentationParameters
, sizeof(D3DPRESENT_PARAMETERS
));
1002 IDirect3DDevice8Impl_CreateRenderTarget((LPDIRECT3DDEVICE8
) object
,
1003 pPresentationParameters
->BackBufferWidth
,
1004 pPresentationParameters
->BackBufferHeight
,
1005 pPresentationParameters
->BackBufferFormat
,
1006 pPresentationParameters
->MultiSampleType
,
1008 (LPDIRECT3DSURFACE8
*) &object
->frontBuffer
);
1010 IDirect3DDevice8Impl_CreateRenderTarget((LPDIRECT3DDEVICE8
) object
,
1011 pPresentationParameters
->BackBufferWidth
,
1012 pPresentationParameters
->BackBufferHeight
,
1013 pPresentationParameters
->BackBufferFormat
,
1014 pPresentationParameters
->MultiSampleType
,
1016 (LPDIRECT3DSURFACE8
*) &object
->backBuffer
);
1018 if (pPresentationParameters
->EnableAutoDepthStencil
) {
1019 IDirect3DDevice8Impl_CreateDepthStencilSurface((LPDIRECT3DDEVICE8
) object
,
1020 pPresentationParameters
->BackBufferWidth
,
1021 pPresentationParameters
->BackBufferHeight
,
1022 pPresentationParameters
->AutoDepthStencilFormat
,
1023 D3DMULTISAMPLE_NONE
,
1024 (LPDIRECT3DSURFACE8
*) &object
->depthStencilBuffer
);
1026 object
->depthStencilBuffer
= NULL
;
1029 /* init the default renderTarget management */
1030 object
->drawable
= object
->win
;
1031 object
->render_ctx
= object
->glCtx
;
1032 object
->renderTarget
= object
->frontBuffer
;
1033 IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8
) object
->renderTarget
);
1034 object
->stencilBufferTarget
= object
->depthStencilBuffer
;
1035 if (NULL
!= object
->stencilBufferTarget
) {
1036 IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8
) object
->stencilBufferTarget
);
1041 if (glXMakeCurrent(object
->display
, object
->win
, object
->glCtx
) == False
) {
1042 ERR("Error in setting current context (context %p drawable %ld)!\n", object
->glCtx
, object
->win
);
1044 checkGLcall("glXMakeCurrent");
1046 /* Clear the screen */
1047 glClearColor(1.0, 0.0, 0.0, 0.0);
1048 checkGLcall("glClearColor");
1049 glColor3f(1.0, 1.0, 1.0);
1050 checkGLcall("glColor3f");
1052 glEnable(GL_LIGHTING
);
1053 checkGLcall("glEnable");
1055 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, GL_TRUE
);
1056 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);");
1058 glTexEnvf(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_COMBINE_EXT
);
1059 checkGLcall("glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);");
1061 glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL
, GL_SEPARATE_SPECULAR_COLOR
);
1062 checkGLcall("glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);");
1065 * Initialize openGL extension related variables
1066 * with Default values
1068 IDirect3D8Impl_FillGLCaps(iface
, object
->display
);
1070 /* Setup all the devices defaults */
1071 IDirect3DDeviceImpl_InitStartupStateBlock(object
);
1075 { /* Set a default viewport */
1079 vp
.Width
= pPresentationParameters
->BackBufferWidth
;
1080 vp
.Height
= pPresentationParameters
->BackBufferHeight
;
1083 IDirect3DDevice8Impl_SetViewport((LPDIRECT3DDEVICE8
) object
, &vp
);
1086 /* Initialize the current view state */
1087 object
->modelview_valid
= 1;
1088 object
->proj_valid
= 0;
1089 object
->view_ident
= 1;
1090 object
->last_was_rhw
= 0;
1092 TRACE("(%p,%d) All defaults now set up, leaving CreateDevice\n", This
, Adapter
);
1096 ICOM_VTABLE(IDirect3D8
) Direct3D8_Vtbl
=
1098 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1099 IDirect3D8Impl_QueryInterface
,
1100 IDirect3D8Impl_AddRef
,
1101 IDirect3D8Impl_Release
,
1102 IDirect3D8Impl_RegisterSoftwareDevice
,
1103 IDirect3D8Impl_GetAdapterCount
,
1104 IDirect3D8Impl_GetAdapterIdentifier
,
1105 IDirect3D8Impl_GetAdapterModeCount
,
1106 IDirect3D8Impl_EnumAdapterModes
,
1107 IDirect3D8Impl_GetAdapterDisplayMode
,
1108 IDirect3D8Impl_CheckDeviceType
,
1109 IDirect3D8Impl_CheckDeviceFormat
,
1110 IDirect3D8Impl_CheckDeviceMultiSampleType
,
1111 IDirect3D8Impl_CheckDepthStencilMatch
,
1112 IDirect3D8Impl_GetDeviceCaps
,
1113 IDirect3D8Impl_GetAdapterMonitor
,
1114 IDirect3D8Impl_CreateDevice