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 #include "wine/debug.h"
30 #include "d3d8_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
35 static const int modes
[NUM_MODES
][3] = {
48 /* retrieve the X display to use on a given DC */
49 inline static Display
*get_display( HDC hdc
)
52 enum x11drv_escape_codes escape
= X11DRV_GET_DISPLAY
;
54 if (!ExtEscape( hdc
, X11DRV_ESCAPE
, sizeof(escape
), (LPCSTR
)&escape
,
55 sizeof(display
), (LPSTR
)&display
)) display
= NULL
;
60 /* IDirect3D IUnknown parts follow: */
61 HRESULT WINAPI
IDirect3D8Impl_QueryInterface(LPDIRECT3D8 iface
,REFIID riid
,LPVOID
*ppobj
)
63 ICOM_THIS(IDirect3D8Impl
,iface
);
65 if (IsEqualGUID(riid
, &IID_IUnknown
)
66 || IsEqualGUID(riid
, &IID_IDirect3D8
)) {
67 IDirect3D8Impl_AddRef(iface
);
72 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
76 ULONG WINAPI
IDirect3D8Impl_AddRef(LPDIRECT3D8 iface
) {
77 ICOM_THIS(IDirect3D8Impl
,iface
);
78 TRACE("(%p) : AddRef from %ld\n", This
, This
->ref
);
82 ULONG WINAPI
IDirect3D8Impl_Release(LPDIRECT3D8 iface
) {
83 ICOM_THIS(IDirect3D8Impl
,iface
);
84 ULONG ref
= --This
->ref
;
85 TRACE("(%p) : ReleaseRef to %ld\n", This
, This
->ref
);
87 HeapFree(GetProcessHeap(), 0, This
);
91 /* IDirect3D Interface follow: */
92 HRESULT WINAPI
IDirect3D8Impl_RegisterSoftwareDevice (LPDIRECT3D8 iface
, void* pInitializeFunction
) {
93 ICOM_THIS(IDirect3D8Impl
,iface
);
94 FIXME("(%p)->(%p): stub\n", This
, pInitializeFunction
);
98 UINT WINAPI
IDirect3D8Impl_GetAdapterCount (LPDIRECT3D8 iface
) {
99 ICOM_THIS(IDirect3D8Impl
,iface
);
100 /* FIXME: Set to one for now to imply the display */
101 TRACE("(%p): Mostly stub, only returns primary display\n", This
);
105 HRESULT WINAPI
IDirect3D8Impl_GetAdapterIdentifier (LPDIRECT3D8 iface
,
106 UINT Adapter
, DWORD Flags
, D3DADAPTER_IDENTIFIER8
* pIdentifier
) {
107 ICOM_THIS(IDirect3D8Impl
,iface
);
109 TRACE("(%p}->(Adapter: %d, Flags: %lx, pId=%p)\n", This
, Adapter
, Flags
, pIdentifier
);
111 if (Adapter
>= IDirect3D8Impl_GetAdapterCount(iface
)) {
112 return D3DERR_INVALIDCALL
;
115 if (Adapter
== 0) { /* Display */
116 strcpy(pIdentifier
->Driver
, "Display");
117 strcpy(pIdentifier
->Description
, "Direct3D Display");
118 pIdentifier
->DriverVersion
.s
.HighPart
= 1;
119 pIdentifier
->DriverVersion
.s
.LowPart
= 0;
120 pIdentifier
->VendorId
= 0;
121 pIdentifier
->DeviceId
= 0;
122 pIdentifier
->SubSysId
= 0;
123 pIdentifier
->Revision
= 0;
124 /*FIXME: memcpy(&pIdentifier->DeviceIdentifier, ??, sizeof(??GUID)); */
125 if (Flags
& D3DENUM_NO_WHQL_LEVEL
) {
126 pIdentifier
->WHQLLevel
= 0;
128 pIdentifier
->WHQLLevel
= 1;
131 FIXME("Adapter not primary display\n");
137 UINT WINAPI
IDirect3D8Impl_GetAdapterModeCount (LPDIRECT3D8 iface
,
139 ICOM_THIS(IDirect3D8Impl
,iface
);
141 TRACE("(%p}->(Adapter: %d)\n", This
, Adapter
);
143 if (Adapter
>= IDirect3D8Impl_GetAdapterCount(iface
)) {
144 return D3DERR_INVALIDCALL
;
147 if (Adapter
== 0) { /* Display */
148 int maxWidth
= GetSystemMetrics(SM_CXSCREEN
);
149 int maxHeight
= GetSystemMetrics(SM_CYSCREEN
);
152 for (i
=0; i
<NUM_MODES
; i
++) {
153 if (modes
[i
][0] > maxWidth
|| modes
[i
][1] > maxHeight
) {
159 FIXME("Adapter not primary display\n");
165 HRESULT WINAPI
IDirect3D8Impl_EnumAdapterModes (LPDIRECT3D8 iface
,
166 UINT Adapter
, UINT Mode
, D3DDISPLAYMODE
* pMode
) {
167 ICOM_THIS(IDirect3D8Impl
,iface
);
169 TRACE("(%p}->(Adapter: %d, mode: %d, pMode=%p)\n", This
, Adapter
, Mode
, pMode
);
171 if (Adapter
>= IDirect3D8Impl_GetAdapterCount(iface
)) {
172 return D3DERR_INVALIDCALL
;
175 if (Adapter
== 0) { /* Display */
180 pMode
->Width
= GetSystemMetrics(SM_CXSCREEN
);
181 pMode
->Height
= GetSystemMetrics(SM_CYSCREEN
);
182 pMode
->RefreshRate
= 85; /*FIXME: How to identify? */
183 } else if (Mode
< (NUM_MODES
+1)) {
184 pMode
->Width
= modes
[Mode
-1][0];
185 pMode
->Height
= modes
[Mode
-1][1];
186 pMode
->RefreshRate
= modes
[Mode
-1][2];
188 TRACE("Requested mode out of range %d\n", Mode
);
189 return D3DERR_INVALIDCALL
;
192 hdc
= CreateDCA("DISPLAY", NULL
, NULL
, NULL
);
193 bpp
= GetDeviceCaps(hdc
, BITSPIXEL
);
197 case 8: pMode
->Format
= D3DFMT_R3G3B2
; break;
198 case 16: pMode
->Format
= D3DFMT_A4R4G4B4
; break;
199 case 24: pMode
->Format
= D3DFMT_R8G8B8
; break;
200 case 32: pMode
->Format
= D3DFMT_A8R8G8B8
; break;
201 default: pMode
->Format
= D3DFMT_UNKNOWN
;
203 TRACE("W %d H %d rr %d fmt %x\n", pMode
->Width
, pMode
->Height
, pMode
->RefreshRate
, pMode
->Format
);
206 FIXME("Adapter not primary display\n");
212 HRESULT WINAPI
IDirect3D8Impl_GetAdapterDisplayMode (LPDIRECT3D8 iface
,
213 UINT Adapter
, D3DDISPLAYMODE
* pMode
) {
214 ICOM_THIS(IDirect3D8Impl
,iface
);
215 TRACE("(%p}->(Adapter: %d, pMode: %p)\n", This
, Adapter
, pMode
);
217 if (Adapter
>= IDirect3D8Impl_GetAdapterCount(iface
)) {
218 return D3DERR_INVALIDCALL
;
221 if (Adapter
== 0) { /* Display */
225 pMode
->Width
= GetSystemMetrics(SM_CXSCREEN
);
226 pMode
->Height
= GetSystemMetrics(SM_CYSCREEN
);
227 pMode
->RefreshRate
= 85; /*FIXME: How to identify? */
229 hdc
= CreateDCA("DISPLAY", NULL
, NULL
, NULL
);
230 bpp
= GetDeviceCaps(hdc
, BITSPIXEL
);
234 case 8: pMode
->Format
= D3DFMT_R3G3B2
; break;
235 case 16: pMode
->Format
= D3DFMT_A4R4G4B4
; break;
236 case 24: pMode
->Format
= D3DFMT_R8G8B8
; break;
237 case 32: pMode
->Format
= D3DFMT_A8R8G8B8
; break;
238 default: pMode
->Format
= D3DFMT_UNKNOWN
;
242 FIXME("Adapter not primary display\n");
245 TRACE("returning w:%d, h:%d, ref:%d, fmt:%d\n", pMode
->Width
,
246 pMode
->Height
, pMode
->RefreshRate
, pMode
->Format
);
250 HRESULT WINAPI
IDirect3D8Impl_CheckDeviceType (LPDIRECT3D8 iface
,
251 UINT Adapter
, D3DDEVTYPE CheckType
, D3DFORMAT DisplayFormat
,
252 D3DFORMAT BackBufferFormat
, BOOL Windowed
) {
253 ICOM_THIS(IDirect3D8Impl
,iface
);
254 FIXME("(%p)->(Adptr:%d, CheckType:%x, DispFmt:%x, BackBuf:%x, Win? %d): stub\n", This
, Adapter
, CheckType
,
255 DisplayFormat
, BackBufferFormat
, Windowed
);
259 HRESULT WINAPI
IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 iface
,
260 UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT AdapterFormat
,
261 DWORD Usage
, D3DRESOURCETYPE RType
, D3DFORMAT CheckFormat
) {
262 ICOM_THIS(IDirect3D8Impl
,iface
);
263 FIXME("(%p)->(Adptr:%d, DevType: %x, AdptFmt: %d, Use: %ld, ResTyp: %x, CheckFmt: %d)\n", This
, Adapter
, DeviceType
,
264 AdapterFormat
, Usage
, RType
, CheckFormat
);
268 HRESULT WINAPI
IDirect3D8Impl_CheckDeviceMultiSampleType (LPDIRECT3D8 iface
,
269 UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT SurfaceFormat
,
270 BOOL Windowed
, D3DMULTISAMPLE_TYPE MultiSampleType
) {
271 ICOM_THIS(IDirect3D8Impl
,iface
);
272 FIXME("(%p)->(Adptr:%d, DevType: %x, SurfFmt: %x, Win? %d, MultiSamp: %x)\n", This
, Adapter
, DeviceType
,
273 SurfaceFormat
, Windowed
, MultiSampleType
);
277 HRESULT WINAPI
IDirect3D8Impl_CheckDepthStencilMatch (LPDIRECT3D8 iface
,
278 UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT AdapterFormat
,
279 D3DFORMAT RenderTargetFormat
, D3DFORMAT DepthStencilFormat
) {
280 ICOM_THIS(IDirect3D8Impl
,iface
);
281 FIXME("(%p)->(Adptr:%d, DevType: %x, AdptFmt: %x, RendrTgtFmt: %x, DepthStencilFmt: %x)\n", This
, Adapter
, DeviceType
,
282 AdapterFormat
, RenderTargetFormat
, DepthStencilFormat
);
286 HRESULT WINAPI
IDirect3D8Impl_GetDeviceCaps (LPDIRECT3D8 iface
,
287 UINT Adapter
, D3DDEVTYPE DeviceType
, D3DCAPS8
* pCaps
) {
288 ICOM_THIS(IDirect3D8Impl
,iface
);
289 TRACE("(%p)->(Adptr:%d, DevType: %x, pCaps: %p)\n", This
, Adapter
, DeviceType
, pCaps
);
292 /* NOTE: Most of the values here are complete garbage for now */
293 pCaps
->DeviceType
= D3DDEVTYPE_HAL
; /* Not quite true, but use h/w supported by opengl I suppose */
294 pCaps
->AdapterOrdinal
= Adapter
;
297 pCaps
->Caps2
= D3DCAPS2_CANRENDERWINDOWED
;
298 pCaps
->Caps3
= D3DDEVCAPS_HWTRANSFORMANDLIGHT
;
299 pCaps
->PresentationIntervals
= D3DPRESENT_INTERVAL_IMMEDIATE
;
301 pCaps
->CursorCaps
= 0;
303 pCaps
->DevCaps
= D3DDEVCAPS_DRAWPRIMTLVERTEX
| D3DDEVCAPS_HWTRANSFORMANDLIGHT
| D3DDEVCAPS_PUREDEVICE
;
305 pCaps
->PrimitiveMiscCaps
= D3DPMISCCAPS_CULLCCW
| D3DPMISCCAPS_CULLCW
| D3DPMISCCAPS_COLORWRITEENABLE
| D3DPMISCCAPS_CLIPTLVERTS
|
306 D3DPMISCCAPS_CLIPPLANESCALEDPOINTS
| D3DPMISCCAPS_MASKZ
; /*NOT: D3DPMISCCAPS_TSSARGTEMP*/
307 pCaps
->RasterCaps
= D3DPRASTERCAPS_DITHER
| D3DPRASTERCAPS_PAT
;
308 pCaps
->ZCmpCaps
= D3DPCMPCAPS_ALWAYS
| D3DPCMPCAPS_EQUAL
| D3DPCMPCAPS_GREATER
| D3DPCMPCAPS_GREATEREQUAL
|
309 D3DPCMPCAPS_LESS
| D3DPCMPCAPS_LESSEQUAL
| D3DPCMPCAPS_NEVER
| D3DPCMPCAPS_NOTEQUAL
;
311 pCaps
->SrcBlendCaps
= 0;
312 pCaps
->DestBlendCaps
= 0;
313 pCaps
->AlphaCmpCaps
= 0;
314 pCaps
->ShadeCaps
= D3DPSHADECAPS_SPECULARGOURAUDRGB
| D3DPSHADECAPS_COLORGOURAUDRGB
;
315 pCaps
->TextureCaps
= D3DPTEXTURECAPS_ALPHA
| D3DPTEXTURECAPS_ALPHAPALETTE
| D3DPTEXTURECAPS_CUBEMAP
| D3DPTEXTURECAPS_POW2
| D3DPTEXTURECAPS_VOLUMEMAP
;
316 pCaps
->TextureFilterCaps
= 0;
317 pCaps
->CubeTextureFilterCaps
= 0;
318 pCaps
->VolumeTextureFilterCaps
= 0;
319 pCaps
->TextureAddressCaps
= D3DPTADDRESSCAPS_BORDER
| D3DPTADDRESSCAPS_CLAMP
| D3DPTADDRESSCAPS_WRAP
;
320 pCaps
->VolumeTextureAddressCaps
= 0;
322 pCaps
->LineCaps
= D3DLINECAPS_TEXTURE
| D3DLINECAPS_ZTEST
;
324 pCaps
->MaxTextureWidth
= 16384;
325 pCaps
->MaxTextureHeight
= 16384;
326 pCaps
->MaxVolumeExtent
= 0;
328 pCaps
->MaxTextureRepeat
= 32768;
329 pCaps
->MaxTextureAspectRatio
= 32768;
330 pCaps
->MaxAnisotropy
= 0;
331 pCaps
->MaxVertexW
= 1.0;
333 pCaps
->GuardBandLeft
= 0;
334 pCaps
->GuardBandTop
= 0;
335 pCaps
->GuardBandRight
= 0;
336 pCaps
->GuardBandBottom
= 0;
338 pCaps
->ExtentsAdjust
= 0;
340 pCaps
->StencilCaps
= D3DSTENCILCAPS_DECRSAT
| D3DSTENCILCAPS_INCRSAT
|
341 D3DSTENCILCAPS_INVERT
| D3DSTENCILCAPS_KEEP
|
342 D3DSTENCILCAPS_REPLACE
| D3DSTENCILCAPS_ZERO
/* | D3DSTENCILCAPS_DECR | D3DSTENCILCAPS_INCR */;
344 pCaps
->FVFCaps
= D3DFVFCAPS_PSIZE
| 0x80000;
345 pCaps
->TextureOpCaps
= 0xFFFFFFFF;
346 pCaps
->MaxTextureBlendStages
= 256;
347 pCaps
->MaxSimultaneousTextures
= 256;
349 pCaps
->VertexProcessingCaps
= D3DVTXPCAPS_DIRECTIONALLIGHTS
| D3DVTXPCAPS_MATERIALSOURCE7
| D3DVTXPCAPS_POSITIONALLIGHTS
| D3DVTXPCAPS_TEXGEN
;
351 pCaps
->MaxActiveLights
= 8;
352 pCaps
->MaxUserClipPlanes
= 1;
353 pCaps
->MaxVertexBlendMatrices
= 1;
354 pCaps
->MaxVertexBlendMatrixIndex
= 1;
356 pCaps
->MaxPointSize
= 128.0;
358 pCaps
->MaxPrimitiveCount
= 0xFFFFFFFF;
359 pCaps
->MaxVertexIndex
= 0xFFFFFFFF;
360 pCaps
->MaxStreams
= 1;
361 pCaps
->MaxStreamStride
= 1024;
363 pCaps
->VertexShaderVersion
= 01;
364 pCaps
->MaxVertexShaderConst
= 1;
366 pCaps
->PixelShaderVersion
= 01;
367 pCaps
->MaxPixelShaderValue
= 1.0;
372 HMONITOR WINAPI
IDirect3D8Impl_GetAdapterMonitor (LPDIRECT3D8 iface
,
374 ICOM_THIS(IDirect3D8Impl
,iface
);
375 FIXME("(%p)->(Adptr:%d)\n", This
, Adapter
);
379 HRESULT WINAPI
IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface
,
380 UINT Adapter
, D3DDEVTYPE DeviceType
, HWND hFocusWindow
,
381 DWORD BehaviourFlags
, D3DPRESENT_PARAMETERS
* pPresentationParameters
,
382 IDirect3DDevice8
** ppReturnedDeviceInterface
) {
383 IDirect3DDevice8Impl
*object
;
386 XVisualInfo
template;
387 const char *GL_Extensions
= NULL
;
388 const char *GLX_Extensions
= NULL
;
390 ICOM_THIS(IDirect3D8Impl
,iface
);
391 TRACE("(%p)->(Adptr:%d, DevType: %x, FocusHwnd: %p, BehFlags: %lx, PresParms: %p, RetDevInt: %p)\n", This
, Adapter
, DeviceType
,
392 hFocusWindow
, BehaviourFlags
, pPresentationParameters
, ppReturnedDeviceInterface
);
394 /* Allocate the storage for the device */
395 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DDevice8Impl
));
396 if (NULL
== object
) {
397 return D3DERR_OUTOFVIDEOMEMORY
;
399 object
->lpVtbl
= &Direct3DDevice8_Vtbl
;
401 object
->direct3d8
= This
;
402 object
->UpdateStateBlock
= &object
->StateBlock
;
404 /* Save the creation parameters */
405 object
->CreateParms
.AdapterOrdinal
= Adapter
;
406 object
->CreateParms
.DeviceType
= DeviceType
;
407 object
->CreateParms
.hFocusWindow
= hFocusWindow
;
408 object
->CreateParms
.BehaviorFlags
= BehaviourFlags
;
410 *ppReturnedDeviceInterface
= (LPDIRECT3DDEVICE8
)object
;
412 /* Initialize settings */
413 memcpy(&object
->PresentParms
, pPresentationParameters
, sizeof(D3DPRESENT_PARAMETERS
));
415 object
->PresentParms
.BackBufferCount
= 1; /* Opengl only supports one? */
416 pPresentationParameters
->BackBufferCount
= 1;
418 object
->adapterNo
= Adapter
;
419 object
->devType
= DeviceType
;
421 /* Initialize openGl */
424 int dblBuf
[]={GLX_STENCIL_SIZE
,8,GLX_RGBA
,GLX_DEPTH_SIZE
,16,GLX_DOUBLEBUFFER
,None
};
425 /* FIXME: Handle stencil appropriately via EnableAutoDepthStencil / AutoDepthStencilFormat */
426 /*int dblBuf[]={GLX_RGBA,GLX_RED_SIZE,4,GLX_GREEN_SIZE,4,GLX_BLUE_SIZE,4,GLX_DOUBLEBUFFER,None}; */
428 /* Which hwnd are we using? */
429 /* if (pPresentationParameters->Windowed) { */
430 whichHWND
= pPresentationParameters
->hDeviceWindow
;
432 whichHWND
= hFocusWindow
;
434 object
->win
= (Window
)GetPropA( whichHWND
, "__wine_x11_client_window" );
437 * whichHWND = (HWND) GetDesktopWindow();
438 * object->win = (Window)GetPropA(whichHWND, "__wine_x11_whole_window" );
443 hDc
= GetDC(whichHWND
);
444 object
->display
= get_display(hDc
);
447 object
->visInfo
= glXChooseVisual(object
->display
, DefaultScreen(object
->display
), dblBuf
);
448 if (NULL
== object
->visInfo
) {
449 FIXME("cannot choose needed glxVisual with Stencil Buffer\n");
452 * second try using wine initialized visual ...
453 * must be fixed reworking wine-glx init
455 template.visualid
= (VisualID
)GetPropA( GetDesktopWindow(), "__wine_x11_visual_id" );
456 object
->visInfo
= XGetVisualInfo(object
->display
, VisualIDMask
, &template, &num
);
457 if (NULL
== object
->visInfo
) {
458 ERR("cannot really get XVisual\n");
460 return D3DERR_NOTAVAILABLE
;
464 object
->glCtx
= glXCreateContext(object
->display
, object
->visInfo
, NULL
, GL_TRUE
);
465 if (NULL
== object
->visInfo
) {
466 ERR("cannot create glxContext\n");
468 return D3DERR_NOTAVAILABLE
;
472 ReleaseDC(whichHWND
, hDc
);
475 if (object
->glCtx
== NULL
) {
476 ERR("Error in context creation !\n");
477 return D3DERR_INVALIDCALL
;
479 TRACE("Context created (HWND=%p, glContext=%p, Window=%ld, VisInfo=%p)\n",
480 whichHWND
, object
->glCtx
, object
->win
, object
->visInfo
);
483 TRACE("Creating back buffer\n");
484 /* MSDN: If Windowed is TRUE and either of the BackBufferWidth/Height values is zero,
485 then the corresponding dimension of the client area of the hDeviceWindow
486 (or the focus window, if hDeviceWindow is NULL) is taken. */
487 if (pPresentationParameters
->Windowed
&& ((pPresentationParameters
->BackBufferWidth
== 0) ||
488 (pPresentationParameters
->BackBufferHeight
== 0))) {
491 GetClientRect(whichHWND
, &Rect
);
493 if (pPresentationParameters
->BackBufferWidth
== 0) {
494 pPresentationParameters
->BackBufferWidth
= Rect
.right
;
495 TRACE("Updating width to %d\n", pPresentationParameters
->BackBufferWidth
);
497 if (pPresentationParameters
->BackBufferHeight
== 0) {
498 pPresentationParameters
->BackBufferHeight
= Rect
.bottom
;
499 TRACE("Updating height to %d\n", pPresentationParameters
->BackBufferHeight
);
503 IDirect3DDevice8Impl_CreateImageSurface((LPDIRECT3DDEVICE8
) object
,
504 pPresentationParameters
->BackBufferWidth
,
505 pPresentationParameters
->BackBufferHeight
,
506 pPresentationParameters
->BackBufferFormat
,
507 (LPDIRECT3DSURFACE8
*) &object
->backBuffer
);
509 /* Now override the surface's Flip method (if in double buffering) ?COPIED from DDRAW!?
510 ((x11_ds_private *) surface->private)->opengl_flip = TRUE;
513 struct _surface_chain *chain = surface->s.chain;
514 for (i=0;i<chain->nrofsurfaces;i++)
515 if (chain->surfaces[i]->s.surface_desc.ddsCaps.dwCaps & DDSCAPS_FLIP)
516 ((x11_ds_private *) chain->surfaces[i]->private)->opengl_flip = TRUE;
521 if (glXMakeCurrent(object
->display
, object
->win
, object
->glCtx
) == False
) {
522 ERR("Error in setting current context (context %p drawable %ld)!\n", object
->glCtx
, object
->win
);
524 checkGLcall("glXMakeCurrent");
526 /* Clear the screen */
527 glClearColor(1.0, 0.0, 0.0, 0.0);
528 checkGLcall("glClearColor");
529 glColor3f(1.0, 1.0, 1.0);
530 checkGLcall("glColor3f");
532 glEnable(GL_LIGHTING
);
533 checkGLcall("glEnable");
535 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, GL_TRUE
);
536 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);");
538 glTexEnvf(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_COMBINE_EXT
);
539 checkGLcall("glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);");
541 /* Setup all the devices defaults */
542 CreateStateBlock((LPDIRECT3DDEVICE8
) object
);
544 /* Parse the gl supported features, in theory enabling parts of our code appropriately */
545 GL_Extensions
= glGetString(GL_EXTENSIONS
);
546 TRACE("GL_Extensions reported:\n");
548 if (NULL
== GL_Extensions
) {
549 ERR(" GL_Extensions returns NULL\n");
551 while (*GL_Extensions
!=0x00) {
552 const char *Start
= GL_Extensions
;
555 memset(ThisExtn
, 0x00, sizeof(ThisExtn
));
556 while (*GL_Extensions
!=' ' && *GL_Extensions
!=0x00) {
559 memcpy(ThisExtn
, Start
, (GL_Extensions
-Start
));
560 TRACE (" %s\n", ThisExtn
);
561 if (*GL_Extensions
==' ') GL_Extensions
++;
565 GLX_Extensions
= glXQueryExtensionsString(object
->display
, DefaultScreen(object
->display
));
566 TRACE("GLX_Extensions reported:\n");
568 if (NULL
== GLX_Extensions
) {
569 ERR(" GLX_Extensions returns NULL\n");
571 while (*GLX_Extensions
!=0x00) {
572 const char *Start
= GLX_Extensions
;
575 memset(ThisExtn
, 0x00, sizeof(ThisExtn
));
576 while (*GLX_Extensions
!=' ' && *GLX_Extensions
!=0x00) {
579 memcpy(ThisExtn
, Start
, (GLX_Extensions
-Start
));
580 TRACE (" %s\n", ThisExtn
);
581 if (*GLX_Extensions
==' ') GLX_Extensions
++;
588 GLint gl_max_texture_units_arb
;
589 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB
, &gl_max_texture_units_arb
);
590 TRACE("GLCaps: GL_MAX_TEXTURE_UNITS_ARB=%d\n", gl_max_texture_units_arb
);
593 { /* Set a default viewport */
597 vp
.Width
= pPresentationParameters
->BackBufferWidth
;
598 vp
.Height
= pPresentationParameters
->BackBufferHeight
;
601 IDirect3DDevice8Impl_SetViewport((LPDIRECT3DDEVICE8
) object
, &vp
);
604 TRACE("(%p,%d)\n", This
, Adapter
);
608 ICOM_VTABLE(IDirect3D8
) Direct3D8_Vtbl
=
610 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
611 IDirect3D8Impl_QueryInterface
,
612 IDirect3D8Impl_AddRef
,
613 IDirect3D8Impl_Release
,
614 IDirect3D8Impl_RegisterSoftwareDevice
,
615 IDirect3D8Impl_GetAdapterCount
,
616 IDirect3D8Impl_GetAdapterIdentifier
,
617 IDirect3D8Impl_GetAdapterModeCount
,
618 IDirect3D8Impl_EnumAdapterModes
,
619 IDirect3D8Impl_GetAdapterDisplayMode
,
620 IDirect3D8Impl_CheckDeviceType
,
621 IDirect3D8Impl_CheckDeviceFormat
,
622 IDirect3D8Impl_CheckDeviceMultiSampleType
,
623 IDirect3D8Impl_CheckDepthStencilMatch
,
624 IDirect3D8Impl_GetDeviceCaps
,
625 IDirect3D8Impl_GetAdapterMonitor
,
626 IDirect3D8Impl_CreateDevice