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
21 #define NONAMELESSUNION
22 #define NONAMELESSSTRUCT
27 #include "wine/debug.h"
32 #include "d3d8_private.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
37 static const int modes[NUM_MODES][3] = {
50 /* retrieve the X display to use on a given DC */
51 inline static Display *get_display( HDC hdc )
54 enum x11drv_escape_codes escape = X11DRV_GET_DISPLAY;
56 if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape,
57 sizeof(display), (LPSTR)&display )) display = NULL;
62 /* IDirect3D IUnknown parts follow: */
63 HRESULT WINAPI IDirect3D8Impl_QueryInterface(LPDIRECT3D8 iface,REFIID riid,LPVOID *ppobj)
65 ICOM_THIS(IDirect3D8Impl,iface);
67 if (IsEqualGUID(riid, &IID_IUnknown)
68 || IsEqualGUID(riid, &IID_IDirect3D8)) {
69 IDirect3D8Impl_AddRef(iface);
74 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
78 ULONG WINAPI IDirect3D8Impl_AddRef(LPDIRECT3D8 iface) {
79 ICOM_THIS(IDirect3D8Impl,iface);
80 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
84 ULONG WINAPI IDirect3D8Impl_Release(LPDIRECT3D8 iface) {
85 ICOM_THIS(IDirect3D8Impl,iface);
86 ULONG ref = --This->ref;
87 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
89 HeapFree(GetProcessHeap(), 0, This);
93 /* IDirect3D Interface follow: */
94 HRESULT WINAPI IDirect3D8Impl_RegisterSoftwareDevice (LPDIRECT3D8 iface, void* pInitializeFunction) {
95 ICOM_THIS(IDirect3D8Impl,iface);
96 FIXME("(%p)->(%p): stub\n", This, pInitializeFunction);
100 UINT WINAPI IDirect3D8Impl_GetAdapterCount (LPDIRECT3D8 iface) {
101 ICOM_THIS(IDirect3D8Impl,iface);
102 /* FIXME: Set to one for now to imply the display */
103 TRACE("(%p): Mostly stub, only returns primary display\n", This);
107 HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier (LPDIRECT3D8 iface,
108 UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER8* pIdentifier) {
109 ICOM_THIS(IDirect3D8Impl,iface);
111 TRACE("(%p}->(Adapter: %d, Flags: %lx, pId=%p)\n", This, Adapter, Flags, pIdentifier);
113 if (Adapter >= IDirect3D8Impl_GetAdapterCount(iface)) {
114 return D3DERR_INVALIDCALL;
117 if (Adapter == 0) { /* Display */
118 strcpy(pIdentifier->Driver, "Display");
119 strcpy(pIdentifier->Description, "Direct3D Display");
120 pIdentifier->DriverVersion.s.HighPart = 1;
121 pIdentifier->DriverVersion.s.LowPart = 0;
122 pIdentifier->VendorId = 0;
123 pIdentifier->DeviceId = 0;
124 pIdentifier->SubSysId = 0;
125 pIdentifier->Revision = 0;
126 /*FIXME: memcpy(&pIdentifier->DeviceIdentifier, ??, sizeof(??GUID)); */
127 if (Flags & D3DENUM_NO_WHQL_LEVEL ) {
128 pIdentifier->WHQLLevel = 0;
130 pIdentifier->WHQLLevel = 1;
133 FIXME("Adapter not primary display\n");
139 UINT WINAPI IDirect3D8Impl_GetAdapterModeCount (LPDIRECT3D8 iface,
141 ICOM_THIS(IDirect3D8Impl,iface);
143 TRACE("(%p}->(Adapter: %d)\n", This, Adapter);
145 if (Adapter >= IDirect3D8Impl_GetAdapterCount(iface)) {
146 return D3DERR_INVALIDCALL;
149 if (Adapter == 0) { /* Display */
150 int maxWidth = GetSystemMetrics(SM_CXSCREEN);
151 int maxHeight = GetSystemMetrics(SM_CYSCREEN);
154 for (i=0; i<NUM_MODES; i++) {
155 if (modes[i][0] > maxWidth || modes[i][1] > maxHeight) {
161 FIXME("Adapter not primary display\n");
167 HRESULT WINAPI IDirect3D8Impl_EnumAdapterModes (LPDIRECT3D8 iface,
168 UINT Adapter, UINT Mode, D3DDISPLAYMODE* pMode) {
169 ICOM_THIS(IDirect3D8Impl,iface);
171 TRACE("(%p}->(Adapter: %d, mode: %d, pMode=%p)\n", This, Adapter, Mode, pMode);
173 if (Adapter >= IDirect3D8Impl_GetAdapterCount(iface)) {
174 return D3DERR_INVALIDCALL;
177 if (Adapter == 0) { /* Display */
182 pMode->Width = GetSystemMetrics(SM_CXSCREEN);
183 pMode->Height = GetSystemMetrics(SM_CYSCREEN);
184 pMode->RefreshRate = 85; /*FIXME: How to identify? */
185 } else if (Mode < (NUM_MODES+1)) {
186 pMode->Width = modes[Mode-1][0];
187 pMode->Height = modes[Mode-1][1];
188 pMode->RefreshRate = modes[Mode-1][2];
190 TRACE("Requested mode out of range %d\n", Mode);
191 return D3DERR_INVALIDCALL;
194 hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
195 bpp = GetDeviceCaps(hdc, BITSPIXEL);
199 case 8: pMode->Format = D3DFMT_R3G3B2; break;
200 /*case 16: pMode->Format = D3DFMT_A4R4G4B4; break;*/
201 case 16: pMode->Format = D3DFMT_R5G6B5; break;
202 case 24: pMode->Format = D3DFMT_R8G8B8; break;
203 case 32: pMode->Format = D3DFMT_A8R8G8B8; break;
204 default: pMode->Format = D3DFMT_UNKNOWN;
206 TRACE("W %d H %d rr %d fmt %x\n", pMode->Width, pMode->Height, pMode->RefreshRate, pMode->Format);
209 FIXME("Adapter not primary display\n");
215 HRESULT WINAPI IDirect3D8Impl_GetAdapterDisplayMode (LPDIRECT3D8 iface,
216 UINT Adapter, D3DDISPLAYMODE* pMode) {
217 ICOM_THIS(IDirect3D8Impl,iface);
218 TRACE("(%p}->(Adapter: %d, pMode: %p)\n", This, Adapter, pMode);
220 if (Adapter >= IDirect3D8Impl_GetAdapterCount(iface)) {
221 return D3DERR_INVALIDCALL;
224 if (Adapter == 0) { /* Display */
228 pMode->Width = GetSystemMetrics(SM_CXSCREEN);
229 pMode->Height = GetSystemMetrics(SM_CYSCREEN);
230 pMode->RefreshRate = 85; /*FIXME: How to identify? */
232 hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
233 bpp = GetDeviceCaps(hdc, BITSPIXEL);
237 case 8: pMode->Format = D3DFMT_R3G3B2; break;
238 case 16: pMode->Format = D3DFMT_R5G6B5; break;
239 /*case 16: pMode->Format = D3DFMT_A4R4G4B4; break;*/
240 case 24: pMode->Format = D3DFMT_R8G8B8; break;
241 case 32: pMode->Format = D3DFMT_A8R8G8B8; break;
242 default: pMode->Format = D3DFMT_UNKNOWN;
246 FIXME("Adapter not primary display\n");
249 TRACE("returning w:%d, h:%d, ref:%d, fmt:%x\n", pMode->Width,
250 pMode->Height, pMode->RefreshRate, pMode->Format);
254 HRESULT WINAPI IDirect3D8Impl_CheckDeviceType (LPDIRECT3D8 iface,
255 UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat,
256 D3DFORMAT BackBufferFormat, BOOL Windowed) {
257 ICOM_THIS(IDirect3D8Impl,iface);
258 FIXME("(%p)->(Adptr:%d, CheckType:%x, DispFmt:%x, BackBuf:%x, Win? %d): stub\n", This, Adapter, CheckType,
259 DisplayFormat, BackBufferFormat, Windowed);
263 HRESULT WINAPI IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 iface,
264 UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
265 DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
266 ICOM_THIS(IDirect3D8Impl,iface);
267 FIXME("(%p)->(Adptr:%d, DevType: %x, AdptFmt: %d, Use: %ld, ResTyp: %x, CheckFmt: %d)\n", This, Adapter, DeviceType,
268 AdapterFormat, Usage, RType, CheckFormat);
272 HRESULT WINAPI IDirect3D8Impl_CheckDeviceMultiSampleType (LPDIRECT3D8 iface,
273 UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat,
274 BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType) {
275 ICOM_THIS(IDirect3D8Impl,iface);
276 FIXME("(%p)->(Adptr:%d, DevType: %x, SurfFmt: %x, Win? %d, MultiSamp: %x)\n", This, Adapter, DeviceType,
277 SurfaceFormat, Windowed, MultiSampleType);
281 HRESULT WINAPI IDirect3D8Impl_CheckDepthStencilMatch (LPDIRECT3D8 iface,
282 UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
283 D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) {
284 ICOM_THIS(IDirect3D8Impl,iface);
285 FIXME("(%p)->(Adptr:%d, DevType: %x, AdptFmt: %x, RendrTgtFmt: %x, DepthStencilFmt: %x)\n", This, Adapter, DeviceType,
286 AdapterFormat, RenderTargetFormat, DepthStencilFormat);
290 HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps (LPDIRECT3D8 iface,
291 UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS8* pCaps) {
292 ICOM_THIS(IDirect3D8Impl,iface);
293 TRACE("(%p)->(Adptr:%d, DevType: %x, pCaps: %p)\n", This, Adapter, DeviceType, pCaps);
296 /* NOTE: Most of the values here are complete garbage for now */
297 pCaps->DeviceType = (DeviceType == D3DDEVTYPE_HAL) ? D3DDEVTYPE_HAL : D3DDEVTYPE_REF; /* Not quite true, but use h/w supported by opengl I suppose */
298 pCaps->AdapterOrdinal = Adapter;
301 pCaps->Caps2 = D3DCAPS2_CANRENDERWINDOWED;
302 pCaps->Caps3 = D3DDEVCAPS_HWTRANSFORMANDLIGHT;
303 pCaps->PresentationIntervals = D3DPRESENT_INTERVAL_IMMEDIATE;
305 pCaps->CursorCaps = 0;
307 pCaps->DevCaps = D3DDEVCAPS_DRAWPRIMTLVERTEX | D3DDEVCAPS_HWTRANSFORMANDLIGHT | D3DDEVCAPS_PUREDEVICE;
309 pCaps->PrimitiveMiscCaps = D3DPMISCCAPS_CULLCCW | D3DPMISCCAPS_CULLCW | D3DPMISCCAPS_COLORWRITEENABLE | D3DPMISCCAPS_CLIPTLVERTS |
310 D3DPMISCCAPS_CLIPPLANESCALEDPOINTS | D3DPMISCCAPS_MASKZ; /*NOT: D3DPMISCCAPS_TSSARGTEMP*/
311 pCaps->RasterCaps = D3DPRASTERCAPS_DITHER | D3DPRASTERCAPS_PAT;
312 pCaps->ZCmpCaps = D3DPCMPCAPS_ALWAYS | D3DPCMPCAPS_EQUAL | D3DPCMPCAPS_GREATER | D3DPCMPCAPS_GREATEREQUAL |
313 D3DPCMPCAPS_LESS | D3DPCMPCAPS_LESSEQUAL | D3DPCMPCAPS_NEVER | D3DPCMPCAPS_NOTEQUAL;
315 pCaps->SrcBlendCaps = 0;
316 pCaps->DestBlendCaps = 0;
317 pCaps->AlphaCmpCaps = 0;
318 pCaps->ShadeCaps = D3DPSHADECAPS_SPECULARGOURAUDRGB | D3DPSHADECAPS_COLORGOURAUDRGB ;
319 pCaps->TextureCaps = D3DPTEXTURECAPS_ALPHA | D3DPTEXTURECAPS_ALPHAPALETTE | D3DPTEXTURECAPS_CUBEMAP | D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_VOLUMEMAP | D3DPTEXTURECAPS_MIPMAP;
320 pCaps->TextureFilterCaps = 0;
321 pCaps->CubeTextureFilterCaps = 0;
322 pCaps->VolumeTextureFilterCaps = 0;
323 pCaps->TextureAddressCaps = D3DPTADDRESSCAPS_BORDER | D3DPTADDRESSCAPS_CLAMP | D3DPTADDRESSCAPS_WRAP;
324 pCaps->VolumeTextureAddressCaps = 0;
326 pCaps->LineCaps = D3DLINECAPS_TEXTURE | D3DLINECAPS_ZTEST;
328 pCaps->MaxTextureWidth = 16384;
329 pCaps->MaxTextureHeight = 16384;
330 pCaps->MaxVolumeExtent = 0;
332 pCaps->MaxTextureRepeat = 32768;
333 pCaps->MaxTextureAspectRatio = 32768;
334 pCaps->MaxAnisotropy = 0;
335 pCaps->MaxVertexW = 1.0;
337 pCaps->GuardBandLeft = 0;
338 pCaps->GuardBandTop = 0;
339 pCaps->GuardBandRight = 0;
340 pCaps->GuardBandBottom = 0;
342 pCaps->ExtentsAdjust = 0;
344 pCaps->StencilCaps = D3DSTENCILCAPS_DECRSAT | D3DSTENCILCAPS_INCRSAT |
345 D3DSTENCILCAPS_INVERT | D3DSTENCILCAPS_KEEP |
346 D3DSTENCILCAPS_REPLACE | D3DSTENCILCAPS_ZERO /* | D3DSTENCILCAPS_DECR | D3DSTENCILCAPS_INCR */;
348 pCaps->FVFCaps = D3DFVFCAPS_PSIZE | 0x80000;
349 pCaps->TextureOpCaps = 0xFFFFFFFF;
352 GLint gl_max_texture_units_arb;
353 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max_texture_units_arb);
354 TRACE("GLCaps: GL_MAX_TEXTURE_UNITS_ARB=%d\n", gl_max_texture_units_arb);
355 pCaps->MaxTextureBlendStages = min(8, gl_max_texture_units_arb);
356 pCaps->MaxSimultaneousTextures = min(8, gl_max_texture_units_arb);
359 pCaps->VertexProcessingCaps = D3DVTXPCAPS_DIRECTIONALLIGHTS | D3DVTXPCAPS_MATERIALSOURCE7 | D3DVTXPCAPS_POSITIONALLIGHTS | D3DVTXPCAPS_TEXGEN;
361 pCaps->MaxActiveLights = 8;
362 pCaps->MaxUserClipPlanes = 1;
363 pCaps->MaxVertexBlendMatrices = 1;
364 pCaps->MaxVertexBlendMatrixIndex = 1;
366 pCaps->MaxPointSize = 128.0;
368 pCaps->MaxPrimitiveCount = 0xFFFFFFFF;
369 pCaps->MaxVertexIndex = 0xFFFFFFFF;
370 pCaps->MaxStreams = 1;
371 pCaps->MaxStreamStride = 1024;
373 pCaps->VertexShaderVersion = D3DVS_VERSION(1,1);
374 pCaps->MaxVertexShaderConst = D3D8_VSHADER_MAX_CONSTANTS;
376 pCaps->PixelShaderVersion = D3DPS_VERSION(1,1);
377 pCaps->MaxPixelShaderValue = 1.0;
382 HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor (LPDIRECT3D8 iface,
384 ICOM_THIS(IDirect3D8Impl,iface);
385 FIXME("(%p)->(Adptr:%d)\n", This, Adapter);
389 HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
390 UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,
391 DWORD BehaviourFlags, D3DPRESENT_PARAMETERS* pPresentationParameters,
392 IDirect3DDevice8** ppReturnedDeviceInterface) {
393 IDirect3DDevice8Impl *object;
396 XVisualInfo template;
397 const char *GL_Extensions = NULL;
398 const char *GLX_Extensions = NULL;
400 ICOM_THIS(IDirect3D8Impl,iface);
401 TRACE("(%p)->(Adptr:%d, DevType: %x, FocusHwnd: %p, BehFlags: %lx, PresParms: %p, RetDevInt: %p)\n", This, Adapter, DeviceType,
402 hFocusWindow, BehaviourFlags, pPresentationParameters, ppReturnedDeviceInterface);
404 /* Allocate the storage for the device */
405 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DDevice8Impl));
406 if (NULL == object) {
407 return D3DERR_OUTOFVIDEOMEMORY;
409 object->lpVtbl = &Direct3DDevice8_Vtbl;
411 object->direct3d8 = This;
412 /** The device AddRef the direct3d8 Interface else crash in propers clients codes */
413 IDirect3D8_AddRef((LPDIRECT3D8) object->direct3d8);
414 object->UpdateStateBlock = &object->StateBlock;
416 /* Save the creation parameters */
417 object->CreateParms.AdapterOrdinal = Adapter;
418 object->CreateParms.DeviceType = DeviceType;
419 object->CreateParms.hFocusWindow = hFocusWindow;
420 object->CreateParms.BehaviorFlags = BehaviourFlags;
422 *ppReturnedDeviceInterface = (LPDIRECT3DDEVICE8)object;
424 /* Initialize settings */
425 memcpy(&object->PresentParms, pPresentationParameters, sizeof(D3DPRESENT_PARAMETERS));
427 object->PresentParms.BackBufferCount = 1; /* Opengl only supports one? */
428 pPresentationParameters->BackBufferCount = 1;
430 object->adapterNo = Adapter;
431 object->devType = DeviceType;
433 /* Initialize openGl */
436 int dblBuf[]={GLX_STENCIL_SIZE,8,GLX_RGBA,GLX_DEPTH_SIZE,16,GLX_DOUBLEBUFFER,None};
437 /* FIXME: Handle stencil appropriately via EnableAutoDepthStencil / AutoDepthStencilFormat */
438 /*int dblBuf[]={GLX_RGBA,GLX_RED_SIZE,4,GLX_GREEN_SIZE,4,GLX_BLUE_SIZE,4,GLX_DOUBLEBUFFER,None}; */
440 /* Which hwnd are we using? */
441 /* if (pPresentationParameters->Windowed) { */
442 whichHWND = pPresentationParameters->hDeviceWindow;
444 whichHWND = hFocusWindow;
446 object->win = (Window)GetPropA( whichHWND, "__wine_x11_client_window" );
449 * whichHWND = (HWND) GetDesktopWindow();
450 * object->win = (Window)GetPropA(whichHWND, "__wine_x11_whole_window" );
455 hDc = GetDC(whichHWND);
456 object->display = get_display(hDc);
459 object->visInfo = glXChooseVisual(object->display, DefaultScreen(object->display), dblBuf);
460 if (NULL == object->visInfo) {
461 FIXME("cannot choose needed glxVisual with Stencil Buffer\n");
464 * second try using wine initialized visual ...
465 * must be fixed reworking wine-glx init
467 template.visualid = (VisualID)GetPropA( GetDesktopWindow(), "__wine_x11_visual_id" );
468 object->visInfo = XGetVisualInfo(object->display, VisualIDMask, &template, &num);
469 if (NULL == object->visInfo) {
470 ERR("cannot really get XVisual\n");
472 return D3DERR_NOTAVAILABLE;
475 object->glCtx = glXCreateContext(object->display, object->visInfo, NULL, GL_TRUE);
476 if (NULL == object->glCtx) {
477 ERR("cannot create glxContext\n");
479 return D3DERR_NOTAVAILABLE;
483 ReleaseDC(whichHWND, hDc);
486 if (object->glCtx == NULL) {
487 ERR("Error in context creation !\n");
488 return D3DERR_INVALIDCALL;
490 TRACE("Context created (HWND=%p, glContext=%p, Window=%ld, VisInfo=%p)\n",
491 whichHWND, object->glCtx, object->win, object->visInfo);
494 TRACE("Creating back buffer\n");
495 /* MSDN: If Windowed is TRUE and either of the BackBufferWidth/Height values is zero,
496 then the corresponding dimension of the client area of the hDeviceWindow
497 (or the focus window, if hDeviceWindow is NULL) is taken. */
498 if (pPresentationParameters->Windowed && ((pPresentationParameters->BackBufferWidth == 0) ||
499 (pPresentationParameters->BackBufferHeight == 0))) {
502 GetClientRect(whichHWND, &Rect);
504 if (pPresentationParameters->BackBufferWidth == 0) {
505 pPresentationParameters->BackBufferWidth = Rect.right;
506 TRACE("Updating width to %d\n", pPresentationParameters->BackBufferWidth);
508 if (pPresentationParameters->BackBufferHeight == 0) {
509 pPresentationParameters->BackBufferHeight = Rect.bottom;
510 TRACE("Updating height to %d\n", pPresentationParameters->BackBufferHeight);
514 IDirect3DDevice8Impl_CreateImageSurface((LPDIRECT3DDEVICE8) object,
515 pPresentationParameters->BackBufferWidth,
516 pPresentationParameters->BackBufferHeight,
517 pPresentationParameters->BackBufferFormat,
518 (LPDIRECT3DSURFACE8*) &object->backBuffer);
520 /* Now override the surface's Flip method (if in double buffering) ?COPIED from DDRAW!?
521 ((x11_ds_private *) surface->private)->opengl_flip = TRUE;
524 struct _surface_chain *chain = surface->s.chain;
525 for (i=0;i<chain->nrofsurfaces;i++)
526 if (chain->surfaces[i]->s.surface_desc.ddsCaps.dwCaps & DDSCAPS_FLIP)
527 ((x11_ds_private *) chain->surfaces[i]->private)->opengl_flip = TRUE;
533 /*TRACE("hereeee. %x %x %x\n", object->display, object->win, object->glCtx);*/
534 if (glXMakeCurrent(object->display, object->win, object->glCtx) == False) {
535 ERR("Error in setting current context (context %p drawable %ld)!\n", object->glCtx, object->win);
537 checkGLcall("glXMakeCurrent");
539 /* Clear the screen */
540 glClearColor(1.0, 0.0, 0.0, 0.0);
541 checkGLcall("glClearColor");
542 glColor3f(1.0, 1.0, 1.0);
543 checkGLcall("glColor3f");
545 glEnable(GL_LIGHTING);
546 checkGLcall("glEnable");
548 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
549 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);");
551 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
552 checkGLcall("glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);");
554 /* Initialize openGL extension related variables */
555 object->isMultiTexture = FALSE;
556 object->TextureUnits = 1;
558 /* Parse the gl supported features, in theory enabling parts of our code appropriately */
559 GL_Extensions = glGetString(GL_EXTENSIONS);
560 TRACE("GL_Extensions reported:\n");
562 if (NULL == GL_Extensions) {
563 ERR(" GL_Extensions returns NULL\n");
565 while (*GL_Extensions != 0x00) {
566 const char *Start = GL_Extensions;
569 memset(ThisExtn, 0x00, sizeof(ThisExtn));
570 while (*GL_Extensions != ' ' && *GL_Extensions != 0x00) {
573 memcpy(ThisExtn, Start, (GL_Extensions - Start));
574 TRACE (" %s\n", ThisExtn);
576 if (strcmp(ThisExtn, "GL_ARB_multitexture") == 0) {
577 GLint gl_max_texture_units_arb;
578 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max_texture_units_arb);
579 object->isMultiTexture = TRUE;
580 object->TextureUnits = min(8, gl_max_texture_units_arb);
581 TRACE("FOUND: Multitexture support - GL_MAX_TEXTURE_UNITS_ARB=%d\n", gl_max_texture_units_arb);
584 if (*GL_Extensions == ' ') GL_Extensions++;
588 GLX_Extensions = glXQueryExtensionsString(object->display, DefaultScreen(object->display));
589 TRACE("GLX_Extensions reported:\n");
591 if (NULL == GLX_Extensions) {
592 ERR(" GLX_Extensions returns NULL\n");
594 while (*GLX_Extensions != 0x00) {
595 const char *Start = GLX_Extensions;
598 memset(ThisExtn, 0x00, sizeof(ThisExtn));
599 while (*GLX_Extensions != ' ' && *GLX_Extensions != 0x00) {
602 memcpy(ThisExtn, Start, (GLX_Extensions - Start));
603 TRACE (" %s\n", ThisExtn);
604 if (*GLX_Extensions == ' ') GLX_Extensions++;
608 /* Setup all the devices defaults */
609 CreateStateBlock((LPDIRECT3DDEVICE8) object);
613 { /* Set a default viewport */
617 vp.Width = pPresentationParameters->BackBufferWidth;
618 vp.Height = pPresentationParameters->BackBufferHeight;
621 IDirect3DDevice8Impl_SetViewport((LPDIRECT3DDEVICE8) object, &vp);
624 TRACE("(%p,%d)\n", This, Adapter);
628 ICOM_VTABLE(IDirect3D8) Direct3D8_Vtbl =
630 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
631 IDirect3D8Impl_QueryInterface,
632 IDirect3D8Impl_AddRef,
633 IDirect3D8Impl_Release,
634 IDirect3D8Impl_RegisterSoftwareDevice,
635 IDirect3D8Impl_GetAdapterCount,
636 IDirect3D8Impl_GetAdapterIdentifier,
637 IDirect3D8Impl_GetAdapterModeCount,
638 IDirect3D8Impl_EnumAdapterModes,
639 IDirect3D8Impl_GetAdapterDisplayMode,
640 IDirect3D8Impl_CheckDeviceType,
641 IDirect3D8Impl_CheckDeviceFormat,
642 IDirect3D8Impl_CheckDeviceMultiSampleType,
643 IDirect3D8Impl_CheckDepthStencilMatch,
644 IDirect3D8Impl_GetDeviceCaps,
645 IDirect3D8Impl_GetAdapterMonitor,
646 IDirect3D8Impl_CreateDevice