Author: greatlrd
Date: Sat Dec 9 21:31:31 2006
New Revision: 25104
URL:
http://svn.reactos.org/svn/reactos?rev=25104&view=rev
Log:
Test code to create surface. it is a big hack to create a primare surface.
but we success create a primary surface. with this hack.
Modified:
trunk/reactos/dll/directx/ddraw/main/ddraw_main.c
Modified: trunk/reactos/dll/directx/ddraw/main/ddraw_main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/main/ddr…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/main/ddraw_main.c (original)
+++ trunk/reactos/dll/directx/ddraw/main/ddraw_main.c Sat Dec 9 21:31:31 2006
@@ -185,6 +185,7 @@
LPDDRAWI_DDRAWSURFACE_INT That;
DDHAL_CANCREATESURFACEDATA mDdCanCreateSurface;
DDHAL_CREATESURFACEDATA mDdCreateSurface;
+ LPDDRAWI_DDRAWSURFACE_MORE SurfaceMore;
if (pUnkOuter!=NULL)
{
@@ -250,6 +251,7 @@
/* own code now */
+
mDdCanCreateSurface.lpDD = This->lpLcl->lpGbl;
mDdCanCreateSurface.bIsDifferentPixelFormat = FALSE;
mDdCanCreateSurface.lpDDSurfaceDesc = (LPDDSURFACEDESC) pDDSD;
@@ -261,43 +263,77 @@
mDdCreateSurface.dwSCnt = That->dwIntRefCnt + 1; // is this correct
mDdCreateSurface.lpDDSurfaceDesc = (LPDDSURFACEDESC) pDDSD;
//mDdCreateSurface.lplpSList = That->lpLcl->lpSurfMore->slist;
- mDdCreateSurface.lplpSList = &That->lpLcl;
+ //mDdCreateSurface.lplpSList = &That->lpLcl;
+
+ SurfaceMore = DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_MORE));
+ if (SurfaceMore == NULL)
+ {
+ return DDERR_OUTOFMEMORY;
+ }
+
+ if (pDDSD->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
+ {
+ DDRAWI_DDRAWSURFACE_LCL *mpPrimaryLocals[1];
+ DDSURFACEDESC mddsdPrimary;
+
+ This->lpLcl->lpGbl->lp16DD = This->lpLcl->lpGbl;
+ That->lpLcl->lpSurfMore = SurfaceMore;
+
+ ZeroMemory(&mddsdPrimary, sizeof(DDSURFACEDESC));
+ mddsdPrimary.dwSize = sizeof(DDSURFACEDESC);
+ mddsdPrimary.dwFlags = DDSD_CAPS;
+ mddsdPrimary.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_VIDEOMEMORY |
DDSCAPS_VISIBLE;
+
+ mDdCanCreateSurface.lpDD = This->lpLcl->lpGbl;
+ mDdCanCreateSurface.CanCreateSurface =
This->lpLcl->lpDDCB->HALDD.CanCreateSurface;
+ mDdCanCreateSurface.bIsDifferentPixelFormat = FALSE; //isDifferentPixelFormat;
+ mDdCanCreateSurface.lpDDSurfaceDesc = &mddsdPrimary; // pDDSD;
+
+ if (mDdCanCreateSurface.CanCreateSurface(&mDdCanCreateSurface)==
DDHAL_DRIVER_NOTHANDLED)
+ {
+ return DDERR_NOTINITIALIZED;
+ }
+
+ if (mDdCanCreateSurface.ddRVal != DD_OK)
+ {
+ return DDERR_NOTINITIALIZED;
+ }
-
- if (pDDSD->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
- {
-
- /* we only create one surface it is primary */
- //LPDDRAWI_DDRAWSURFACE_LCL surf;
-
- DX_STUB_str( "Can not create primary surface well yet");
-
- if (mDdCanCreateSurface.CanCreateSurface(&mDdCanCreateSurface) ==
DDHAL_DRIVER_NOTHANDLED)
- {
- DX_STUB_str( "Can not create surface ");
- return DDERR_NOTINITIALIZED;
- }
-
- if (mDdCanCreateSurface.ddRVal != DD_OK)
- {
- DX_STUB_str( "Fail");
- return mDdCanCreateSurface.ddRVal;
- }
-
- DX_STUB_str( "Can not create primary surface well yet");
-
- if (mDdCreateSurface.CreateSurface(&mDdCreateSurface) == DDHAL_DRIVER_NOTHANDLED)
- {
- DX_STUB_str( "Can not create surface fail");
- return DDERR_NOTINITIALIZED;
- }
-
- DX_STUB_str( "Can not create primary surface well yet");
-
- Main_DirectDraw_AddRef((LPDIRECTDRAW7)This);
- Main_DDrawSurface_AddRef((LPDIRECTDRAWSURFACE7)That);
- return mDdCreateSurface.ddRVal;
-
+ That->lpLcl->lpGbl->dwGlobalFlags = DDRAWISURFGBL_ISGDISURFACE;
+ That->lpLcl->lpGbl->lpDD = This->lpLcl->lpGbl;
+ That->lpLcl->lpGbl->lpDDHandle = This->lpLcl->lpGbl;
+ That->lpLcl->lpGbl->wWidth = 1024; //(WORD)mpModeInfos[0].dwWidth;
+ That->lpLcl->lpGbl->wHeight = 768; //(WORD)mpModeInfos[0].dwHeight;
+ That->lpLcl->lpGbl->lPitch = 32; //mpModeInfos[0].lPitch;
+
+ memset(SurfaceMore, 0, sizeof(DDRAWI_DDRAWSURFACE_MORE));
+ SurfaceMore->dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE);
+
+ That->lpLcl->lpGbl = That->lpLcl->lpGbl;
+ That->lpLcl->lpSurfMore = SurfaceMore;
+ That->lpLcl->dwProcessId = GetCurrentProcessId();
+ That->lpLcl->dwFlags =
DDRAWISURF_PARTOFPRIMARYCHAIN|DDRAWISURF_HASOVERLAYDATA;
+ That->lpLcl->ddsCaps.dwCaps = mddsdPrimary.ddsCaps.dwCaps;
+
+ mpPrimaryLocals[0] = That->lpLcl;
+
+ mDdCreateSurface.lpDD = This->lpLcl->lpGbl;
+ mDdCreateSurface.CreateSurface =
This->lpLcl->lpDDCB->HALDD.CreateSurface;
+ mDdCreateSurface.lpDDSurfaceDesc = &mddsdPrimary;//pDDSD;
+ mDdCreateSurface.lplpSList = mpPrimaryLocals; //cSurfaces;
+ mDdCreateSurface.dwSCnt = 1 ; //ppSurfaces;
+
+ if (mDdCreateSurface.CreateSurface(&mDdCreateSurface) ==
DDHAL_DRIVER_NOTHANDLED)
+ {
+ return DDERR_NOTINITIALIZED;
+ }
+
+ if (mDdCreateSurface.ddRVal != DD_OK)
+ {
+ return mDdCreateSurface.ddRVal;
+ }
+
+ return DD_OK;
}
else if (pDDSD->ddsCaps.dwCaps & DDSCAPS_OVERLAY)
{