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
25 #define NONAMELESSUNION
26 #define NONAMELESSSTRUCT
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
34 #include "d3d8_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
38 /* x11drv GDI escapes */
39 #define X11DRV_ESCAPE 6789
40 enum x11drv_escape_codes
42 X11DRV_GET_DISPLAY
, /* get X11 display for a DC */
43 X11DRV_GET_DRAWABLE
, /* get current drawable for a DC */
44 X11DRV_GET_FONT
, /* get current X font for a DC */
48 static const D3DFORMAT device_formats
[NUM_FORMATS
] = {
59 /* retrieve the X display to use on a given DC */
60 inline static Display
*get_display( HDC hdc
)
63 enum x11drv_escape_codes escape
= X11DRV_GET_DISPLAY
;
65 if (!ExtEscape( hdc
, X11DRV_ESCAPE
, sizeof(escape
), (LPCSTR
)&escape
,
66 sizeof(display
), (LPSTR
)&display
)) display
= NULL
;
71 /* IDirect3D IUnknown parts follow: */
72 HRESULT WINAPI
IDirect3D8Impl_QueryInterface(LPDIRECT3D8 iface
,REFIID riid
,LPVOID
*ppobj
)
74 ICOM_THIS(IDirect3D8Impl
,iface
);
76 if (IsEqualGUID(riid
, &IID_IUnknown
)
77 || IsEqualGUID(riid
, &IID_IDirect3D8
)) {
78 IDirect3D8Impl_AddRef(iface
);
83 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
87 ULONG WINAPI
IDirect3D8Impl_AddRef(LPDIRECT3D8 iface
) {
88 ICOM_THIS(IDirect3D8Impl
,iface
);
89 TRACE("(%p) : AddRef from %ld\n", This
, This
->ref
);
93 ULONG WINAPI
IDirect3D8Impl_Release(LPDIRECT3D8 iface
) {
94 ICOM_THIS(IDirect3D8Impl
,iface
);
95 ULONG ref
= --This
->ref
;
96 TRACE("(%p) : ReleaseRef to %ld\n", This
, This
->ref
);
98 HeapFree(GetProcessHeap(), 0, This
);
102 /* IDirect3D Interface follow: */
103 HRESULT WINAPI
IDirect3D8Impl_RegisterSoftwareDevice (LPDIRECT3D8 iface
, void* pInitializeFunction
) {
104 ICOM_THIS(IDirect3D8Impl
,iface
);
105 FIXME("(%p)->(%p): stub\n", This
, pInitializeFunction
);
109 UINT WINAPI
IDirect3D8Impl_GetAdapterCount (LPDIRECT3D8 iface
) {
110 ICOM_THIS(IDirect3D8Impl
,iface
);
111 /* FIXME: Set to one for now to imply the display */
112 TRACE("(%p): Mostly stub, only returns primary display\n", This
);
116 HRESULT WINAPI
IDirect3D8Impl_GetAdapterIdentifier (LPDIRECT3D8 iface
,
117 UINT Adapter
, DWORD Flags
, D3DADAPTER_IDENTIFIER8
* pIdentifier
) {
118 ICOM_THIS(IDirect3D8Impl
,iface
);
120 TRACE("(%p}->(Adapter: %d, Flags: %lx, pId=%p)\n", This
, Adapter
, Flags
, pIdentifier
);
122 if (Adapter
>= IDirect3D8Impl_GetAdapterCount(iface
)) {
123 return D3DERR_INVALIDCALL
;
126 if (Adapter
== 0) { /* Display */
127 strcpy(pIdentifier
->Driver
, "Display");
128 strcpy(pIdentifier
->Description
, "Direct3D Display");
129 pIdentifier
->DriverVersion
.s
.HighPart
= 1;
130 pIdentifier
->DriverVersion
.s
.LowPart
= 0;
131 pIdentifier
->VendorId
= 0;
132 pIdentifier
->DeviceId
= 0;
133 pIdentifier
->SubSysId
= 0;
134 pIdentifier
->Revision
= 0;
135 /*FIXME: memcpy(&pIdentifier->DeviceIdentifier, ??, sizeof(??GUID)); */
136 if (Flags
& D3DENUM_NO_WHQL_LEVEL
) {
137 pIdentifier
->WHQLLevel
= 0;
139 pIdentifier
->WHQLLevel
= 1;
142 FIXME("Adapter not primary display\n");
148 UINT WINAPI
IDirect3D8Impl_GetAdapterModeCount (LPDIRECT3D8 iface
,
150 ICOM_THIS(IDirect3D8Impl
,iface
);
152 TRACE("(%p}->(Adapter: %d)\n", This
, Adapter
);
154 if (Adapter
>= IDirect3D8Impl_GetAdapterCount(iface
)) {
155 return D3DERR_INVALIDCALL
;
158 if (Adapter
== 0) { /* Display */
162 while (EnumDisplaySettingsExW(NULL
, i
, &DevModeW
, 0)) {
165 TRACE("(%p}->(Adapter: %d) => %d\n", This
, Adapter
, i
);
168 FIXME("Adapter not primary display\n");
174 HRESULT WINAPI
IDirect3D8Impl_EnumAdapterModes (LPDIRECT3D8 iface
,
175 UINT Adapter
, UINT Mode
, D3DDISPLAYMODE
* pMode
) {
176 ICOM_THIS(IDirect3D8Impl
,iface
);
178 TRACE("(%p}->(Adapter:%d, mode:%d, pMode:%p)\n", This
, Adapter
, Mode
, pMode
);
180 if (Adapter
>= IDirect3D8Impl_GetAdapterCount(iface
)) {
181 return D3DERR_INVALIDCALL
;
184 if (Adapter
== 0) { /* Display */
189 if (EnumDisplaySettingsExW(NULL
, Mode
, &DevModeW
, 0))
191 pMode
->Width
= DevModeW
.dmPelsWidth
;
192 pMode
->Height
= DevModeW
.dmPelsHeight
;
193 bpp
= DevModeW
.dmBitsPerPel
;
194 pMode
->RefreshRate
= D3DADAPTER_DEFAULT
;
195 if (DevModeW
.dmFields
&DM_DISPLAYFREQUENCY
)
197 pMode
->RefreshRate
= DevModeW
.dmDisplayFrequency
;
202 TRACE("Requested mode out of range %d\n", Mode
);
203 return D3DERR_INVALIDCALL
;
206 hdc
= CreateDCA("DISPLAY", NULL
, NULL
, NULL
);
207 bpp
= min(GetDeviceCaps(hdc
, BITSPIXEL
), bpp
);
211 case 8: pMode
->Format
= D3DFMT_R3G3B2
; break;
212 case 16: pMode
->Format
= D3DFMT_R5G6B5
; break;
213 case 24: /* pMode->Format = D3DFMT_R5G6B5; break;*/ /* Make 24bit appear as 32 bit */
214 case 32: pMode
->Format
= D3DFMT_A8R8G8B8
; break;
215 default: pMode
->Format
= D3DFMT_UNKNOWN
;
217 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
);
220 FIXME("Adapter not primary display\n");
226 HRESULT WINAPI
IDirect3D8Impl_GetAdapterDisplayMode (LPDIRECT3D8 iface
,
227 UINT Adapter
, D3DDISPLAYMODE
* pMode
) {
228 ICOM_THIS(IDirect3D8Impl
,iface
);
229 TRACE("(%p}->(Adapter: %d, pMode: %p)\n", This
, Adapter
, pMode
);
231 if (Adapter
>= IDirect3D8Impl_GetAdapterCount(iface
)) {
232 return D3DERR_INVALIDCALL
;
235 if (Adapter
== 0) { /* Display */
239 EnumDisplaySettingsExW(NULL
, (DWORD
)-1, &DevModeW
, 0);
240 pMode
->Width
= DevModeW
.dmPelsWidth
;
241 pMode
->Height
= DevModeW
.dmPelsHeight
;
242 bpp
= DevModeW
.dmBitsPerPel
;
243 pMode
->RefreshRate
= D3DADAPTER_DEFAULT
;
244 if (DevModeW
.dmFields
&DM_DISPLAYFREQUENCY
)
246 pMode
->RefreshRate
= DevModeW
.dmDisplayFrequency
;
250 case 8: pMode
->Format
= D3DFMT_R3G3B2
; break;
251 case 16: pMode
->Format
= D3DFMT_R5G6B5
; break;
252 case 24: /*pMode->Format = D3DFMT_R5G6B5; break;*/ /* Make 24bit appear as 32 bit */
253 case 32: pMode
->Format
= D3DFMT_A8R8G8B8
; break;
254 default: pMode
->Format
= D3DFMT_UNKNOWN
;
258 FIXME("Adapter not primary display\n");
261 TRACE("returning w:%d, h:%d, ref:%d, fmt:%x\n", pMode
->Width
,
262 pMode
->Height
, pMode
->RefreshRate
, pMode
->Format
);
266 HRESULT WINAPI
IDirect3D8Impl_CheckDeviceType (LPDIRECT3D8 iface
,
267 UINT Adapter
, D3DDEVTYPE CheckType
, D3DFORMAT DisplayFormat
,
268 D3DFORMAT BackBufferFormat
, BOOL Windowed
) {
269 ICOM_THIS(IDirect3D8Impl
,iface
);
270 FIXME("(%p)->(Adptr:%d, CheckType:(%x,%s), DispFmt:(%x,%s), BackBuf:(%x,%s), Win?%d): stub\n",
273 CheckType
, debug_d3ddevicetype(CheckType
),
274 DisplayFormat
, debug_d3dformat(DisplayFormat
),
275 BackBufferFormat
, debug_d3dformat(BackBufferFormat
),
280 HRESULT WINAPI
IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 iface
,
281 UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT AdapterFormat
,
282 DWORD Usage
, D3DRESOURCETYPE RType
, D3DFORMAT CheckFormat
) {
283 ICOM_THIS(IDirect3D8Impl
,iface
);
284 FIXME("(%p)->(Adptr:%d, DevType:(%u,%s), AdptFmt:(%u,%s), Use:(%lu,%s), ResTyp:(%x,%s), CheckFmt:(%u,%s))\n",
287 DeviceType
, debug_d3ddevicetype(DeviceType
),
288 AdapterFormat
, debug_d3dformat(AdapterFormat
),
289 Usage
, debug_d3dusage(Usage
),
290 RType
, debug_d3dressourcetype(RType
),
291 CheckFormat
, debug_d3dformat(CheckFormat
));
293 if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC
)) {
294 switch (CheckFormat
) {
300 break; /* Avoid compiler warnings */
304 switch (CheckFormat
) {
312 case D3DFMT_X8L8V8U8
:
315 /* Since we do not support these formats right now, don't pretend to. */
316 return D3DERR_NOTAVAILABLE
;
324 HRESULT WINAPI
IDirect3D8Impl_CheckDeviceMultiSampleType(LPDIRECT3D8 iface
,
325 UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT SurfaceFormat
,
326 BOOL Windowed
, D3DMULTISAMPLE_TYPE MultiSampleType
) {
327 ICOM_THIS(IDirect3D8Impl
,iface
);
328 FIXME("(%p)->(Adptr:%d, DevType:(%x,%s), SurfFmt:(%x,%s), Win?%d, MultiSamp:%x)\n",
331 DeviceType
, debug_d3ddevicetype(DeviceType
),
332 SurfaceFormat
, debug_d3dformat(SurfaceFormat
),
336 if (D3DMULTISAMPLE_NONE
== MultiSampleType
)
338 return D3DERR_NOTAVAILABLE
;
341 HRESULT WINAPI
IDirect3D8Impl_CheckDepthStencilMatch(LPDIRECT3D8 iface
,
342 UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT AdapterFormat
,
343 D3DFORMAT RenderTargetFormat
, D3DFORMAT DepthStencilFormat
) {
344 ICOM_THIS(IDirect3D8Impl
,iface
);
345 FIXME("(%p)->(Adptr:%d, DevType:(%x,%s), AdptFmt:(%x,%s), RendrTgtFmt:(%x,%s), DepthStencilFmt:(%x,%s))\n",
348 DeviceType
, debug_d3ddevicetype(DeviceType
),
349 AdapterFormat
, debug_d3dformat(AdapterFormat
),
350 RenderTargetFormat
, debug_d3dformat(RenderTargetFormat
),
351 DepthStencilFormat
, debug_d3dformat(DepthStencilFormat
));
354 switch (DepthStencilFormat
) {
360 * as i don't know how to really check hard caps of graphics cards
361 * i prefer to not permit 32bit zbuffers enumeration (as few cards can do it)
363 return D3DERR_NOTAVAILABLE
;
371 HRESULT WINAPI
IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface
, UINT Adapter
, D3DDEVTYPE DeviceType
, D3DCAPS8
* pCaps
) {
373 BOOL gotContext
= FALSE
;
374 BOOL created
= FALSE
;
375 GLint gl_tex_size
= 0;
376 GLXContext gl_context
= 0;
377 Display
*display
= NULL
;
378 ICOM_THIS(IDirect3D8Impl
,iface
);
380 TRACE("(%p)->(Adptr:%d, DevType: %x, pCaps: %p)\n", This
, Adapter
, DeviceType
, pCaps
);
382 /* Note: GL seems to trap if GetDeviceCaps is called before any HWND's created
383 ie there is no GL Context - Get a default rendering context to enable the
384 function query some info from GL */
385 if (glXGetCurrentContext() == NULL
) {
387 XVisualInfo
template;
391 Drawable drawable
= (Drawable
) GetPropA(GetDesktopWindow(), "__wine_x11_whole_window");
392 XWindowAttributes win_attr
;
396 /* Get the display */
397 device_context
= GetDC(0);
398 display
= get_display(device_context
);
399 ReleaseDC(0, device_context
);
401 /* Get the X visual */
403 if (XGetWindowAttributes(display
, drawable
, &win_attr
)) {
404 visual
= win_attr
.visual
;
406 visual
= DefaultVisual(display
, DefaultScreen(display
));
408 template.visualid
= XVisualIDFromVisual(visual
);
409 vis
= XGetVisualInfo(display
, VisualIDMask
, &template, &num
);
412 WARN("Error creating visual info for capabilities initialization\n");
416 /* Create a GL context */
418 gl_context
= glXCreateContext(display
, vis
, NULL
, GL_TRUE
);
420 if (gl_context
== NULL
) {
422 WARN("Error creating default context for capabilities initialization\n");
427 /* Make it the current GL context */
428 if (!failed
&& glXMakeCurrent(display
, drawable
, gl_context
) == False
) {
429 glXDestroyContext(display
, gl_context
);
431 WARN("Error setting default context as current for capabilities initialization\n");
435 /* It worked! Wow... */
444 if (gotContext
== FALSE
) {
446 FIXME("GetDeviceCaps called but no GL Context - Returning dummy values\n");
448 pCaps
->MaxTextureBlendStages
= 2;
449 pCaps
->MaxSimultaneousTextures
= 2;
450 pCaps
->MaxUserClipPlanes
= 8;
451 pCaps
->MaxActiveLights
= 8;
452 pCaps
->MaxVertexBlendMatrices
= 0;
453 pCaps
->MaxVertexBlendMatrixIndex
= 1;
454 pCaps
->MaxAnisotropy
= 0;
455 pCaps
->MaxPointSize
= 255.0;
457 glGetIntegerv(GL_MAX_TEXTURE_SIZE
, &gl_tex_size
);
459 pCaps
->DeviceType
= (DeviceType
== D3DDEVTYPE_HAL
) ? D3DDEVTYPE_HAL
: D3DDEVTYPE_REF
; /* Not quite true, but use h/w supported by opengl I suppose */
460 pCaps
->AdapterOrdinal
= Adapter
;
463 pCaps
->Caps2
= D3DCAPS2_CANRENDERWINDOWED
;
464 pCaps
->Caps3
= D3DDEVCAPS_HWTRANSFORMANDLIGHT
;
465 pCaps
->PresentationIntervals
= D3DPRESENT_INTERVAL_IMMEDIATE
;
467 pCaps
->CursorCaps
= 0;
469 pCaps
->DevCaps
= D3DDEVCAPS_DRAWPRIMTLVERTEX
|
470 D3DDEVCAPS_HWTRANSFORMANDLIGHT
|
471 D3DDEVCAPS_PUREDEVICE
;
473 pCaps
->PrimitiveMiscCaps
= D3DPMISCCAPS_CULLCCW
|
474 D3DPMISCCAPS_CULLCW
|
475 D3DPMISCCAPS_COLORWRITEENABLE
|
476 D3DPMISCCAPS_CLIPTLVERTS
|
477 D3DPMISCCAPS_CLIPPLANESCALEDPOINTS
|
479 /*NOT: D3DPMISCCAPS_TSSARGTEMP*/
481 pCaps
->RasterCaps
= D3DPRASTERCAPS_DITHER
|
483 D3DPRASTERCAPS_FOGRANGE
;
485 D3DPRASTERCAPS_FOGVERTEX
486 D3DPRASTERCAPS_FOGTABLE
487 D3DPRASTERCAPS_MIPMAPLODBIAS
489 D3DPRASTERCAPS_ANISOTROPY
492 D3DPRASTERCAPS_COLORPERSPECTIVE
493 D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE
494 D3DPRASTERCAPS_ANTIALIASEDGES
495 D3DPRASTERCAPS_ZBUFFERLESSHSR
496 D3DPRASTERCAPS_WBUFFER */
498 pCaps
->ZCmpCaps
= D3DPCMPCAPS_ALWAYS
|
500 D3DPCMPCAPS_GREATER
|
501 D3DPCMPCAPS_GREATEREQUAL
|
503 D3DPCMPCAPS_LESSEQUAL
|
505 D3DPCMPCAPS_NOTEQUAL
;
507 pCaps
->SrcBlendCaps
= 0xFFFFFFFF; /*FIXME: Tidy up later */
508 pCaps
->DestBlendCaps
= 0xFFFFFFFF; /*FIXME: Tidy up later */
509 pCaps
->AlphaCmpCaps
= 0xFFFFFFFF; /*FIXME: Tidy up later */
511 pCaps
->ShadeCaps
= D3DPSHADECAPS_SPECULARGOURAUDRGB
|
512 D3DPSHADECAPS_COLORGOURAUDRGB
;
514 pCaps
->TextureCaps
= D3DPTEXTURECAPS_ALPHA
|
515 D3DPTEXTURECAPS_ALPHAPALETTE
|
516 D3DPTEXTURECAPS_POW2
|
517 D3DPTEXTURECAPS_VOLUMEMAP
|
518 D3DPTEXTURECAPS_MIPMAP
;
519 #if defined(GL_VERSION_1_3) || defined(GL_ARB_texture_cube_map)
520 pCaps
->TextureCaps
|= D3DPTEXTURECAPS_CUBEMAP
|
521 D3DPTEXTURECAPS_MIPCUBEMAP
|
522 D3DPTEXTURECAPS_CUBEMAP_POW2
;
525 pCaps
->TextureFilterCaps
= D3DPTFILTERCAPS_MAGFLINEAR
|
526 D3DPTFILTERCAPS_MAGFPOINT
|
527 D3DPTFILTERCAPS_MINFLINEAR
|
528 D3DPTFILTERCAPS_MINFPOINT
|
529 D3DPTFILTERCAPS_MIPFLINEAR
|
530 D3DPTFILTERCAPS_MIPFPOINT
;
532 pCaps
->CubeTextureFilterCaps
= 0;
533 pCaps
->VolumeTextureFilterCaps
= 0;
535 pCaps
->TextureAddressCaps
= D3DPTADDRESSCAPS_BORDER
|
536 D3DPTADDRESSCAPS_CLAMP
|
537 D3DPTADDRESSCAPS_WRAP
;
538 #if defined(GL_VERSION_1_3)
539 pCaps
->TextureAddressCaps
|= D3DPTADDRESSCAPS_MIRROR
;
542 D3DPTADDRESSCAPS_BORDER
543 D3DPTADDRESSCAPS_MIRRORONCE */
545 pCaps
->VolumeTextureAddressCaps
= 0;
547 pCaps
->LineCaps
= D3DLINECAPS_TEXTURE
|
554 pCaps
->MaxTextureWidth
= gl_tex_size
;
555 pCaps
->MaxTextureHeight
= gl_tex_size
;
557 pCaps
->MaxVolumeExtent
= 0;
559 pCaps
->MaxTextureRepeat
= 32768;
560 pCaps
->MaxTextureAspectRatio
= 32768;
561 pCaps
->MaxVertexW
= 1.0;
563 pCaps
->GuardBandLeft
= 0;
564 pCaps
->GuardBandTop
= 0;
565 pCaps
->GuardBandRight
= 0;
566 pCaps
->GuardBandBottom
= 0;
568 pCaps
->ExtentsAdjust
= 0;
570 pCaps
->StencilCaps
= D3DSTENCILCAPS_DECRSAT
|
571 D3DSTENCILCAPS_INCRSAT
|
572 D3DSTENCILCAPS_INVERT
|
573 D3DSTENCILCAPS_KEEP
|
574 D3DSTENCILCAPS_REPLACE
|
576 #if defined(GL_VERSION_1_4) || defined(GL_EXT_stencil_wrap)
577 pCaps
->StencilCaps
|= D3DSTENCILCAPS_DECR
|
581 pCaps
->FVFCaps
= D3DFVFCAPS_PSIZE
| 0x80000;
583 pCaps
->TextureOpCaps
= D3DTEXOPCAPS_ADD
|
584 D3DTEXOPCAPS_ADDSIGNED
|
585 D3DTEXOPCAPS_ADDSIGNED2X
|
586 D3DTEXOPCAPS_MODULATE
|
587 D3DTEXOPCAPS_MODULATE2X
|
588 D3DTEXOPCAPS_MODULATE4X
|
589 D3DTEXOPCAPS_SELECTARG1
|
590 D3DTEXOPCAPS_SELECTARG2
|
591 D3DTEXOPCAPS_DISABLE
;
592 #if defined(GL_VERSION_1_3)
593 pCaps
->TextureOpCaps
|= D3DTEXOPCAPS_DOTPRODUCT3
|
594 D3DTEXOPCAPS_SUBTRACT
;
597 D3DTEXOPCAPS_ADDSMOOTH
598 D3DTEXOPCAPS_BLENDCURRENTALPHA
599 D3DTEXOPCAPS_BLENDDIFFUSEALPHA
600 D3DTEXOPCAPS_BLENDFACTORALPHA
601 D3DTEXOPCAPS_BLENDTEXTUREALPHA
602 D3DTEXOPCAPS_BLENDTEXTUREALPHAPM
603 D3DTEXOPCAPS_BUMPENVMAP
604 D3DTEXOPCAPS_BUMPENVMAPLUMINANCE
606 D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
607 D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
608 D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR
609 D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA
610 D3DTEXOPCAPS_MULTIPLYADD
611 D3DTEXOPCAPS_PREMODULATE */
616 #if defined(GL_VERSION_1_3)
617 glGetIntegerv(GL_MAX_TEXTURE_UNITS
, &gl_max
);
619 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB
, &gl_max
);
621 TRACE("GLCaps: GL_MAX_TEXTURE_UNITS_ARB=%d\n", gl_max
);
622 pCaps
->MaxTextureBlendStages
= min(8, gl_max
);
623 pCaps
->MaxSimultaneousTextures
= min(8, gl_max
);
625 glGetIntegerv(GL_MAX_CLIP_PLANES
, &gl_max
);
626 pCaps
->MaxUserClipPlanes
= min(MAX_CLIPPLANES
, gl_max
);
627 TRACE("GLCaps: GL_MAX_CLIP_PLANES=%ld\n", pCaps
->MaxUserClipPlanes
);
629 glGetIntegerv(GL_MAX_LIGHTS
, &gl_max
);
630 pCaps
->MaxActiveLights
= gl_max
;
631 TRACE("GLCaps: GL_MAX_LIGHTS=%ld\n", pCaps
->MaxActiveLights
);
633 #if defined(GL_ARB_vertex_blend)
634 glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB
, &gl_max
);
635 pCaps
->MaxVertexBlendMatrices
= gl_max
;
636 pCaps
->MaxVertexBlendMatrixIndex
= 1;
638 pCaps
->MaxVertexBlendMatrices
= 0;
639 pCaps
->MaxVertexBlendMatrixIndex
= 1;
642 #if defined(GL_EXT_texture_filter_anisotropic)
643 glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
, &gl_max
);
644 pCaps
->MaxAnisotropy
= gl_max
;
646 pCaps
->MaxAnisotropy
= 0;
649 glGetFloatv(GL_POINT_SIZE_RANGE
, &gl_float
);
650 pCaps
->MaxPointSize
= gl_float
;
653 pCaps
->VertexProcessingCaps
= D3DVTXPCAPS_DIRECTIONALLIGHTS
|
654 D3DVTXPCAPS_MATERIALSOURCE7
|
655 D3DVTXPCAPS_POSITIONALLIGHTS
|
658 D3DVTXPCAPS_LOCALVIEWER
659 D3DVTXPCAPS_TWEENING */
661 pCaps
->MaxPrimitiveCount
= 0xFFFFFFFF;
662 pCaps
->MaxVertexIndex
= 0xFFFFFFFF;
663 pCaps
->MaxStreams
= MAX_STREAMS
;
664 pCaps
->MaxStreamStride
= 1024;
667 pCaps
->VertexShaderVersion
= D3DVS_VERSION(1,1);
668 pCaps
->MaxVertexShaderConst
= D3D8_VSHADER_MAX_CONSTANTS
;
670 pCaps
->VertexShaderVersion
= 0;
671 pCaps
->MaxVertexShaderConst
= D3D8_VSHADER_MAX_CONSTANTS
;
675 pCaps
->PixelShaderVersion
= D3DPS_VERSION(1,1);
676 pCaps
->MaxPixelShaderValue
= 1.0;
678 pCaps
->PixelShaderVersion
= 0;
679 pCaps
->MaxPixelShaderValue
= 0.0;
682 /* If we created a dummy context, throw it away */
684 glXMakeCurrent(display
, None
, NULL
);
685 glXDestroyContext(display
, gl_context
);
691 HMONITOR WINAPI
IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface
, UINT Adapter
) {
692 ICOM_THIS(IDirect3D8Impl
,iface
);
693 FIXME("(%p)->(Adptr:%d)\n", This
, Adapter
);
698 static void IDirect3D8Impl_FillGLCaps(LPDIRECT3D8 iface
, Display
* display
) {
699 const char *GL_Extensions
= NULL
;
700 const char *GLX_Extensions
= NULL
;
702 ICOM_THIS(IDirect3D8Impl
,iface
);
705 * Initialize openGL extension related variables
706 * with Default values
708 memset(&This
->gl_info
.supported
, 0, sizeof(This
->gl_info
.supported
));
709 This
->gl_info
.max_textures
= 1;
710 This
->gl_info
.ps_arb_version
= PS_VERSION_NOT_SUPPORTED
;
711 This
->gl_info
.vs_arb_version
= VS_VERSION_NOT_SUPPORTED
;
712 This
->gl_info
.vs_nv_version
= VS_VERSION_NOT_SUPPORTED
;
713 This
->gl_info
.vs_ati_version
= VS_VERSION_NOT_SUPPORTED
;
715 #define USE_GL_FUNC(type, pfn) This->gl_info.pfn = NULL;
719 /* Retrieve opengl defaults */
720 glGetIntegerv(GL_MAX_CLIP_PLANES
, &gl_max
);
721 This
->gl_info
.max_clipplanes
= min(MAX_CLIPPLANES
, gl_max
);
722 TRACE("ClipPlanes support - num Planes=%d\n", gl_max
);
724 glGetIntegerv(GL_MAX_LIGHTS
, &gl_max
);
725 This
->gl_info
.max_lights
= gl_max
;
726 TRACE("Lights support - max lights=%d\n", gl_max
);
728 /* Parse the gl supported features, in theory enabling parts of our code appropriately */
729 GL_Extensions
= glGetString(GL_EXTENSIONS
);
730 FIXME("GL_Extensions reported:\n");
732 if (NULL
== GL_Extensions
) {
733 ERR(" GL_Extensions returns NULL\n");
735 while (*GL_Extensions
!= 0x00) {
736 const char *Start
= GL_Extensions
;
739 memset(ThisExtn
, 0x00, sizeof(ThisExtn
));
740 while (*GL_Extensions
!= ' ' && *GL_Extensions
!= 0x00) {
743 memcpy(ThisExtn
, Start
, (GL_Extensions
- Start
));
744 FIXME("- %s\n", ThisExtn
);
749 if (strcmp(ThisExtn
, "GL_ARB_fragment_program") == 0) {
750 This
->gl_info
.ps_arb_version
= PS_VERSION_11
;
751 FIXME(" FOUND: ARB Pixel Shader support - version=%02x\n", This
->gl_info
.ps_arb_version
);
752 This
->gl_info
.supported
[ARB_FRAGMENT_PROGRAM
] = TRUE
;
753 } else if (strcmp(ThisExtn
, "GL_ARB_multisample") == 0) {
754 FIXME(" FOUND: ARB Multisample support\n");
755 This
->gl_info
.supported
[ARB_MULTISAMPLE
] = TRUE
;
756 } else if (strcmp(ThisExtn
, "GL_ARB_multitexture") == 0) {
757 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB
, &gl_max
);
758 FIXME(" FOUND: ARB Multitexture support - GL_MAX_TEXTURE_UNITS_ARB=%u\n", gl_max
);
759 This
->gl_info
.supported
[ARB_MULTITEXTURE
] = TRUE
;
760 This
->gl_info
.max_textures
= min(8, gl_max
);
761 } else if (strcmp(ThisExtn
, "GL_ARB_texture_cube_map") == 0) {
762 FIXME(" FOUND: ARB Texture Cube Map support\n");
763 This
->gl_info
.supported
[ARB_TEXTURE_CUBE_MAP
] = TRUE
;
764 } else if (strcmp(ThisExtn
, "GL_ARB_texture_compression") == 0) {
765 FIXME(" FOUND: ARB Texture Compression support\n");
766 This
->gl_info
.supported
[ARB_TEXTURE_COMPRESSION
] = TRUE
;
767 } else if (strcmp(ThisExtn
, "GL_ARB_texture_env_combine") == 0) {
768 FIXME(" FOUND: EXT Texture Env combine support\n");
769 This
->gl_info
.supported
[ARB_TEXTURE_ENV_COMBINE
] = TRUE
;
770 } else if (strcmp(ThisExtn
, "GL_ARB_texture_env_dot3") == 0) {
771 if (FALSE
== This
->gl_info
.supported
[ARB_TEXTURE_ENV_DOT3
]) {
772 FIXME(" FOUND: EXT Dot3 support\n");
773 This
->gl_info
.supported
[ARB_TEXTURE_ENV_DOT3
] = TRUE
;
775 } else if (strstr(ThisExtn
, "GL_ARB_vertex_program")) {
776 This
->gl_info
.vs_arb_version
= VS_VERSION_11
;
777 FIXME(" FOUND: ARB Vertex Shader support - version=%02x\n", This
->gl_info
.vs_arb_version
);
778 This
->gl_info
.supported
[ARB_VERTEX_PROGRAM
] = TRUE
;
783 } else if (strcmp(ThisExtn
, "GL_EXT_fog_coord") == 0) {
784 FIXME(" FOUND: EXT Fog coord support\n");
785 This
->gl_info
.supported
[EXT_FOG_COORD
] = TRUE
;
786 } else if (strcmp(ThisExtn
, "GL_EXT_paletted_texture") == 0) { /* handle paletted texture extensions */
787 FIXME(" FOUND: EXT Paletted texture support\n");
788 This
->gl_info
.supported
[EXT_PALETTED_TEXTURE
] = TRUE
;
789 } else if (strcmp(ThisExtn
, "GL_EXT_point_parameters") == 0) {
790 FIXME(" FOUND: EXT Point parameters support\n");
791 This
->gl_info
.supported
[EXT_POINT_PARAMETERS
] = TRUE
;
792 } else if (strcmp(ThisExtn
, "GL_EXT_secondary_color") == 0) {
793 FIXME(" FOUND: EXT Secondary coord support\n");
794 This
->gl_info
.supported
[EXT_SECONDARY_COLOR
] = TRUE
;
795 #if defined(GL_EXT_texture_compression_s3tc)
796 } else if (strcmp(ThisExtn
, "GL_EXT_texture_compression_s3tc") == 0) {
797 FIXME(" FOUND: EXT Texture S3TC compression support\n");
798 This
->gl_info
.supported
[EXT_TEXTURE_COMPRESSION_S3TC
] = TRUE
;
800 } else if (strcmp(ThisExtn
, "GL_EXT_texture_env_dot3") == 0) {
801 if (FALSE
== This
->gl_info
.supported
[ARB_TEXTURE_ENV_DOT3
]) {
802 FIXME(" FOUND: EXT Dot3 support\n");
803 This
->gl_info
.supported
[ARB_TEXTURE_ENV_DOT3
] = TRUE
;
805 } else if (strcmp(ThisExtn
, "GL_EXT_texture_filter_anisotropic") == 0) {
806 FIXME(" FOUND: EXT Texture Anisotropic filter support\n");
807 This
->gl_info
.supported
[EXT_TEXTURE_FILTER_ANISOTROPIC
] = TRUE
;
808 } else if (strcmp(ThisExtn
, "GL_EXT_texture_lod") == 0) {
809 FIXME(" FOUND: EXT Texture LOD support\n");
810 This
->gl_info
.supported
[EXT_TEXTURE_LOD
] = TRUE
;
811 } else if (strcmp(ThisExtn
, "GL_EXT_texture_lod_bias") == 0) {
812 FIXME(" FOUND: EXT Texture LOD bias support\n");
813 This
->gl_info
.supported
[EXT_TEXTURE_LOD_BIAS
] = TRUE
;
814 } else if (strcmp(ThisExtn
, "GL_EXT_vertex_weighting") == 0) {
815 FIXME(" FOUND: EXT Vertex weighting support\n");
816 This
->gl_info
.supported
[EXT_VERTEX_WEIGHTING
] = TRUE
;
821 } else if (strstr(ThisExtn
, "GL_NV_fragment_program")) {
822 This
->gl_info
.ps_nv_version
= PS_VERSION_11
;
823 FIXME(" FOUND: NVIDIA (NV) Pixel Shader support - version=%02x\n", This
->gl_info
.ps_nv_version
);
824 This
->gl_info
.supported
[NV_FRAGMENT_PROGRAM
] = TRUE
;
825 } else if (strstr(ThisExtn
, "GL_NV_vertex_program")) {
826 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
);
827 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
);
828 FIXME(" FOUND: NVIDIA (NV) Vertex Shader support - version=%02x\n", This
->gl_info
.vs_nv_version
);
829 This
->gl_info
.supported
[NV_VERTEX_PROGRAM
] = TRUE
;
835 } else if (strcmp(ThisExtn
, "GL_EXT_vertex_shader") == 0) {
836 This
->gl_info
.vs_ati_version
= VS_VERSION_11
;
837 FIXME(" FOUND: ATI (EXT) Vertex Shader support - version=%02x\n", This
->gl_info
.vs_ati_version
);
838 This
->gl_info
.supported
[EXT_VERTEX_SHADER
] = TRUE
;
842 if (*GL_Extensions
== ' ') GL_Extensions
++;
846 #define USE_GL_FUNC(type, pfn) This->gl_info.pfn = (type) glXGetProcAddressARB(#pfn);
850 GLX_Extensions
= glXQueryExtensionsString(display
, DefaultScreen(display
));
851 FIXME("GLX_Extensions reported:\n");
853 if (NULL
== GLX_Extensions
) {
854 ERR(" GLX_Extensions returns NULL\n");
856 while (*GLX_Extensions
!= 0x00) {
857 const char *Start
= GLX_Extensions
;
860 memset(ThisExtn
, 0x00, sizeof(ThisExtn
));
861 while (*GLX_Extensions
!= ' ' && *GLX_Extensions
!= 0x00) {
864 memcpy(ThisExtn
, Start
, (GLX_Extensions
- Start
));
865 FIXME("- %s\n", ThisExtn
);
866 if (*GLX_Extensions
== ' ') GLX_Extensions
++;
870 #define USE_GL_FUNC(type, pfn) This->gl_info.pfn = (type) glXGetProcAddressARB(#pfn);
876 HRESULT WINAPI
IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface
,
877 UINT Adapter
, D3DDEVTYPE DeviceType
, HWND hFocusWindow
,
878 DWORD BehaviourFlags
, D3DPRESENT_PARAMETERS
* pPresentationParameters
,
879 IDirect3DDevice8
** ppReturnedDeviceInterface
) {
880 IDirect3DDevice8Impl
*object
;
883 XVisualInfo
template;
885 ICOM_THIS(IDirect3D8Impl
,iface
);
886 TRACE("(%p)->(Adptr:%d, DevType: %x, FocusHwnd: %p, BehFlags: %lx, PresParms: %p, RetDevInt: %p)\n", This
, Adapter
, DeviceType
,
887 hFocusWindow
, BehaviourFlags
, pPresentationParameters
, ppReturnedDeviceInterface
);
889 /* Allocate the storage for the device */
890 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DDevice8Impl
));
891 if (NULL
== object
) {
892 return D3DERR_OUTOFVIDEOMEMORY
;
894 object
->lpVtbl
= &Direct3DDevice8_Vtbl
;
896 object
->direct3d8
= This
;
897 /** The device AddRef the direct3d8 Interface else crash in propers clients codes */
898 IDirect3D8_AddRef((LPDIRECT3D8
) object
->direct3d8
);
900 /** use StateBlock Factory here, for creating the startup stateBlock */
901 object
->StateBlock
= NULL
;
902 IDirect3DDeviceImpl_CreateStateBlock(object
, D3DSBT_ALL
, NULL
);
903 object
->UpdateStateBlock
= object
->StateBlock
;
905 /* Save the creation parameters */
906 object
->CreateParms
.AdapterOrdinal
= Adapter
;
907 object
->CreateParms
.DeviceType
= DeviceType
;
908 object
->CreateParms
.hFocusWindow
= hFocusWindow
;
909 object
->CreateParms
.BehaviorFlags
= BehaviourFlags
;
911 *ppReturnedDeviceInterface
= (LPDIRECT3DDEVICE8
) object
;
913 /* Initialize settings */
914 object
->PresentParms
.BackBufferCount
= 1; /* Opengl only supports one? */
915 object
->adapterNo
= Adapter
;
916 object
->devType
= DeviceType
;
918 /* Initialize openGl */
921 /*int dblBuf[] = {GLX_STENCIL_SIZE,8,GLX_RGBA,GLX_DEPTH_SIZE,16,GLX_DOUBLEBUFFER,None};*/
922 int dblBuf
[] = {GLX_RGBA
,
923 GLX_STENCIL_SIZE
, 8, /* 2 */
924 GLX_DEPTH_SIZE
, 16, /* 4 */
925 GLX_DOUBLEBUFFER
, None
};
926 /* FIXME: Handle stencil appropriately via EnableAutoDepthStencil / AutoDepthStencilFormat */
928 /* Which hwnd are we using? */
929 /* if (pPresentationParameters->Windowed) { */
930 whichHWND
= pPresentationParameters
->hDeviceWindow
;
932 whichHWND
= hFocusWindow
;
934 object
->win_handle
= whichHWND
;
935 object
->win
= (Window
)GetPropA( whichHWND
, "__wine_x11_client_window" );
938 * whichHWND = (HWND) GetDesktopWindow();
939 * object->win = (Window)GetPropA(whichHWND, "__wine_x11_whole_window" );
944 hDc
= GetDC(whichHWND
);
945 object
->display
= get_display(hDc
);
948 TRACE("(%p)->(DepthStencil:(%u,%s), BackBufferFormat:(%u,%s))\n", This
,
949 pPresentationParameters
->AutoDepthStencilFormat
, debug_d3dformat(pPresentationParameters
->AutoDepthStencilFormat
),
950 pPresentationParameters
->BackBufferFormat
, debug_d3dformat(pPresentationParameters
->BackBufferFormat
));
954 if (TRUE
== pPresentationParameters
->EnableAutoDepthStencil
) {
955 switch (pPresentationParameters
->AutoDepthStencilFormat
) {
956 case D3DFMT_D16_LOCKABLE
: dblBuf
[2] = 8; dblBuf
[4] = 16; break;
957 case D3DFMT_D16
: dblBuf
[2] = 8; dblBuf
[4] = 16; break;
958 case D3DFMT_D15S1
: dblBuf
[2] = 1; dblBuf
[4] = 16; break;
959 case D3DFMT_D24X4S4
: dblBuf
[2] = 4; dblBuf
[4] = 24; break;
960 case D3DFMT_D24S8
: dblBuf
[2] = 8; dblBuf
[4] = 24; break;
961 case D3DFMT_D24X8
: dblBuf
[2] = 8; dblBuf
[4] = 24; break;
962 case D3DFMT_D32
: dblBuf
[2] = 8; dblBuf
[4] = 32; break;
963 default: dblBuf
[2] = 8; dblBuf
[4] = 16; break;
967 switch (pPresentationParameters
->BackBufferFormat
) {
968 case D3DFMT_R3G3B2
: dblBuf
[6] = 3; dblBuf
[8] = 3; dblBuf
[10] = 2; dblBuf
[12] = 0; break;
969 case D3DFMT_R5G6B5
: dblBuf
[6] = 5; dblBuf
[8] = 6; dblBuf
[10] = 5; dblBuf
[12] = 0; break;
970 case D3DFMT_X1R5G5B5
: dblBuf
[6] = 5; dblBuf
[8] = 5; dblBuf
[10] = 5; dblBuf
[12] = 0; break;
971 case D3DFMT_A1R5G5B5
: dblBuf
[6] = 5; dblBuf
[8] = 5; dblBuf
[10] = 5; dblBuf
[12] = 1; break;
972 case D3DFMT_X4R4G4B4
: dblBuf
[6] = 4; dblBuf
[8] = 4; dblBuf
[10] = 4; dblBuf
[12] = 0; break;
973 case D3DFMT_R8G8B8
: dblBuf
[6] = 8; dblBuf
[8] = 8; dblBuf
[10] = 8; dblBuf
[12] = 0; break;
974 case D3DFMT_X8R8G8B8
: dblBuf
[6] = 8; dblBuf
[8] = 8; dblBuf
[10] = 8; dblBuf
[12] = 0; break;
975 case D3DFMT_A8R8G8B8
: dblBuf
[6] = 8; dblBuf
[8] = 8; dblBuf
[10] = 8; dblBuf
[12] = 8; break;
976 default: dblBuf
[6] = 5; dblBuf
[8] = 6; dblBuf
[10] = 5; dblBuf
[12] = 0; break;
981 object
->visInfo
= glXChooseVisual(object
->display
, DefaultScreen(object
->display
), dblBuf
);
982 if (NULL
== object
->visInfo
) {
983 FIXME("cannot choose needed glxVisual with Stencil Buffer\n");
986 * second try using wine initialized visual ...
987 * must be fixed reworking wine-glx init
989 template.visualid
= (VisualID
)GetPropA(GetDesktopWindow(), "__wine_x11_visual_id");
990 object
->visInfo
= XGetVisualInfo(object
->display
, VisualIDMask
, &template, &num
);
991 if (NULL
== object
->visInfo
) {
992 ERR("cannot really get XVisual\n");
994 return D3DERR_NOTAVAILABLE
;
997 object
->glCtx
= glXCreateContext(object
->display
, object
->visInfo
, NULL
, GL_TRUE
);
998 if (NULL
== object
->glCtx
) {
999 ERR("cannot create glxContext\n");
1001 return D3DERR_NOTAVAILABLE
;
1005 ReleaseDC(whichHWND
, hDc
);
1008 if (object
->glCtx
== NULL
) {
1009 ERR("Error in context creation !\n");
1010 return D3DERR_INVALIDCALL
;
1012 TRACE("Context created (HWND=%p, glContext=%p, Window=%ld, VisInfo=%p)\n",
1013 whichHWND
, object
->glCtx
, object
->win
, object
->visInfo
);
1016 /* If not windowed, need to go fullscreen, and resize the HWND to the appropriate */
1018 if (!pPresentationParameters
->Windowed
) {
1023 memset(&devmode
, 0, sizeof(DEVMODEW
));
1024 devmode
.dmFields
= DM_BITSPERPEL
| DM_PELSWIDTH
| DM_PELSHEIGHT
;
1025 MultiByteToWideChar(CP_ACP
, 0, "Gamers CG", -1, devmode
.dmDeviceName
, CCHDEVICENAME
);
1026 hdc
= CreateDCA("DISPLAY", NULL
, NULL
, NULL
);
1027 bpp
= GetDeviceCaps(hdc
, BITSPIXEL
);
1029 devmode
.dmBitsPerPel
= (bpp
>= 24) ? 32 : bpp
;/*Stupid XVidMode cannot change bpp D3DFmtGetBpp(object, pPresentationParameters->BackBufferFormat);*/
1030 devmode
.dmPelsWidth
= pPresentationParameters
->BackBufferWidth
;
1031 devmode
.dmPelsHeight
= pPresentationParameters
->BackBufferHeight
;
1032 ChangeDisplaySettingsExW(devmode
.dmDeviceName
, &devmode
, object
->win_handle
, CDS_FULLSCREEN
, NULL
);
1034 FIXME("Requested full screen support not implemented, expect windowed operation\n");
1037 /* Make popup window */
1038 ShowWindow(whichHWND
, SW_HIDE
);
1039 SetWindowLongA(whichHWND
, GWL_STYLE
, WS_POPUP
);
1040 SetWindowPos(object
->win_handle
, HWND_TOP
, 0, 0,
1041 pPresentationParameters
->BackBufferWidth
,
1042 pPresentationParameters
->BackBufferHeight
, SWP_SHOWWINDOW
| SWP_FRAMECHANGED
);
1043 ShowWindow(whichHWND
, SW_SHOW
);
1046 TRACE("Creating back buffer\n");
1047 /* MSDN: If Windowed is TRUE and either of the BackBufferWidth/Height values is zero,
1048 then the corresponding dimension of the client area of the hDeviceWindow
1049 (or the focus window, if hDeviceWindow is NULL) is taken. */
1050 if (pPresentationParameters
->Windowed
&& ((pPresentationParameters
->BackBufferWidth
== 0) ||
1051 (pPresentationParameters
->BackBufferHeight
== 0))) {
1054 GetClientRect(whichHWND
, &Rect
);
1056 if (pPresentationParameters
->BackBufferWidth
== 0) {
1057 pPresentationParameters
->BackBufferWidth
= Rect
.right
;
1058 TRACE("Updating width to %d\n", pPresentationParameters
->BackBufferWidth
);
1060 if (pPresentationParameters
->BackBufferHeight
== 0) {
1061 pPresentationParameters
->BackBufferHeight
= Rect
.bottom
;
1062 TRACE("Updating height to %d\n", pPresentationParameters
->BackBufferHeight
);
1066 /* Save the presentation parms now filled in correctly */
1067 memcpy(&object
->PresentParms
, pPresentationParameters
, sizeof(D3DPRESENT_PARAMETERS
));
1070 IDirect3DDevice8Impl_CreateRenderTarget((LPDIRECT3DDEVICE8
) object
,
1071 pPresentationParameters
->BackBufferWidth
,
1072 pPresentationParameters
->BackBufferHeight
,
1073 pPresentationParameters
->BackBufferFormat
,
1074 pPresentationParameters
->MultiSampleType
,
1076 (LPDIRECT3DSURFACE8
*) &object
->frontBuffer
);
1078 IDirect3DDevice8Impl_CreateRenderTarget((LPDIRECT3DDEVICE8
) object
,
1079 pPresentationParameters
->BackBufferWidth
,
1080 pPresentationParameters
->BackBufferHeight
,
1081 pPresentationParameters
->BackBufferFormat
,
1082 pPresentationParameters
->MultiSampleType
,
1084 (LPDIRECT3DSURFACE8
*) &object
->backBuffer
);
1086 if (pPresentationParameters
->EnableAutoDepthStencil
) {
1087 IDirect3DDevice8Impl_CreateDepthStencilSurface((LPDIRECT3DDEVICE8
) object
,
1088 pPresentationParameters
->BackBufferWidth
,
1089 pPresentationParameters
->BackBufferHeight
,
1090 pPresentationParameters
->AutoDepthStencilFormat
,
1091 D3DMULTISAMPLE_NONE
,
1092 (LPDIRECT3DSURFACE8
*) &object
->depthStencilBuffer
);
1094 object
->depthStencilBuffer
= NULL
;
1096 TRACE("FrontBuf @ %p, BackBuf @ %p, DepthStencil @ %p\n",object
->frontBuffer
, object
->backBuffer
, object
->depthStencilBuffer
);
1098 /* init the default renderTarget management */
1099 object
->drawable
= object
->win
;
1100 object
->render_ctx
= object
->glCtx
;
1101 object
->renderTarget
= object
->frontBuffer
;
1102 IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8
) object
->renderTarget
);
1103 object
->stencilBufferTarget
= object
->depthStencilBuffer
;
1104 if (NULL
!= object
->stencilBufferTarget
) {
1105 IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8
) object
->stencilBufferTarget
);
1110 if (glXMakeCurrent(object
->display
, object
->win
, object
->glCtx
) == False
) {
1111 ERR("Error in setting current context (context %p drawable %ld)!\n", object
->glCtx
, object
->win
);
1113 checkGLcall("glXMakeCurrent");
1115 /* Clear the screen */
1116 glClearColor(1.0, 0.0, 0.0, 0.0);
1117 checkGLcall("glClearColor");
1118 glColor3f(1.0, 1.0, 1.0);
1119 checkGLcall("glColor3f");
1121 glEnable(GL_LIGHTING
);
1122 checkGLcall("glEnable");
1124 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, GL_TRUE
);
1125 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);");
1127 glTexEnvf(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_COMBINE_EXT
);
1128 checkGLcall("glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);");
1130 glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL
, GL_SEPARATE_SPECULAR_COLOR
);
1131 checkGLcall("glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);");
1134 * Initialize openGL extension related variables
1135 * with Default values
1137 IDirect3D8Impl_FillGLCaps(iface
, object
->display
);
1139 /* Setup all the devices defaults */
1140 IDirect3DDeviceImpl_InitStartupStateBlock(object
);
1144 { /* Set a default viewport */
1148 vp
.Width
= pPresentationParameters
->BackBufferWidth
;
1149 vp
.Height
= pPresentationParameters
->BackBufferHeight
;
1152 IDirect3DDevice8Impl_SetViewport((LPDIRECT3DDEVICE8
) object
, &vp
);
1155 /* Initialize the current view state */
1156 object
->modelview_valid
= 1;
1157 object
->proj_valid
= 0;
1158 object
->view_ident
= 1;
1159 object
->last_was_rhw
= 0;
1160 glGetIntegerv(GL_MAX_LIGHTS
, &object
->maxConcurrentLights
);
1161 TRACE("(%p,%d) All defaults now set up, leaving CreateDevice with %p\n", This
, Adapter
, object
);
1165 ICOM_VTABLE(IDirect3D8
) Direct3D8_Vtbl
=
1167 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1168 IDirect3D8Impl_QueryInterface
,
1169 IDirect3D8Impl_AddRef
,
1170 IDirect3D8Impl_Release
,
1171 IDirect3D8Impl_RegisterSoftwareDevice
,
1172 IDirect3D8Impl_GetAdapterCount
,
1173 IDirect3D8Impl_GetAdapterIdentifier
,
1174 IDirect3D8Impl_GetAdapterModeCount
,
1175 IDirect3D8Impl_EnumAdapterModes
,
1176 IDirect3D8Impl_GetAdapterDisplayMode
,
1177 IDirect3D8Impl_CheckDeviceType
,
1178 IDirect3D8Impl_CheckDeviceFormat
,
1179 IDirect3D8Impl_CheckDeviceMultiSampleType
,
1180 IDirect3D8Impl_CheckDepthStencilMatch
,
1181 IDirect3D8Impl_GetDeviceCaps
,
1182 IDirect3D8Impl_GetAdapterMonitor
,
1183 IDirect3D8Impl_CreateDevice