Commit c8901d6f authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

ddraw: Rewrite most of ddraw using WineD3D.

parent 0fa7170d
......@@ -4,44 +4,30 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = ddraw.dll
IMPORTLIB = libddraw.$(IMPLIBEXT)
IMPORTS = ole32 user32 gdi32 advapi32 kernel32 ntdll
IMPORTS = wined3d ole32 user32 gdi32 advapi32 kernel32 ntdll
EXTRAINCL = @X_CFLAGS@
EXTRALIBS = -ldxguid -luuid @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
OPENGLFILES = \
d3d_utils.c \
device_main.c \
device_opengl.c \
direct3d_main.c \
direct3d_opengl.c \
executebuffer.c \
light.c \
material.c \
opengl_utils.c \
texture.c \
vertexbuffer.c \
viewport.c
C_SRCS = \
@OPENGLFILES@ \
clipper.c \
ddraw_hal.c \
ddraw_main.c \
ddraw.c \
ddraw_thunks.c \
ddraw_user.c \
ddraw_utils.c \
device.c \
direct3d.c \
executebuffer.c \
gamma.c \
light.c \
main.c \
palette_hal.c \
palette_main.c \
material.c \
palette.c \
parent.c \
regsvr.c \
surface_dib.c \
surface_fakezbuffer.c \
surface_gamma.c \
surface_hal.c \
surface_main.c \
surface.c \
surface_thunks.c \
surface_user.c \
surface_wndproc.c
texture.c \
utils.c \
vertexbuffer.c \
viewport.c
RC_SRCS = version.rc
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -8,8 +8,8 @@
@ stdcall DirectDrawCreateEx(ptr ptr ptr ptr)
@ stdcall DirectDrawEnumerateA(ptr ptr)
@ stdcall DirectDrawEnumerateExA(ptr ptr long)
@ stdcall DirectDrawEnumerateExW(ptr ptr long)
@ stdcall DirectDrawEnumerateW(ptr ptr)
@ stub DirectDrawEnumerateExW
@ stub DirectDrawEnumerateW
@ stdcall -private DllCanUnloadNow()
@ stdcall -private DllGetClassObject(ptr ptr ptr)
@ stdcall -private DllRegisterServer()
......
......@@ -15,6 +15,9 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdarg.h>
#include "windef.h"
......@@ -205,6 +208,7 @@ IDirectDrawImpl_CreateSurface(LPDIRECTDRAW This, LPDDSURFACEDESC pSDesc,
IUnknown *pUnkOuter)
{
LPDIRECTDRAWSURFACE7 pSurface7;
IDirectDrawSurfaceImpl *impl;
HRESULT hr;
/* the LPDDSURFACEDESC -> LPDDSURFACEDESC2 conversion should be ok,
......@@ -221,6 +225,12 @@ IDirectDrawImpl_CreateSurface(LPDIRECTDRAW This, LPDDSURFACEDESC pSDesc,
IDirectDrawSurface7, IDirectDrawSurface3,
pSurface7);
impl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, pSurface7);
if(impl)
{
impl->version = 1;
}
return hr;
}
......@@ -230,6 +240,7 @@ IDirectDraw2Impl_CreateSurface(LPDIRECTDRAW2 This, LPDDSURFACEDESC pSDesc,
IUnknown *pUnkOuter)
{
LPDIRECTDRAWSURFACE7 pSurface7;
IDirectDrawSurfaceImpl *impl;
HRESULT hr;
hr = IDirectDraw7_CreateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
......@@ -244,6 +255,12 @@ IDirectDraw2Impl_CreateSurface(LPDIRECTDRAW2 This, LPDDSURFACEDESC pSDesc,
IDirectDrawSurface7, IDirectDrawSurface3,
pSurface7);
impl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, pSurface7);
if(impl)
{
impl->version = 2;
}
return hr;
}
......@@ -252,13 +269,22 @@ IDirectDraw4Impl_CreateSurface(LPDIRECTDRAW4 This, LPDDSURFACEDESC2 pSDesc,
LPDIRECTDRAWSURFACE4 *ppSurface,
IUnknown *pUnkOuter)
{
return IDirectDraw7_CreateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This),
pSDesc,
(LPDIRECTDRAWSURFACE7 *)ppSurface,
pUnkOuter);
HRESULT hr;
IDirectDrawSurfaceImpl *impl;
hr = IDirectDraw7_CreateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This),
pSDesc,
(LPDIRECTDRAWSURFACE7 *)ppSurface,
pUnkOuter);
impl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurface);
if(impl)
{
impl->version = 4;
}
return hr;
}
static HRESULT WINAPI
......@@ -709,10 +735,7 @@ IDirectDrawImpl_Initialize(LPDIRECTDRAW iface, LPGUID pGUID)
HRESULT ret_value;
ret_value = IDirectDraw7_Initialize(ICOM_INTERFACE(This, IDirectDraw7), pGUID);
/* Overwrite the falsely set 'DIRECTDRAW7' flag */
This->local.dwLocalFlags &= ~DDRAWILCL_DIRECTDRAW7;
return ret_value;
}
......@@ -721,12 +744,9 @@ IDirectDraw2Impl_Initialize(LPDIRECTDRAW2 iface, LPGUID pGUID)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirectDraw2, iface);
HRESULT ret_value;
ret_value = IDirectDraw7_Initialize(ICOM_INTERFACE(This, IDirectDraw7), pGUID);
/* Overwrite the falsely set 'DIRECTDRAW7' flag */
This->local.dwLocalFlags &= ~DDRAWILCL_DIRECTDRAW7;
return ret_value;
}
......@@ -735,12 +755,9 @@ IDirectDraw4Impl_Initialize(LPDIRECTDRAW4 iface, LPGUID pGUID)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirectDraw4, iface);
HRESULT ret_value;
ret_value = IDirectDraw7_Initialize(ICOM_INTERFACE(This, IDirectDraw7), pGUID);
/* Overwrite the falsely set 'DIRECTDRAW7' flag */
This->local.dwLocalFlags &= ~DDRAWILCL_DIRECTDRAW7;
return ret_value;
}
......@@ -942,7 +959,7 @@ IDirectDraw4Impl_GetDeviceIdentifier(LPDIRECTDRAW4 This,
return hr;
}
const IDirectDrawVtbl DDRAW_IDirectDraw_VTable =
const IDirectDrawVtbl IDirectDraw1_Vtbl =
{
IDirectDrawImpl_QueryInterface,
IDirectDrawImpl_AddRef,
......@@ -969,7 +986,7 @@ const IDirectDrawVtbl DDRAW_IDirectDraw_VTable =
IDirectDrawImpl_WaitForVerticalBlank,
};
const IDirectDraw2Vtbl DDRAW_IDirectDraw2_VTable =
const IDirectDraw2Vtbl IDirectDraw2_Vtbl =
{
IDirectDraw2Impl_QueryInterface,
IDirectDraw2Impl_AddRef,
......@@ -997,7 +1014,7 @@ const IDirectDraw2Vtbl DDRAW_IDirectDraw2_VTable =
IDirectDraw2Impl_GetAvailableVidMem
};
const IDirectDraw4Vtbl DDRAW_IDirectDraw4_VTable =
const IDirectDraw4Vtbl IDirectDraw4_Vtbl =
{
IDirectDraw4Impl_QueryInterface,
IDirectDraw4Impl_AddRef,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
/* DirectDrawGammaControl implementation
*
* Copyright 2001 TransGaming Technologies Inc.
* Copyright 2006 Stefan Dsinger
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include "wine/debug.h"
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winerror.h"
#include "wingdi.h"
#include "wine/exception.h"
#include "excpt.h"
#include "ddraw.h"
#include "d3d.h"
#include "ddraw_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
WINE_DECLARE_DEBUG_CHANNEL(ddraw_thunk);
/**********************************************************
* IUnkown parts follow
**********************************************************/
/**********************************************************
* IDirectDrawGammaControl::QueryInterface
*
* QueryInterface, thunks to IDirectDrawSurface
*
* Params:
* riid: Interface id queried for
* obj: Returns the interface pointer
*
* Returns:
* S_OK or E_NOINTERFACE: See IDirectDrawSurface7::QueryInterface
*
**********************************************************/
static HRESULT WINAPI
IDirectDrawGammaControlImpl_QueryInterface(IDirectDrawGammaControl *iface, REFIID riid,
void **obj)
{
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface);
TRACE_(ddraw_thunk)("(%p)->(%s,%p): Thunking to IDirectDrawSurface7\n", This, debugstr_guid(riid), obj);
return IDirectDrawSurface7_QueryInterface(ICOM_INTERFACE(This, IDirectDrawSurface7),
riid,
obj);
}
/**********************************************************
* IDirectDrawGammaControl::AddRef
*
* Addref, thunks to IDirectDrawSurface
*
* Returns:
* The new refcount
*
**********************************************************/
static ULONG WINAPI
IDirectDrawGammaControlImpl_AddRef(IDirectDrawGammaControl *iface)
{
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface);
TRACE_(ddraw_thunk)("(%p)->() Thunking to IDirectDrawSurface7\n", This);
return IDirectDrawSurface7_AddRef(ICOM_INTERFACE(This, IDirectDrawSurface7));
}
/**********************************************************
* IDirectDrawGammaControl::Release
*
* Release, thunks to IDirectDrawSurface
*
* Returns:
* The new refcount
*
**********************************************************/
static ULONG WINAPI
IDirectDrawGammaControlImpl_Release(IDirectDrawGammaControl *iface)
{
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface);
TRACE_(ddraw_thunk)("(%p)->() Thunking to IDirectDrawSurface7\n", This);
return IDirectDrawSurface7_Release(ICOM_INTERFACE(This, IDirectDrawSurface7));
}
/**********************************************************
* IDirectDrawGammaControl
**********************************************************/
/**********************************************************
* IDirectDrawGammaControl::GetGammaRamp
*
* Returns the current gamma ramp for a surface
*
* Params:
* Flags: Ignored
* GammaRamp: Address to write the ramp to
*
* Returns:
* DD_OK on success
* DDERR_INVALIDPARAMS if GammaRamp is NULL
*
**********************************************************/
static HRESULT WINAPI
IDirectDrawGammaControlImpl_GetGammaRamp(IDirectDrawGammaControl *iface,
DWORD Flags,
DDGAMMARAMP *GammaRamp)
{
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface);
TRACE("(%p)->(%08lx,%p)\n", This,Flags,GammaRamp);
/* This looks sane */
if(!GammaRamp)
{
ERR("(%p) GammaRamp is NULL, returning DDERR_INVALIDPARAMS\n", This);
return DDERR_INVALIDPARAMS;
}
if(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
/* This returns a void */
IWineD3DDevice_GetGammaRamp(This->ddraw->wineD3DDevice,
0 /* Swapchain */,
(WINED3DGAMMARAMP *) GammaRamp);
}
else
{
ERR("(%p) Unimplemented for non-primary surfaces\n", This);
}
return DD_OK;
}
/**********************************************************
* IDirectDrawGammaControl::SetGammaRamp
*
* Sets the red, green and blue gamma ramps for
*
* Params:
* Flags: Can be DDSGR_CALIBRATE to request calibration
* GammaRamp: Structure containing the new gamma ramp
*
* Returns:
* DD_OK on success
* DDERR_INVALIDPARAMS if GammaRamp is NULL
*
**********************************************************/
static HRESULT WINAPI
IDirectDrawGammaControlImpl_SetGammaRamp(IDirectDrawGammaControl *iface,
DWORD Flags,
DDGAMMARAMP *GammaRamp)
{
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface);
TRACE("(%p)->(%08lx,%p)\n", This,Flags,GammaRamp);
/* This looks sane */
if(!GammaRamp)
{
ERR("(%p) GammaRamp is NULL, returning DDERR_INVALIDPARAMS\n", This);
return DDERR_INVALIDPARAMS;
}
if(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
/* This returns a void */
IWineD3DDevice_SetGammaRamp(This->ddraw->wineD3DDevice,
0 /* Swapchain */,
Flags,
(WINED3DGAMMARAMP *) GammaRamp);
}
else
{
ERR("(%p) Unimplemented for non-primary surfaces\n", This);
}
return DD_OK;
}
const IDirectDrawGammaControlVtbl IDirectDrawGammaControl_Vtbl =
{
IDirectDrawGammaControlImpl_QueryInterface,
IDirectDrawGammaControlImpl_AddRef,
IDirectDrawGammaControlImpl_Release,
IDirectDrawGammaControlImpl_GetGammaRamp,
IDirectDrawGammaControlImpl_SetGammaRamp
};
/* GL API list
* Copyright (c) 2003 Lionel Ulmer / Mike McCormack
*
* This file contains all structures that are not exported
* through d3d.h and all common macros.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* Note : this file is NOT protected against double-inclusion for pretty good
reasons :-) */
#ifndef GL_API_FUNCTION
#error "This file should be included with GL_API_FUNCTION defined !"
#endif
GL_API_FUNCTION(glAlphaFunc)
GL_API_FUNCTION(glBegin)
GL_API_FUNCTION(glBindTexture)
GL_API_FUNCTION(glBlendFunc)
GL_API_FUNCTION(glClear)
GL_API_FUNCTION(glClearColor)
GL_API_FUNCTION(glClearDepth)
GL_API_FUNCTION(glClearStencil)
GL_API_FUNCTION(glClipPlane)
GL_API_FUNCTION(glColor3f)
GL_API_FUNCTION(glColor3ub)
GL_API_FUNCTION(glColor4ub)
GL_API_FUNCTION(glColorMask)
GL_API_FUNCTION(glColorMaterial)
GL_API_FUNCTION(glColorPointer)
GL_API_FUNCTION(glCopyPixels)
GL_API_FUNCTION(glCopyTexSubImage2D)
GL_API_FUNCTION(glCullFace)
GL_API_FUNCTION(glDeleteTextures)
GL_API_FUNCTION(glDepthFunc)
GL_API_FUNCTION(glDepthMask)
GL_API_FUNCTION(glDepthRange)
GL_API_FUNCTION(glDisable)
GL_API_FUNCTION(glDisableClientState)
GL_API_FUNCTION(glDrawArrays)
GL_API_FUNCTION(glDrawBuffer)
GL_API_FUNCTION(glDrawElements)
GL_API_FUNCTION(glDrawPixels)
GL_API_FUNCTION(glEnable)
GL_API_FUNCTION(glEnableClientState)
GL_API_FUNCTION(glEnd)
GL_API_FUNCTION(glFlush)
GL_API_FUNCTION(glFogf)
GL_API_FUNCTION(glFogfv)
GL_API_FUNCTION(glFogi)
GL_API_FUNCTION(glFrontFace)
GL_API_FUNCTION(glGenTextures)
GL_API_FUNCTION(glGetBooleanv)
GL_API_FUNCTION(glGetError)
GL_API_FUNCTION(glGetFloatv)
GL_API_FUNCTION(glGetIntegerv)
GL_API_FUNCTION(glGetString)
GL_API_FUNCTION(glGetTexEnviv)
GL_API_FUNCTION(glGetTexParameteriv)
GL_API_FUNCTION(glHint)
GL_API_FUNCTION(glLightModelfv)
GL_API_FUNCTION(glLightModeli)
GL_API_FUNCTION(glLightfv)
GL_API_FUNCTION(glLoadIdentity)
GL_API_FUNCTION(glLoadMatrixf)
GL_API_FUNCTION(glMaterialf)
GL_API_FUNCTION(glMaterialfv)
GL_API_FUNCTION(glMatrixMode)
GL_API_FUNCTION(glMultMatrixf)
GL_API_FUNCTION(glNormal3f)
GL_API_FUNCTION(glNormal3fv)
GL_API_FUNCTION(glNormalPointer)
GL_API_FUNCTION(glOrtho)
GL_API_FUNCTION(glPixelStorei)
GL_API_FUNCTION(glPolygonMode)
GL_API_FUNCTION(glPolygonOffset)
GL_API_FUNCTION(glPopMatrix)
GL_API_FUNCTION(glPushMatrix)
GL_API_FUNCTION(glRasterPos2i)
GL_API_FUNCTION(glRasterPos3d)
GL_API_FUNCTION(glReadBuffer)
GL_API_FUNCTION(glReadPixels)
GL_API_FUNCTION(glScissor)
GL_API_FUNCTION(glShadeModel)
GL_API_FUNCTION(glStencilFunc)
GL_API_FUNCTION(glStencilMask)
GL_API_FUNCTION(glStencilOp)
GL_API_FUNCTION(glTexCoord1fv)
GL_API_FUNCTION(glTexCoord2f)
GL_API_FUNCTION(glTexCoord2fv)
GL_API_FUNCTION(glTexCoord3fv)
GL_API_FUNCTION(glTexCoord4fv)
GL_API_FUNCTION(glTexCoordPointer)
GL_API_FUNCTION(glTexEnvf)
GL_API_FUNCTION(glTexEnvfv)
GL_API_FUNCTION(glTexEnvi)
GL_API_FUNCTION(glTexImage2D)
GL_API_FUNCTION(glTexParameteri)
GL_API_FUNCTION(glTexParameterfv)
GL_API_FUNCTION(glTexSubImage2D)
GL_API_FUNCTION(glTranslatef)
GL_API_FUNCTION(glVertex3d)
GL_API_FUNCTION(glVertex3f)
GL_API_FUNCTION(glVertex3fv)
GL_API_FUNCTION(glVertex4f)
GL_API_FUNCTION(glVertexPointer)
GL_API_FUNCTION(glViewport)
GL_API_FUNCTION(glXCreateContext)
GL_API_FUNCTION(glXDestroyContext)
GL_API_FUNCTION(glXMakeCurrent)
GL_API_FUNCTION(glXQueryExtensionsString)
GL_API_FUNCTION(glXSwapBuffers)
/* GL 'hack' private include file
* Copyright (c) 2003 Lionel Ulmer / Mike McCormack
*
* This file contains all structures that are not exported
* through d3d.h and all common macros.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __GRAPHICS_WINE_GL_PRIVATE_H
#define __GRAPHICS_WINE_GL_PRIVATE_H
#ifdef HAVE_OPENGL
#undef APIENTRY
#undef CALLBACK
#undef WINAPI
#define XMD_H /* This is to prevent the Xmd.h inclusion bug :-/ */
#include <GL/gl.h>
#include <GL/glx.h>
#ifdef HAVE_GL_GLEXT_H
# include <GL/glext.h>
#endif
#undef XMD_H
#undef APIENTRY
#undef CALLBACK
#undef WINAPI
/* Redefines the constants */
#define CALLBACK __stdcall
#define WINAPI __stdcall
#define APIENTRY WINAPI
#define GL_API_FUNCTION(f) extern typeof(f) * p##f;
#include "gl_api.h"
#undef GL_API_FUNCTION
/* This is also where I store our private extension defines...
I know that Raphael won't like it, but well, I prefer doing that than battling 10 different headers :-)
Note: this is perfectly 'legal' as the three variants of the enum have exactly the same value
*/
#define GL_MIRRORED_REPEAT_WINE 0x8370
#define GL_TEXTURE_FILTER_CONTROL_WINE 0x8500
#define GL_TEXTURE_LOD_BIAS_WINE 0x8501
#define GL_TEXTURE0_WINE 0x84C0
#define GL_TEXTURE1_WINE 0x84C1
#define GL_TEXTURE2_WINE 0x84C2
#define GL_TEXTURE3_WINE 0x84C3
#define GL_TEXTURE4_WINE 0x84C4
#define GL_TEXTURE5_WINE 0x84C5
#define GL_TEXTURE6_WINE 0x84C6
#define GL_TEXTURE7_WINE 0x84C7
#define GL_MAX_TEXTURE_UNITS_WINE 0x84E2
#ifndef GLPRIVATE_NO_REDEFINE
#define glAlphaFunc pglAlphaFunc
#define glBegin pglBegin
#define glBindTexture pglBindTexture
#define glBlendFunc pglBlendFunc
#define glClear pglClear
#define glClearColor pglClearColor
#define glClearDepth pglClearDepth
#define glClearStencil pglClearStencil
#define glClipPlane pglClipPlane
#define glColor3f pglColor3f
#define glColor3ub pglColor3ub
#define glColor4ub pglColor4ub
#define glColorMask pglColorMask
#define glColorPointer pglColorPointer
#define glCopyPixels pglCopyPixels
#define glCopyTexSubImage2D pglCopyTexSubImage2D
#define glColorMaterial pglColorMaterial
#define glCullFace pglCullFace
#define glDeleteTextures pglDeleteTextures
#define glDepthFunc pglDepthFunc
#define glDepthMask pglDepthMask
#define glDepthRange pglDepthRange
#define glDisable pglDisable
#define glDisableClientState pglDisableClientState
#define glDrawArrays pglDrawArrays
#define glDrawBuffer pglDrawBuffer
#define glDrawElements pglDrawElements
#define glDrawPixels pglDrawPixels
#define glEnable pglEnable
#define glEnableClientState pglEnableClientState
#define glEnd pglEnd
#define glFlush pglFlush
#define glFogf pglFogf
#define glFogfv pglFogfv
#define glFogi pglFogi
#define glFrontFace pglFrontFace
#define glGenTextures pglGenTextures
#define glGetBooleanv pglGetBooleanv
#define glGetError pglGetError
#define glGetFloatv pglGetFloatv
#define glGetIntegerv pglGetIntegerv
#define glGetString pglGetString
#define glGetTexEnviv pglGetTexEnviv
#define glGetTexParameteriv pglGetTexParameteriv
#define glHint pglHint
#define glLightModelfv pglLightModelfv
#define glLightModeli pglLightModeli
#define glLightfv pglLightfv
#define glLoadIdentity pglLoadIdentity
#define glLoadMatrixf pglLoadMatrixf
#define glMaterialf pglMaterialf
#define glMaterialfv pglMaterialfv
#define glMatrixMode pglMatrixMode
#define glMultMatrixf pglMultMatrixf
#define glNormal3f pglNormal3f
#define glNormal3fv pglNormal3fv
#define glNormalPointer pglNormalPointer
#define glOrtho pglOrtho
#define glPixelStorei pglPixelStorei
#define glPolygonMode pglPolygonMode
#define glPolygonOffset pglPolygonOffset
#define glPopMatrix pglPopMatrix
#define glPushMatrix pglPushMatrix
#define glRasterPos2i pglRasterPos2i
#define glRasterPos3d pglRasterPos3d
#define glReadBuffer pglReadBuffer
#define glReadPixels pglReadPixels
#define glScissor pglScissor
#define glShadeModel pglShadeModel
#define glStencilFunc pglStencilFunc
#define glStencilMask pglStencilMask
#define glStencilOp pglStencilOp
#define glTexCoord1fv pglTexCoord1fv
#define glTexCoord2f pglTexCoord2f
#define glTexCoord2fv pglTexCoord2fv
#define glTexCoord3fv pglTexCoord3fv
#define glTexCoord4fv pglTexCoord4fv
#define glTexCoordPointer pglTexCoordPointer
#define glTexEnvf pglTexEnvf
#define glTexEnvfv pglTexEnvfv
#define glTexEnvi pglTexEnvi
#define glTexImage2D pglTexImage2D
#define glTexParameteri pglTexParameteri
#define glTexParameterfv pglTexParameterfv
#define glTexSubImage2D pglTexSubImage2D
#define glTranslatef pglTranslatef
#define glVertex3d pglVertex3d
#define glVertex3f pglVertex3f
#define glVertex3fv pglVertex3fv
#define glVertex4f pglVertex4f
#define glVertexPointer pglVertexPointer
#define glViewport pglViewport
#define glXCreateContext pglXCreateContext
#define glXDestroyContext pglXDestroyContext
#define glXMakeCurrent pglXMakeCurrent
#define glXQueryExtensionsString pglXQueryExtensionsString
#define glXSwapBuffers pglXSwapBuffers
#endif /* GLPRIVATE_NO_REDEFINE */
#endif /* HAVE_OPENGL */
#endif /* __GRAPHICS_WINE_GL_PRIVATE_H */
/* MESA private include file
* Copyright (c) 1998 Lionel ULMER
*
* This file contains all structures that are not exported
* through d3d.h and all common macros.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __GRAPHICS_WINE_MESA_PRIVATE_H
#define __GRAPHICS_WINE_MESA_PRIVATE_H
#include "d3d_private.h"
#ifdef HAVE_OPENGL
#include "gl_private.h"
/* X11 locking */
extern void (*wine_tsx11_lock_ptr)(void);
extern void (*wine_tsx11_unlock_ptr)(void);
/* As GLX relies on X, this is needed */
#define ENTER_GL() wine_tsx11_lock_ptr()
#define LEAVE_GL() wine_tsx11_unlock_ptr()
extern const GUID IID_D3DDEVICE_OpenGL;
typedef enum {
SURFACE_GL,
SURFACE_MEMORY,
SURFACE_MEMORY_DIRTY
} SURFACE_STATE;
/* This structure is used for the 'd3d_private' field of the IDirectDraw structure */
typedef struct IDirect3DGLImpl
{
int dummy; /* Empty for the moment */
} IDirect3DGLImpl;
/* This structure is used for the 'private' field of the IDirectDrawSurfaceImpl structure */
typedef struct IDirect3DTextureGLImpl
{
GLuint tex_name;
BOOLEAN loaded; /* For the moment, this is here.. Should be part of surface management though */
IDirectDrawSurfaceImpl *main; /* Pointer to the 'main' surface of the mip-map set */
/* Texture upload management */
BOOLEAN initial_upload_done;
SURFACE_STATE dirty_flag;
/* This is used to optimize dirty checking in case of mipmapping.
Note that a bitmap could have been used but it was not worth the pain as it will be very rare
to have only one mipmap level change...
The __global_dirty_flag will only be set for the main mipmap level.
*/
SURFACE_STATE __global_dirty_flag;
SURFACE_STATE *global_dirty_flag;
/* This is to optimize the 'per-texture' parameters. */
DWORD *tex_parameters;
/* Surface optimization */
void *surface_ptr;
/* Used to detect a change in internal format when going from non-CK texture to CK-ed texture */
GLenum current_internal_format;
/* This is for now used to override 'standard' surface stuff to be as transparent as possible */
void (*final_release)(struct IDirectDrawSurfaceImpl *This);
void (*lock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags);
void (*unlock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
void (*set_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal);
} IDirect3DTextureGLImpl;
typedef enum {
GL_TRANSFORM_NONE = 0,
GL_TRANSFORM_ORTHO,
GL_TRANSFORM_NORMAL,
GL_TRANSFORM_VERTEXBUFFER
} GL_TRANSFORM_STATE;
typedef enum {
WINE_GL_BUFFER_BACK = 0,
WINE_GL_BUFFER_FRONT
} WINE_GL_BUFFER_TYPE;
typedef struct IDirect3DDeviceGLImpl
{
struct IDirect3DDeviceImpl parent;
GLXContext gl_context;
/* This stores the textures which are actually bound to the GL context */
IDirectDrawSurfaceImpl *current_bound_texture[MAX_TEXTURES];
/* The last type of vertex drawn */
GL_TRANSFORM_STATE transform_state;
/* Used to handle fogging faster... */
BYTE fog_table[3 * 0x10000]; /* 3 is for R, G and B
0x10000 is 0xFF for the vertex color and
0xFF for the fog intensity */
Display *display;
Drawable drawable;
/* Variables used for the flush to frame-buffer code using the texturing code */
GLuint unlock_tex;
void *surface_ptr;
GLenum current_internal_format;
/* 0 is back-buffer, 1 is front-buffer */
SURFACE_STATE state[2];
IDirectDrawSurfaceImpl *lock_surf[2];
RECT lock_rect[2];
/* This is just here to print-out a nice warning if we have two successive locks */
BOOLEAN lock_rect_valid[2];
/* This is used to optimize some stuff */
DWORD prev_clear_color;
DWORD prev_clear_stencil;
D3DVALUE prev_clear_Z;
BOOLEAN depth_mask, depth_test, alpha_test, stencil_test, cull_face, lighting, blending, fogging;
GLenum current_alpha_test_func;
GLclampf current_alpha_test_ref;
GLenum current_tex_env;
GLenum current_active_tex_unit;
} IDirect3DDeviceGLImpl;
/* This is for the OpenGL additions... */
typedef struct {
struct IDirect3DVertexBufferImpl parent;
DWORD dwVertexTypeDesc;
D3DMATRIX world_mat, view_mat, proj_mat;
LPVOID vertices;
} IDirect3DVertexBufferGLImpl;
/* This is for GL extension support.
This can contain either only a boolean if no function pointer exists or a set
of function pointers.
*/
typedef struct {
/* Mirrored Repeat */
BOOLEAN mirrored_repeat;
/* Mipmap lod-bias */
BOOLEAN mipmap_lodbias;
/* Multi-texturing */
GLint max_texture_units;
void (*glActiveTexture)(GLenum texture);
void (*glMultiTexCoord[4])(GLenum target, const GLfloat *v);
void (*glClientActiveTexture)(GLenum texture);
/* S3TC/DXTN compressed texture */
BOOLEAN s3tc_compressed_texture;
void (*glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width,
GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
void (*glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height, GLsizei imageSize, const GLvoid *data);
} GL_EXTENSIONS_LIST;
extern GL_EXTENSIONS_LIST GL_extensions;
/* All non-static functions 'exported' by various sub-objects */
extern HRESULT direct3d_create(IDirectDrawImpl *This);
extern HRESULT d3dtexture_create(IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main_surf);
extern HRESULT d3dlight_create(IDirect3DLightImpl **obj, IDirectDrawImpl *d3d);
extern HRESULT d3dexecutebuffer_create(IDirect3DExecuteBufferImpl **obj, IDirectDrawImpl *d3d, IDirect3DDeviceImpl *d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc);
extern HRESULT d3dmaterial_create(IDirect3DMaterialImpl **obj, IDirectDrawImpl *d3d);
extern HRESULT d3dviewport_create(IDirect3DViewportImpl **obj, IDirectDrawImpl *d3d);
extern HRESULT d3dvertexbuffer_create(IDirect3DVertexBufferImpl **obj, IDirectDrawImpl *d3d, LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc, DWORD dwFlags);
extern HRESULT d3ddevice_create(IDirect3DDeviceImpl **obj, IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *surface, int version);
/* Used for Direct3D to request the device to enumerate itself */
extern HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context, DWORD version) ;
extern HRESULT d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb, LPVOID context) ;
extern HRESULT d3ddevice_find(IDirectDrawImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lplpD3DDevice);
/* Used by the DLL init routine to set-up the GL context and stuff properly */
extern BOOL d3ddevice_init_at_startup(void *gl_handle);
/* Used to upload the texture */
extern HRESULT gltex_upload_texture(IDirectDrawSurfaceImpl *This, IDirect3DDeviceImpl *d3ddev, DWORD stage) ;
/* Used to get the texture name */
extern GLuint gltex_get_tex_name(IDirectDrawSurfaceImpl *This) ;
/* Used to set-up our orthographic projection */
extern void d3ddevice_set_ortho(IDirect3DDeviceImpl *This) ;
/* Rendering state management functions */
extern void set_render_state(IDirect3DDeviceImpl* This, D3DRENDERSTATETYPE dwRenderStateType, STATEBLOCK *lpStateBlock);
extern void store_render_state(IDirect3DDeviceImpl *This, D3DRENDERSTATETYPE dwRenderStateType, DWORD dwRenderState, STATEBLOCK* lpStateBlock);
extern void get_render_state(IDirect3DDeviceImpl *This, D3DRENDERSTATETYPE dwRenderStateType, LPDWORD lpdwRenderState, STATEBLOCK* lpStateBlock);
extern void apply_render_state(IDirect3DDeviceImpl* This, STATEBLOCK* lpStateBlock);
/* Memory to texture conversion code. Split in three functions to do some optimizations. */
extern HRESULT upload_surface_to_tex_memory_init(IDirectDrawSurfaceImpl *surface, GLuint level, GLenum *prev_internal_format,
BOOLEAN need_to_alloc, BOOLEAN need_alpha_ck, DWORD tex_width, DWORD tex_height);
extern HRESULT upload_surface_to_tex_memory(RECT *rect, DWORD xoffset, DWORD yoffset, void **temp_buffer);
extern HRESULT upload_surface_to_tex_memory_release(void);
/* Some utilities functions needed to be shared.. */
extern GLenum convert_D3D_compare_to_GL(D3DCMPFUNC dwRenderState) ;
#endif /* HAVE_OPENGL */
#endif /* __GRAPHICS_WINE_MESA_PRIVATE_H */
/* DirectDraw - IDirectPalette base interface
*
* Copyright 2006 Stefan Dsinger
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "winerror.h"
#include "wine/debug.h"
#include <assert.h>
#include <string.h>
#include "ddraw_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
/*****************************************************************************
* IDirectDrawPalette::QueryInterface
*
* A usual QueryInterface implementation. Can only Query IUnknown and
* IDirectDrawPalette
*
* Params:
* refiid: The interface id queried for
* obj: Address to return the interface pointer at
*
* Returns:
* S_OK on success
* E_NOINTERFACE if the requested interface wasn't found
*****************************************************************************/
static HRESULT WINAPI
IDirectDrawPaletteImpl_QueryInterface(IDirectDrawPalette *iface,
REFIID refiid,
void **obj)
{
ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
if (IsEqualGUID(refiid, &IID_IUnknown)
|| IsEqualGUID(refiid, &IID_IDirectDrawPalette))
{
*obj = iface;
IDirectDrawPalette_AddRef(iface);
return S_OK;
}
else
{
*obj = NULL;
return E_NOINTERFACE;
}
}
/*****************************************************************************
* IDirectDrawPaletteImpl::AddRef
*
* Increases the refcount.
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirectDrawPaletteImpl_AddRef(IDirectDrawPalette *iface)
{
ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->() incrementing from %lu.\n", This, ref - 1);
return ref;
}
/*****************************************************************************
* IDirectDrawPaletteImpl::Release
*
* Reduces the refcount. If the refcount falls to 0, the object is destroyed
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirectDrawPaletteImpl_Release(IDirectDrawPalette *iface)
{
ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->() decrementing from %lu.\n", This, ref + 1);
if (ref == 0)
{
IWineD3DPalette_Release(This->wineD3DPalette);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/*****************************************************************************
* IDirectDrawPalette::Initialize
*
* Initializes the palette. As we start initialized, return
* DDERR_ALREADYINITIALIZED
*
* Params:
* DD: DirectDraw interface this palette is asigned to
* Flags: Some flags, as usual
* ColorTable: The startup color table
*
* Returns:
* DDERR_ALREADYINITIALIZED
*
*****************************************************************************/
static HRESULT WINAPI
IDirectDrawPaletteImpl_Initialize(IDirectDrawPalette *iface,
IDirectDraw *DD,
DWORD Flags,
PALETTEENTRY *ColorTable)
{
TRACE("(%p)->(%p,%lx,%p)\n", iface, DD, Flags, ColorTable);
return DDERR_ALREADYINITIALIZED;
}
/*****************************************************************************
* IDirectDrawPalette::GetCaps
*
* Returns the palette description
*
* Params:
* Caps: Address to store the caps at
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if Caps is NULL
* For more details, see IWineD3DPalette::GetCaps
*
*****************************************************************************/
static HRESULT WINAPI
IDirectDrawPaletteImpl_GetCaps(IDirectDrawPalette *iface,
DWORD *Caps)
{
ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
TRACE("(%p)->(%p): Relay\n", This, Caps);
return IWineD3DPalette_GetCaps(This->wineD3DPalette, Caps);
}
/*****************************************************************************
* IDirectDrawPalette::SetEntries
*
* Sets the palette entries from a PALETTEENTRY structure. WineD3D takes
* care for updating the surface.
*
* Params:
* Flags: Flags, as usual
* Start: First palette entry to set
* Count: Number of entries to set
* PalEnt: Source entries
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if PalEnt is NULL
* For details, see IWineD3DDevice::SetEntries
*
*****************************************************************************/
static HRESULT WINAPI
IDirectDrawPaletteImpl_SetEntries(IDirectDrawPalette *iface,
DWORD Flags,
DWORD Start,
DWORD Count,
PALETTEENTRY *PalEnt)
{
ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
TRACE("(%p)->(%lx,%ld,%ld,%p): Relay\n", This, Flags, Start, Count, PalEnt);
if(!PalEnt)
return DDERR_INVALIDPARAMS;
return IWineD3DPalette_SetEntries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
}
/*****************************************************************************
* IDirectDrawPalette::GetEntries
*
* Returns the entries stored in this interface.
*
* Params:
* Flags: Flags :)
* Start: First entry to return
* Count: The number of entries to return
* PalEnt: PALETTEENTRY structure to write the entries to
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if PalEnt is NULL
* For details, see IWineD3DDevice::SetEntries
*
*****************************************************************************/
static HRESULT WINAPI
IDirectDrawPaletteImpl_GetEntries(IDirectDrawPalette *iface,
DWORD Flags,
DWORD Start,
DWORD Count,
PALETTEENTRY *PalEnt)
{
ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
TRACE("(%p)->(%lx,%ld,%ld,%p): Relay\n", This, Flags, Start, Count, PalEnt);
if(!PalEnt)
return DDERR_INVALIDPARAMS;
return IWineD3DPalette_GetEntries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
}
const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl =
{
/*** IUnknown ***/
IDirectDrawPaletteImpl_QueryInterface,
IDirectDrawPaletteImpl_AddRef,
IDirectDrawPaletteImpl_Release,
/*** IDirectDrawPalette ***/
IDirectDrawPaletteImpl_GetCaps,
IDirectDrawPaletteImpl_GetEntries,
IDirectDrawPaletteImpl_Initialize,
IDirectDrawPaletteImpl_SetEntries
};
/* DirectDrawPalette HAL driver
*
* Copyright 2001 TransGaming Technologies Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "winerror.h"
#include "wine/debug.h"
#include <assert.h>
#include <string.h>
#include "ddraw_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
static const IDirectDrawPaletteVtbl DDRAW_HAL_Palette_VTable;
/******************************************************************************
* IDirectDrawPalette
*/
HRESULT HAL_DirectDrawPalette_Construct(IDirectDrawPaletteImpl* This,
IDirectDrawImpl* pDD, DWORD dwFlags)
{
LPDDRAWI_DIRECTDRAW_GBL dd_gbl = pDD->local.lpGbl;
DDHAL_CREATEPALETTEDATA data;
HRESULT hr;
hr = Main_DirectDrawPalette_Construct(This, pDD, dwFlags);
if (FAILED(hr)) return hr;
This->final_release = HAL_DirectDrawPalette_final_release;
ICOM_INIT_INTERFACE(This, IDirectDrawPalette, DDRAW_HAL_Palette_VTable);
/* initialize HAL palette */
data.lpDD = dd_gbl;
data.lpDDPalette = &This->global;
data.lpColorTable = NULL;
data.ddRVal = 0;
data.CreatePalette = dd_gbl->lpDDCBtmp->HALDD.CreatePalette;
if (data.CreatePalette)
data.CreatePalette(&data);
return DD_OK;
}
HRESULT
HAL_DirectDrawPalette_Create(IDirectDrawImpl* pDD, DWORD dwFlags,
LPDIRECTDRAWPALETTE* ppPalette,
LPUNKNOWN pUnkOuter)
{
IDirectDrawPaletteImpl* This;
HRESULT hr;
if (pUnkOuter != NULL)
return CLASS_E_NOAGGREGATION; /* unchecked */
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
if (This == NULL) return E_OUTOFMEMORY;
hr = HAL_DirectDrawPalette_Construct(This, pDD, dwFlags);
if (FAILED(hr))
HeapFree(GetProcessHeap(), 0, This);
else
*ppPalette = ICOM_INTERFACE(This, IDirectDrawPalette);
return hr;
}
HRESULT WINAPI
HAL_DirectDrawPalette_SetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags,
DWORD dwStart, DWORD dwCount,
LPPALETTEENTRY palent)
{
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
LPDDRAWI_DIRECTDRAW_GBL dd_gbl = This->local.lpDD_lcl->lpGbl;
DDHAL_SETENTRIESDATA data;
TRACE("(%p)->SetEntries(%08lx,%ld,%ld,%p)\n",This,dwFlags,dwStart,dwCount,
palent);
data.lpDD = dd_gbl;
data.lpDDPalette = &This->global;
data.dwBase = dwStart;
data.dwNumEntries = dwCount;
data.lpEntries = palent;
data.ddRVal = 0;
data.SetEntries = dd_gbl->lpDDCBtmp->HALDDPalette.SetEntries;
if (data.SetEntries)
data.SetEntries(&data);
return Main_DirectDrawPalette_SetEntries(iface, dwFlags, dwStart, dwCount, palent);
}
void HAL_DirectDrawPalette_final_release(IDirectDrawPaletteImpl* This)
{
LPDDRAWI_DIRECTDRAW_GBL dd_gbl = This->local.lpDD_lcl->lpGbl;
DDHAL_DESTROYPALETTEDATA data;
/* destroy HAL palette */
data.lpDD = dd_gbl;
data.lpDDPalette = &This->global;
data.ddRVal = 0;
data.DestroyPalette = dd_gbl->lpDDCBtmp->HALDDPalette.DestroyPalette;
if (data.DestroyPalette)
data.DestroyPalette(&data);
Main_DirectDrawPalette_final_release(This);
}
static const IDirectDrawPaletteVtbl DDRAW_HAL_Palette_VTable =
{
Main_DirectDrawPalette_QueryInterface,
Main_DirectDrawPalette_AddRef,
Main_DirectDrawPalette_Release,
Main_DirectDrawPalette_GetCaps,
Main_DirectDrawPalette_GetEntries,
Main_DirectDrawPalette_Initialize,
HAL_DirectDrawPalette_SetEntries
};
/* DirectDraw - IDirectPalette base interface
*
* Copyright 1997-2000 Marcus Meissner
* Copyright 2000-2001 TransGaming Technologies Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "winerror.h"
#include "wine/debug.h"
#include <assert.h>
#include <string.h>
#include "ddraw_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
#define SIZE_BITS (DDPCAPS_1BIT | DDPCAPS_2BIT | DDPCAPS_4BIT | DDPCAPS_8BIT)
/* For unsigned x. 0 is not a power of 2. */
#define IS_POW_2(x) (((x) & ((x) - 1)) == 0)
static const IDirectDrawPaletteVtbl DDRAW_Main_Palette_VTable;
/******************************************************************************
* IDirectDrawPalette
*/
HRESULT Main_DirectDrawPalette_Construct(IDirectDrawPaletteImpl* This,
IDirectDrawImpl* pDD, DWORD dwFlags)
{
if (!IS_POW_2(dwFlags & SIZE_BITS)) return DDERR_INVALIDPARAMS;
if (dwFlags & DDPCAPS_8BITENTRIES)
WARN("creating palette with 8 bit entries\n");
This->palNumEntries = Main_DirectDrawPalette_Size(dwFlags);
This->ref = 1;
This->local.lpGbl = &This->global;
This->local.lpDD_lcl = &pDD->local;
This->global.lpDD_lcl = &pDD->local;
This->global.dwProcessId = GetCurrentProcessId();
This->global.dwFlags = dwFlags;
This->final_release = Main_DirectDrawPalette_final_release;
ICOM_INIT_INTERFACE(This, IDirectDrawPalette, DDRAW_Main_Palette_VTable);
/* we could defer hpal creation until we need it,
* but does anyone have a case where it would be useful? */
This->hpal = CreatePalette((const LOGPALETTE*)&(This->palVersion));
Main_DirectDraw_AddPalette(pDD, This);
return DD_OK;
}
HRESULT
Main_DirectDrawPalette_Create(IDirectDrawImpl* pDD, DWORD dwFlags,
LPDIRECTDRAWPALETTE* ppPalette,
LPUNKNOWN pUnkOuter)
{
IDirectDrawPaletteImpl* This;
HRESULT hr;
if (pUnkOuter != NULL)
return CLASS_E_NOAGGREGATION; /* unchecked */
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
if (This == NULL) return E_OUTOFMEMORY;
hr = Main_DirectDrawPalette_Construct(This, pDD, dwFlags);
if (FAILED(hr))
HeapFree(GetProcessHeap(), 0, This);
else
*ppPalette = ICOM_INTERFACE(This, IDirectDrawPalette);
return hr;
}
DWORD Main_DirectDrawPalette_Size(DWORD dwFlags)
{
switch (dwFlags & SIZE_BITS)
{
case DDPCAPS_1BIT: return 2;
case DDPCAPS_2BIT: return 4;
case DDPCAPS_4BIT: return 16;
case DDPCAPS_8BIT: return 256;
default: assert(0); return 256;
}
}
HRESULT WINAPI
Main_DirectDrawPalette_GetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags,
DWORD dwStart, DWORD dwCount,
LPPALETTEENTRY palent)
{
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
TRACE("(%p)->GetEntries(%08lx,%ld,%ld,%p)\n",This,dwFlags,dwStart,dwCount,
palent);
if (dwFlags != 0) return DDERR_INVALIDPARAMS; /* unchecked */
if (dwStart + dwCount > Main_DirectDrawPalette_Size(This->global.dwFlags))
return DDERR_INVALIDPARAMS;
if (This->global.dwFlags & DDPCAPS_8BITENTRIES)
{
unsigned int i;
LPBYTE entry = (LPBYTE)palent;
for (i=dwStart; i < dwCount+dwStart; i++)
*entry++ = This->palents[i].peRed;
}
else
memcpy(palent, This->palents+dwStart, dwCount * sizeof(PALETTEENTRY));
return DD_OK;
}
HRESULT WINAPI
Main_DirectDrawPalette_SetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags,
DWORD dwStart, DWORD dwCount,
LPPALETTEENTRY palent)
{
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
TRACE("(%p)->SetEntries(%08lx,%ld,%ld,%p)\n",This,dwFlags,dwStart,dwCount,
palent);
if (This->global.dwFlags & DDPCAPS_8BITENTRIES)
{
unsigned int i;
const BYTE* entry = (const BYTE*)palent;
for (i=dwStart; i < dwCount+dwStart; i++)
This->palents[i].peRed = *entry++;
}
else {
memcpy(This->palents+dwStart, palent, dwCount * sizeof(PALETTEENTRY));
if (This->hpal)
SetPaletteEntries(This->hpal, dwStart, dwCount, This->palents+dwStart);
if (This->global.dwFlags & DDPCAPS_PRIMARYSURFACE) {
/* update physical palette */
LPDIRECTDRAWSURFACE7 psurf = NULL;
IDirectDraw7_GetGDISurface(ICOM_INTERFACE(This->ddraw_owner,IDirectDraw7), &psurf);
if (psurf) {
IDirectDrawSurfaceImpl *surf = ICOM_OBJECT(IDirectDrawSurfaceImpl,
IDirectDrawSurface7, psurf);
surf->update_palette(surf, This, dwStart, dwCount, palent);
IDirectDrawSurface7_Release(psurf);
}
else ERR("can't find GDI surface!!\n");
}
}
#if 0
/* Now, if we are in 'depth conversion mode', update the screen palette */
/* FIXME: we need to update the image or we won't get palette fading. */
if (This->ddraw->d->palette_convert != NULL)
This->ddraw->d->palette_convert(palent,This->screen_palents,start,count);
#endif
return DD_OK;
}
void Main_DirectDrawPalette_final_release(IDirectDrawPaletteImpl* This)
{
Main_DirectDraw_RemovePalette(This->ddraw_owner, This);
if (This->hpal) DeleteObject(This->hpal);
}
static void Main_DirectDrawPalette_Destroy(IDirectDrawPaletteImpl* This)
{
This->final_release(This);
if (This->private != This+1)
HeapFree(GetProcessHeap(), 0, This->private);
HeapFree(GetProcessHeap(),0,This);
}
void Main_DirectDrawPalette_ForceDestroy(IDirectDrawPaletteImpl* This)
{
WARN("deleting palette %p with refcnt %lu\n", This, This->ref);
Main_DirectDrawPalette_Destroy(This);
}
ULONG WINAPI
Main_DirectDrawPalette_Release(LPDIRECTDRAWPALETTE iface)
{
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->() decrementing from %lu.\n", This, ref + 1);
if (!ref)
{
Main_DirectDrawPalette_Destroy(This);
return 0;
}
return ref;
}
ULONG WINAPI Main_DirectDrawPalette_AddRef(LPDIRECTDRAWPALETTE iface) {
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->() incrementing from %lu.\n", This, ref - 1);
return ref;
}
HRESULT WINAPI
Main_DirectDrawPalette_Initialize(LPDIRECTDRAWPALETTE iface,
LPDIRECTDRAW ddraw, DWORD dwFlags,
LPPALETTEENTRY palent)
{
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
TRACE("(%p)->(%p,%ld,%p)\n", This, ddraw, dwFlags, palent);
return DDERR_ALREADYINITIALIZED;
}
HRESULT WINAPI
Main_DirectDrawPalette_GetCaps(LPDIRECTDRAWPALETTE iface, LPDWORD lpdwCaps)
{
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
TRACE("(%p)->(%p)\n",This,lpdwCaps);
*lpdwCaps = This->global.dwFlags;
return DD_OK;
}
HRESULT WINAPI
Main_DirectDrawPalette_QueryInterface(LPDIRECTDRAWPALETTE iface,
REFIID refiid, LPVOID *obj)
{
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
if (IsEqualGUID(refiid, &IID_IUnknown)
|| IsEqualGUID(refiid, &IID_IDirectDrawPalette))
{
*obj = iface;
IDirectDrawPalette_AddRef(iface);
return S_OK;
}
else
{
return E_NOINTERFACE;
}
}
static const IDirectDrawPaletteVtbl DDRAW_Main_Palette_VTable =
{
Main_DirectDrawPalette_QueryInterface,
Main_DirectDrawPalette_AddRef,
Main_DirectDrawPalette_Release,
Main_DirectDrawPalette_GetCaps,
Main_DirectDrawPalette_GetEntries,
Main_DirectDrawPalette_Initialize,
Main_DirectDrawPalette_SetEntries
};
/*
* IParent implementation
*
* Copyright (c) 2006 Stefan Dösinger
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* A universal parent interface for everything in WineD3D that doesn't have
* a DDraw counterpart
*/
#include "config.h"
#include "wine/port.h"
#include "wine/debug.h"
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winerror.h"
#include "wingdi.h"
#include "wine/exception.h"
#include "excpt.h"
#include "ddraw.h"
#include "d3d.h"
#include "ddraw_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
const GUID IID_IParent = {0xc20e4c88, 0x74e7, 0x4940, {0xba, 0x9f, 0x2e, 0x32, 0x3f, 0x9d, 0xc9, 0x81}};
/*****************************************************************************
* IUnknown methods
*****************************************************************************/
/*****************************************************************************
* IParent::Queryinterface
*
* It can't query any interfaces, and it's not used for anything. So
* it just returns E_NOINTERFACE
*
* Params:
* riid: guid of queried interface
* obj: returns a pointer to the interface
*
* Return values
* This implementation always returns E_NOINTERFACE and NULL
*
*****************************************************************************/
static HRESULT WINAPI
IParentImpl_QueryInterface(IParent *iface,
REFIID riid,
void **obj)
{
ICOM_THIS_FROM(IParentImpl, IParent, iface);
TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), obj);
*obj = NULL;
if ( IsEqualGUID( &IID_IUnknown, riid ) ||
IsEqualGUID( &IID_IParent, riid ) )
{
*obj = ICOM_INTERFACE(This, IParent);
IParent_AddRef(ICOM_INTERFACE(This, IParent));
return DD_OK;
}
return E_NOINTERFACE;
}
/*****************************************************************************
* IParent::AddRef
*
* Increases the refcount
*
* Params:
*
* Return values
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IParentImpl_AddRef(IParent *iface)
{
ICOM_THIS_FROM(IParentImpl, IParent, iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
return ref;
}
/*****************************************************************************
* IParent::Release
*
* Releases the refcount, and destroys the object if the refcount falls to 0
* Also releases the child object, if destroyed. That's almost the whole sense
* of this interface.
*
* Params:
*
* Return values
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IParentImpl_Release(IParent *iface)
{
ICOM_THIS_FROM(IParentImpl, IParent, iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
if (ref == 0)
{
TRACE("(%p) Releasing child at %p\n", This, This->child);
if(This->child)
IUnknown_Release(This->child);
HeapFree(GetProcessHeap(), 0, This);
TRACE("Released\n");
}
return ref;
}
/*****************************************************************************
* The VTable
*****************************************************************************/
const IParentVtbl IParent_Vtbl =
{
IParentImpl_QueryInterface,
IParentImpl_AddRef,
IParentImpl_Release,
};
/* DirectDrawGammaControl implementation
*
* Copyright 2001 TransGaming Technologies Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "winerror.h"
#include <assert.h>
#include <stdlib.h>
#include "wine/debug.h"
#include "ddraw_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
#define CONVERT(pddgc) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, \
IDirectDrawGammaControl, \
IDirectDrawSurface7, \
(pddgc))
static HRESULT WINAPI
DirectDrawGammaControl_QueryInterface(LPDIRECTDRAWGAMMACONTROL iface, REFIID riid,
LPVOID *ppObj)
{
TRACE("(%p)->(%s,%p)\n", iface, debugstr_guid(riid), ppObj);
return E_NOINTERFACE;
}
static ULONG WINAPI
DirectDrawGammaControl_AddRef(LPDIRECTDRAWGAMMACONTROL iface)
{
return IDirectDrawSurface7_AddRef(CONVERT(iface));
}
static ULONG WINAPI
DirectDrawGammaControl_Release(LPDIRECTDRAWGAMMACONTROL iface)
{
return IDirectDrawSurface7_Release(CONVERT(iface));
}
static HRESULT WINAPI
DirectDrawGammaControl_GetGammaRamp(LPDIRECTDRAWGAMMACONTROL iface, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp)
{
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface);
TRACE("(%p)->(%08lx,%p)\n", iface,dwFlags,lpGammaRamp);
return This->get_gamma_ramp(This, dwFlags, lpGammaRamp);
}
static HRESULT WINAPI
DirectDrawGammaControl_SetGammaRamp(LPDIRECTDRAWGAMMACONTROL iface, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp)
{
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface);
TRACE("(%p)->(%08lx,%p)\n", iface,dwFlags,lpGammaRamp);
return This->set_gamma_ramp(This, dwFlags, lpGammaRamp);
}
const IDirectDrawGammaControlVtbl DDRAW_IDDGC_VTable =
{
DirectDrawGammaControl_QueryInterface,
DirectDrawGammaControl_AddRef,
DirectDrawGammaControl_Release,
DirectDrawGammaControl_GetGammaRamp,
DirectDrawGammaControl_SetGammaRamp
};
......@@ -17,6 +17,8 @@
*/
#include "config.h"
#include "wine/port.h"
#include "wine/debug.h"
#include <stdarg.h>
#include "windef.h"
......@@ -38,6 +40,8 @@
IDirectDrawSurface3, \
(pdds))
WINE_DEFAULT_DEBUG_CHANNEL(ddraw_thunk);
static HRESULT WINAPI
IDirectDrawSurface3Impl_QueryInterface(LPDIRECTDRAWSURFACE3 This, REFIID iid,
LPVOID *ppObj)
......@@ -52,9 +56,11 @@ IDirectDrawSurface3Impl_AddRef(LPDIRECTDRAWSURFACE3 This)
}
static ULONG WINAPI
IDirectDrawSurface3Impl_Release(LPDIRECTDRAWSURFACE3 This)
IDirectDrawSurface3Impl_Release(LPDIRECTDRAWSURFACE3 iface)
{
return IDirectDrawSurface7_Release(CONVERT(This));
ICOM_THIS_FROM( IDirectDrawSurfaceImpl, IDirectDrawSurface3, iface);
TRACE("(%p)\n", This);
return IDirectDrawSurface7_Release(CONVERT(iface));
}
static HRESULT WINAPI
......@@ -389,7 +395,7 @@ IDirectDrawSurface3Impl_SetSurfaceDesc(LPDIRECTDRAWSURFACE3 This,
dwFlags);
}
const IDirectDrawSurface3Vtbl DDRAW_IDDS3_Thunk_VTable =
const IDirectDrawSurface3Vtbl IDirectDrawSurface3_Vtbl =
{
IDirectDrawSurface3Impl_QueryInterface,
IDirectDrawSurface3Impl_AddRef,
......
/* User-based primary surface driver
*
* Copyright 2000 TransGaming Technologies Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "winerror.h"
#include "ddraw_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
static LRESULT WINAPI DirectDrawSurface_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
void DirectDrawSurface_RegisterClass(void)
{
WNDCLASSA wc;
memset(&wc, 0, sizeof(wc));
wc.lpfnWndProc = DirectDrawSurface_WndProc;
wc.cbWndExtra = sizeof(IDirectDrawSurfaceImpl*);
wc.hCursor = (HCURSOR)IDC_ARROW;
wc.lpszClassName = "WINE_DDRAW";
RegisterClassA(&wc);
}
void DirectDrawSurface_UnregisterClass(void)
{
UnregisterClassA("WINE_DDRAW", 0);
}
static LRESULT WINAPI DirectDrawSurface_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
IDirectDrawSurfaceImpl *This;
LRESULT ret;
This = (IDirectDrawSurfaceImpl *)GetWindowLongPtrA(hwnd, 0);
if (This) {
HWND window = This->ddraw_owner->window;
switch (msg) {
case WM_DESTROY:
case WM_NCDESTROY:
case WM_SHOWWINDOW:
case WM_WINDOWPOSCHANGING:
case WM_WINDOWPOSCHANGED:
case WM_SIZE:
case WM_MOVE:
case WM_ERASEBKGND:
case WM_SYNCPAINT:
/* since we're pretending fullscreen,
* let's not pass these on to the app */
ret = DefWindowProcA(hwnd, msg, wParam, lParam);
break;
case WM_NCHITTEST:
ret = HTCLIENT;
break;
case WM_MOUSEACTIVATE:
ret = MA_NOACTIVATE;
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC dc;
dc = BeginPaint(hwnd, &ps);
/* call User_copy_to_screen? */
EndPaint(hwnd, &ps);
ret = 0;
}
break;
default:
ret = window ? SendMessageA(window, msg, wParam, lParam)
: DefWindowProcA(hwnd, msg, wParam, lParam);
}
} else {
if (msg == WM_CREATE) {
CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
This = (IDirectDrawSurfaceImpl *)cs->lpCreateParams;
SetWindowLongPtrA(hwnd, 0, (LONG_PTR)This);
}
ret = DefWindowProcA(hwnd, msg, wParam, lParam);
}
return ret;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment