DX9 driver problem
BlitzMax Forums/BlitzMax Programming/DX9 driver problem
| ||
I was testing Doug Stastny's DX9 driver this weekend, and I think I found a small problem on it, and I have no clue how to fix it... On my game I pre-render text into images (using grabpixmap), and in the main loop, I just draw the images. The program below shows more or less what I do in my game. Problem is, this works perfectly on DX7-OGL, but not in the DX9 driver. Doesnt look as a Grabpixmap fault, or even Loadimage(pixmap) fault, but seems to be some sort of DX state change thing. Run the program on DX9 and the white rectangle written "text" wont show. Uncomment SetBlend SOLIDBLEND, and it will show. If you change it to SetBlend ALPHABLEND, nothing will appear! Does anyone knows what could be wrong? This DX9 driver seems to be a blessing for Vista... ' Simple DX9 demo by Doug Stastny 'Framework brl.max2d SuperStrict Import brl.basic Import brl.pngloader ' import the DX9 Driver and set it as our default Import "Dx9Max2dDriver\Dx9Max2dGraphicsDriver.bmx" '------------------------------------------------ ' uncomment framework to use/test other drivers '------------------------------------------------ SetGraphicsDriver D3D9Max2DDriver() 'SetGraphicsDriver D3D7Max2DDriver() 'SetGraphicsDriver GLMax2DDriver() Global pmax: TPixmap Global render: TImage Global MyGraphics: TGraphics MyGraphics=Graphics(1024,768,0,0,GRAPHICS_BACKBUFFER) SetScale 1,1 SetColor 0,0,0 Cls SetBlend SOLIDBLEND SetColor 255,255,255 DrawRect 0,0,100,100 SetBlend ALPHABLEND SetColor 4,4,4 DrawText "text", 10, 10 pmax = GrabPixmap(0 , 0 , 100, 100) Delay 10 pmax = GrabPixmap(0 , 0 , 100, 100) Delay 10 render = LoadImage(pmax) pmax = Null SetColor 255,255,255 While Not KeyHit(KEY_ESCAPE) Cls 'SetBlend SOLIDBLEND DrawImage render,200,200 Flip 1 Wend CloseGraphics(MyGraphics) MyGraphics=Null End |
| ||
This really is about time to be an official project with proper support. |
| ||
Unlike DX7 DX9 requires special flags to make the presentation/back buffer readable (less optimal pipeline) so I suspect Blitz needs a new GRAPHICS_ flag for people who wish to use grabpixmap. |
| ||
hmmm... looks like it's a texture format problem... changing the texture format from D3DFMT_A8R8G8B8 to D3DFMT_X8R8G8B8 made it appear... but all alpha information was lost, so the text appears as a black block :( |
| ||
@Slotman Sorry for the difficulty. What graphics card are you using. I have wondered the level of support in the various drivers for the mechanism I used for Grabbing Pixmaps. I suspect I need to check a caps bit and fall back to the slower DC method which when creating the DX9 Device, which I wanted to avoid the performance hit of creating lockable back buffers. That being said, since most people just complain that my driver is not "Official", I am pretty much fed up with the blitz community at large and really have no desire to do any additional development or "proper" support. I mean its not like I have charged anybody anything. If anybody wants a clue on how to fix, take a look at the flags for creating the DirectX 9 object for creating a lockable DC and copy the method used by the DirectX7 Driver. Overall the performance hit probably wont be too bad and probably would have been a more conservative approach. |
| ||
@DStastny First of all, thanks for your answer! Please note that I do appreciate your driver, and I think it could be very useful! About people complaining, I think the complaints aren't directed at you (I may be wrong, since I haven't followed all the threads about it, just read the ones I could find), specially because you're not responsible at all for your driver not being official! As for your question this computer has a NVIDIA 9300M GS (dont know how good or bad it is... it's part of the HP touchsmart I bought). I'm on Vista64, if that helps something. It's indeed a driver issue... just tried the same program on XP with an ATI Mobility Radeon X1300, and it works prefectly. Thanks for the clue, I have already look at the dx7 method, will do my best to port it to your driver :) |
| ||
I rewrote the Grabpixmap method:Method GrabPixmap:TPixmap( x:Int,y:Int,width:Int,height:Int ) 'If Not IsValid() Return Local pixmap:TPixmap Local srcdc:Int Local destdc:Int Local sa:Byte Ptr, da:Byte Ptr Local surf:IDirect3DSurface9 Local renderSurf:IDirect3DSurface9 If UpdateRenderState() _D3DDevice9.EndScene() ' get our render target Local target:IDirect3DSurface9 If _D3DDevice9.GetRenderTarget(0,renderSurf)=D3D_Ok Then sa = Varptr srcdc If renderSurf.GetDC(sa)=D3D_Ok Then Print "got source DC" pixmap=TPixmap.Create( width,height,PF_BGR888 ) surf=surffrompixmap( pixmap ) da = Varptr destdc If surf.GetDC(da)=D3D_Ok Then 'Print "srcdc:" + srcdc + " destdc:" + destdc BitBlt destdc,0,0,width,height,srcdc,x,y,ROP_SRCCOPY End If surf.ReleaseDC Varptr da renderSurf.ReleaseDC Varptr sa surf.Release_() pixmap=TPixmap.Create( width,height,PF_BGR888 ) Else Print "Failed to get source DC" Print renderSurf.GetDC(sa) End If End If End If _D3DDevice9.BeginScene() Return pixmap End Method But I'm having one problem: every GetDC call is returning "INVALIDCALL", and the only way I got it to compile was using that "sa/da" hack on the code above. Doing something like "GetDC Varptr srcdc" as in the original, just gives me an error (as GetDC srcdc also does) Does anyone have any clue about it?? |
| ||
@Slotman, Thanks for your comments, interesting on Vista64... In Dx9Graphics.bmx the method _Create:TD3D9Graphics(... uncomment this line 'pp.Flags=D3DPRESENTFLAG_LOCKABLE_BACKBUFFER ' note this is bad bad bad That should enable usage of DC |
| ||
You should ignore the gobsh**es and carry on with this. There's a lot of people who would love to see it finished. It'd be a shame to let the resident pondlife get to you and spoil it for everyone. |
| ||
Seconded -- It really is very much appreciated. |
| ||
I wonder if Mark is even going to pick this up for the next release.. Was it in the SVN before it went down? |
| ||
Also here - much appreciated! |
| ||
Same here. I would happily donate some cash as a thank-you to DStastny for his time and effort on this. |
| ||
hmmm Problem is not on grabpixmap!! Just for a simple test, I tried: ' Simple DX9 demo by Doug Stastny 'Framework brl.max2d SuperStrict Import brl.basic Import brl.pngloader ' import the DX9 Driver and set it as our default Import "Dx9Max2dDriver\Dx9Max2dGraphicsDriver.bmx" '------------------------------------------------ ' uncomment framework to use/test other drivers '------------------------------------------------ SetGraphicsDriver D3D9Max2DDriver() 'SetGraphicsDriver D3D7Max2DDriver() 'SetGraphicsDriver GLMax2DDriver() Global pmax: TPixmap Global render: TImage Global MyGraphics: TGraphics MyGraphics=Graphics(1024,768,0,0,GRAPHICS_BACKBUFFER) SetScale 1,1 SetColor 0,0,0 Cls SetBlend SOLIDBLEND SetColor 255,255,255 DrawRect 0,0,100,100 SetBlend ALPHABLEND SetColor 4,4,4 DrawText "text", 10, 10 pmax = GrabPixmap(0 , 0 , 100, 100) Delay 10 pmax = GrabPixmap(0 , 0 , 100, 100) Delay 10 render = LoadImage(pmax) While Not KeyHit(KEY_ESCAPE) And Not AppTerminate() Cls 'SetBlend SOLIDBLEND If render Then DrawImage render,200,200 DrawPixmap pmax,200,400 Flip 1 Wend pmax=Null CloseGraphics(MyGraphics) MyGraphics=Null End With this above, Drawpíxmap works, so Grabpixmap is working, but still, DrawImage wont show anything at all, unless SETBLEND SOLIDBLEND is uncommented! (Setting it to other blend modes doesnt help, it wont be drawn) Now I'm completly lost... the problem lies on Image = LoadImage(pixmap) ??? |
| ||
Another small hint of what could be the problem... maybe something related to alpha channel/pixel format. When I went into "Function ConvertToPixmap:TPixmap(D3DDevice9 :IDirect3DDevice9, Source:IDirect3DSurface9)" on DX9Utils.bmx and changed: Local sp:TPixmap=TPixmap.CreateStatic(lockrect.pBits,sourceDesc.Width,sourceDesc.Height,lockrect.Pitch,PF_BGRA8888) and change it to PF_BGR888, both pixmap AND the image were rendered, but not right - it had some black lines every other row (like a vertical scanline). So maybe this could be some incompatibility with the pixel format used on the pixmap and the one used on the image? Update:Yes! It seems a problem converting D3DFMT_X8R8G8B8 to PF_BGRA8888 - the problem where images dont show at all is that their alpha channel is zeroed (I guess hehe) |
| ||
Yes, it is fixed now! Just open DX9Utils.bmx and replace the function with the one below: Function ConvertToPixmap:TPixmap(D3DDevice9 :IDirect3DDevice9, Source:IDirect3DSurface9) If Not source Return Null Local pixmap: TPixmap Local sourceDesc: D3DSURFACE_DESC= New D3DSURFACE_DESC Local pixmapSurface:IDirect3DSurface9 source.GetDesc(sourceDesc) pixmapSurface=CreateOffScreenPlainSurface(D3DDevice9, sourceDesc.Width,sourceDesc.Height) If Not pixmapSurface Return Null Select sourceDesc.Format Case D3DFMT_X8R8G8B8 Local srcLockrect:D3DLOCKED_RECT=New D3DLOCKED_RECT If Source.LockRect(srcLockrect,Null,0)=D3D_OK Local destLockRect:D3DLOCKED_RECT=New D3DLOCKED_RECT If pixmapSurface.LockRect(destLockrect,Null,0)=D3D_OK For Local y:Int=0 Until sourceDesc.Height Local srcBits:Int Ptr= Int Ptr(srcLockrect.pBits+srcLockrect.Pitch*y) Local destBits:Int Ptr=Int Ptr(destLockRect.pBits+destLockRect.Pitch*y) For Local x:Int= 0 Until sourceDesc.Width Local color:Int = srcBits[0] destBits[0]=color | $FF000000 srcBits:+1 destBits:+1 Next Next Local sp:TPixmap=TPixmap.CreateStatic(destLockrect.pBits,sourceDesc.Width,sourceDesc.Height,destLockrect.Pitch,PF_BGRA8888) pixmap=CopyPixmap(sp) pixmapSurface.UnlockRect() End If Source.UnlockRect() End If Case D3DFMT_A8R8G8B8 Local lockrect:D3DLOCKED_RECT=New D3DLOCKED_RECT If Source.LockRect(lockrect,Null,0)=D3D_OK Local sp:TPixmap=TPixmap.CreateStatic(lockrect.pBits,sourceDesc.Width,sourceDesc.Height,lockrect.Pitch,PF_BGRA8888) pixmap=CopyPixmap(sp) Source.UnlockRect() End If Case D3DFMT_R5G6B5 Local srcLockrect:D3DLOCKED_RECT=New D3DLOCKED_RECT If Source.LockRect(srcLockrect,Null,0)=D3D_OK Local destLockRect:D3DLOCKED_RECT=New D3DLOCKED_RECT If pixmapSurface.LockRect(destLockrect,Null,0)=D3D_OK For Local y:Int=0 Until sourceDesc.Height Local srcBits:Short Ptr= Short Ptr(srcLockrect.pBits+srcLockrect.Pitch*y) Local destBits:Int Ptr=Int Ptr(destLockRect.pBits+destLockRect.Pitch*y) For Local x:Int= 0 Until sourceDesc.Width Local color:Short = srcBits[0] destBits[0]=$FF000000 | ((((color Shr 11)& $1F) Shl 19)) | (((color Shr 5)& $3F) Shl 11) | ((color& $1F) Shl 3) srcBits:+1 destBits:+1 Next Next Local sp:TPixmap=TPixmap.CreateStatic(destLockrect.pBits,sourceDesc.Width,sourceDesc.Height,destLockrect.Pitch,PF_BGRA8888) pixmap=CopyPixmap(sp) pixmapSurface.UnlockRect() End If Source.UnlockRect() End If Case D3DFMT_A1R5G5B5 Local srcLockrect:D3DLOCKED_RECT=New D3DLOCKED_RECT If Source.LockRect(srcLockrect,Null,0)=D3D_OK Local destLockRect:D3DLOCKED_RECT=New D3DLOCKED_RECT If pixmapSurface.LockRect(destLockrect,Null,0)=D3D_OK For Local y:Int=0 Until sourceDesc.Height Local srcBits:Short Ptr= Short Ptr(srcLockrect.pBits+srcLockrect.Pitch*y) Local destBits:Int Ptr=Int Ptr(destLockRect.pBits+destLockRect.Pitch*y) For Local x:Int= 0 Until sourceDesc.Width Local color:Short = srcBits[0] destBits[0]= (((color Shr 15)&$01)Shl 31) | (((color Shr 10)&$1F)Shl 19) | (((color Shr 5)&$1F)Shl 11) | (color&$1F)Shl 3 srcBits:+1 destBits:+1 Next Next Local sp:TPixmap=TPixmap.CreateStatic(destLockrect.pBits,sourceDesc.Width,sourceDesc.Height,destLockrect.Pitch,PF_BGRA8888) pixmap=CopyPixmap(sp) pixmapSurface.UnlockRect() End If Source.UnlockRect() End If End Select pixmapSurface.Release_ 'pixmap= ConvertPixmap(pixmap,PF_BGR888) Return pixmap End Function There is still one grabpixmap not working on my game, but I will test it again to catch the problem :) Update:hmmm... the problem above still is the lack of alpha - the images shows, but if they were drawn with transparency, it's lost during the convertion... |
| ||
First to everyone I appreciate the support expressed in this thread. So back to troubleshooting Slotman's problem. Lets see where we are. Do to your testing and debugging you determined the Grabpixmap was working without having to fall back to the slow DC method used by the Dx7 driver? Changing the pixmap format in ConvertToPixmap would cause the strange results with scan lines due to improper bit conversion between the format. This is the correct behavior. You just messed up the scanline conversion :) Now interesting part is with GrabPixmap it is grabbing the Frame buffer so it really should not grab any alpha or at least default it to full bright so the format really should be D3DFMT_X8R8G8B8 as alpha channels are not supported as Backbuffer, it seems most drivers are ensuring the X8 bits are set to $FF I have run the sample on my Vista 32 laptop Nvidia Geforce GO7200 and with all drivers appears identical. So this is something specific to the Vista 64? Anyone else able to duplicate the problem on non 64bit machine. What version of Max are you using? All I have right now is access to the 1.30 release and I thought I saw something somewhere regarding a change to grabbing pixmaps and alpha channel, in the SVN version. I am wondering if something was introduced in the pixmap routines. Wont be able to verify that until the next rollup release of BMax. @Slotman, are you using the SVN version or standard 1.30 install? Based upon what I am seeing we need to see what a "pixel" look like coming back from the lock surface However there might be a simpler test :) In the: "Function ConvertToPixmap" Uncomment the line 'pixmap= ConvertPixmap(pixmap,PF_BGR888) at the very bottom of the routine. This dumps all the alpha channel all together. Dont worry when the texture gets loaded via loadimage it will put alpha channel back. I removed this as it seemed inefficent as grabbing a backbuffer should be in 32bit full bright ie. the Alpha is $FF Let me know if that works, if it does i will recode the method and copy the pixmap myself instead of using the copypixmap and ensure the Alpah Channel is set to $FF Thanks for the feedback and valuable debugging. Doug |
| ||
Yes, uncommenting that line indeed fixed the problem!! Now all pixmaps and images are rendered perfectly! |
| ||
Great! I knew I had that line there for a reason :). Just found in my testing it was wasted step. Guess not. I will add a more optimized conversion routine for that form so the Grab does not have to go through extra conversion step. But just sets the Alpah correctly. Strange that it only showed up on Vista 64. Got to love driver writers :). Doug |
| ||
...and now I just found another problem :( (nevermind the ttf problem, was something stupid I did here ;] ) A problem I found on XP (and even on Win98), is that I got a screen full of garbage (or just a black screen) if I let during initialization the depth buffer enabled (on TD3D9Graphics _Create, DX9Graphics.bmx) - but if I let it enabled, and restart the device (like changing from full-screen to window mode or vice-versa) everything goes back to normal...! I would recommend to leave the depth buffer disabled, or get some way to test it if the card/driver support it... without it the screen showed without a problem even on windows 98, on a geforce4 mx 4000 :) |
| ||
I am not sure I understand what your saying here? |
| ||
Heh, sorry for the confusing post, it was 6 a.m. and I was coding all night :) The thing is, I was getting a black window (nothing rendered, or just some garbage showing) in my game with the DX9 driver on Windows XP and Windows 98 - I then removed the depth buffer on the initialization parameters, and everything worked fine. Or in other words, on "DX9Graphics.bmx" in the "Method _Create:TD3D9Graphics(hwnd :Int, width:Int,height:Int,depth:Int,hertz:Int,flags:Int)" - I commented out the following lines: 'If _flags & GRAPHICS_DEPTHBUFFER '_PresentParams.EnableAutoDepthStencil=True ' true if we want z-buffer '_PresentParams.AutoDepthStencilFormat=D3DFMT_D16 'End If Ant it worked across several cards, in several OS. I even tested it today on a computer with an ancient TNT2 card (32mb) and it worked perfectly. I tested on: Win Vista, Geforce 9300 GS Win XP, Radeon 1300 / Geforce 6300 Win 98, Geforce 4 MX 4000 Win 98, TNT2 On those 5 computers, it worked flawlessly :) |
| ||
Can you post a link to the latest (most compatible) version? |
| ||
Get version 0.5 made by Doug Stastny. Then do the following: In the: "Function ConvertToPixmap" Uncomment the line at the bottom of the function: 'pixmap= ConvertPixmap(pixmap,PF_BGR888) Then do the last step I did: on "DX9Graphics.bmx" in the "Method _Create:TD3D9Graphics(hwnd :Int, width:Int,height:Int,depth:Int,hertz:Int,flags:Int)" - I commented out the following lines: 'If _flags & GRAPHICS_DEPTHBUFFER '_PresentParams.EnableAutoDepthStencil=True ' true if we want z-buffer '_PresentParams.AutoDepthStencilFormat=D3DFMT_D16 'End If And you will have what I did here :) I'm thinking in making a small demo (loading images, using fonts, doing grabpixamap, etc) and post a exe, so everyone can quickly test it, and see how stable and good it is :) But, of course, this should go in another topic ;) |
| ||
@Slotman Thats odd that the depth buffer would cause inconstant results on modern cards. I would think the ancient stuff might not be wonky but not the newer cards. Now here is the puzzling part GRAPHICS_DEPTHBUFFER is disabled by default so not quite sure why your getting into that behavior as the default parameter is GRAPHICS_BACKBUFFER only, so that code should not be executing unless when you set the Driver you are enabling the flag. I just ran some tests and that code does not execute unless I specifically turn on the GRAPHICS_DEPTHBUFFER. Max2D does not use the DEPTH_BUFFER. Also the last version I released was 0.6 which revised the rendering pipeline, and saw significant performance boost. 0.5 works fast if you have your render states well batched however that was bad assumption on my part. Doug |
| ||
so where can we get v0.6? |
| ||
Also the last version I released was 0.6 which revised the rendering pipeline, and saw significant performance boost. 0.5 works fast if you have your render states well batched however that was bad assumption on my part. Wow! Didn't know bout that ;) But 0.5 (at least on Vista and XP) did gave me a speed boost compared to DX7, in my game prototype (that doesn't have so much graphics for now) I got from 170 fps to 230 fps :) As for the DEPTHBUFFER, I'm not explicit calling it, so I don't know what's happening, just that when I disabled it, it worked for me :) |
| ||
GIZ 0.6.................please |
| ||
The version I use is dated feb of 07. It contains many dx9 files, not just one, i'm sure its not the latest. The link to version 0.6 here:http://www.blitzbasic.com/Community/posts.php?topic=80591#906807 is not working. Is there another valid link? |
| ||
Not that I know of, I missed that thread so don't have a copy of v0.6 but would host it if Doug likes. Btw, I added the 2 bug fixes to v0.5 (the zip is renamed v0.51) hosted here http://www.blitzmax.com/logs/userlog.php?user=8652&log=1737 as found in this thread. |
| ||
I have had hosting issues that I had never resolved. Gabriel at one time had hosted .6 on his site but that is no longer live. Thinking about it I have decided I will try this weekend time permitting to open a project on Google Code and place the project there. I know markcw had hosted an archive of 0.5 and appreciate that. As for the two fixes only the one regarding the Grabpixmap would I commit at this time as the other issue Slotman reported regarding the DEPTH_BUFFER cant be confirmed. As soon as we see next release of blitzmax I will be able to actually turn it into a formal mod format. Once hosted on Google code there will be a formal place to submit patches and improvements and bug reports. Give me a bit of time to work out getting a Google Code Project setup and my working code base cleaned up for a .7 release. Thanks Doug |
| ||
I just wrote a small function to TEST for the depth buffer, and enable it if the card supports it, and if it's compatible with the backbuffer and display formats. On DX9Graphics.bmx, on "Method _CreateDirect3DDevice9:TD3D9GraphicsDriver(g:TD3D9Graphics)", just before the line: If _Direct3D9.CreateDevice( 0,D3DDEVTYPE_HAL,_FocusHWND,D3DCREATE_PUREDEVICE|D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_FPU_PRESERVE,_FocusPresentParams,_Direct3DDevice9)<>D3D_OK put the following code: Local gmode: D3DDISPLAYMODE=New D3DDISPLAYMODE _dx9driver._Direct3D9.GetAdapterDisplayMode(D3DADAPTER_DEFAULT, gmode) ' test all types of depthbuffer DXLog "testing depth buffer..." Local fmtDepthSelected:Int = D3DFMT_UNKNOWN Local fmtDepths:Int[]=[D3DFMT_D32, D3DFMT_D24X8, D3DFMT_D24S8, D3DFMT_D24X4S4, D3DFMT_D16, D3DFMT_D15S1] Local nDepthFormats:Int = 6 DXLog "getting graphics mode..." If _dx9driver._Direct3D9.GetAdapterDisplayMode(D3DADAPTER_DEFAULT, gmode)=D3D_Ok Then DXLog "testing depth buffer..." For Local i:Int=0 To nDepthFormats-1 '// First, see If this format is supported If _dx9driver._Direct3D9.CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, gmode.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, fmtDepths[i])=D3D_Ok Then DXLog "testing depth buffer format and back buffer format " + i '// Graphics support this Z-buffer format '// Then, check that this format can be used with our backbuffer format '// Some cards may Not like e.g. a 32-bit depth buffer with a 16-bit backbuffer. If _dx9driver._Direct3D9.CheckDepthStencilMatch(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, gmode.Format, _FocusPresentParams.BackBufferFormat, fmtDepths[i])= D3D_Ok Then fmtDepthSelected = fmtDepths[i] i = nDepthFormats+1 Else '// Graphics card does Not support this Z-buffer '// format being used with this backbuffer format End If Else '// Graphics card does Not support this Z-buffer End If Next End If '// Did we find a suitable format? If (fmtDepthSelected <> D3DFMT_UNKNOWN) Then DXLog "---------------------------" DXLog "Depth buffer enabled" DXLog "---------------------------" _FocusPresentParams.EnableAutoDepthStencil=True ' true if we want z-buffer _FocusPresentParams.AutoDepthStencilFormat=fmtDepthSelected Else DXLog "---------------------------" DXLog "no depth buffer" DXLog "---------------------------" End If The little I tested here (just wrote it!) It is now only creating the depth buffer when it's available (successfully created on Geforce 9300 on Vista, not created on the Radeon X1300 on XP). |
| ||
@Slotman Thats good code. I was working on not using the auto select myself. The part I am trying to figure out is how your code is enabling a depth buffer. All cards even old ones support a depth buffer there is something with the EnableAutoDepthStencil thats messing up I suspect its not compatible with the selected back buffer or based upon the resolution there is not enough graphics memory. The part that I just cant figure out with your testing is how you had a depth buffer turned on. Doug |
| ||
The part that I just cant figure out with your testing is how you had a depth buffer turned on. the routine I posted above goes through every format possible for a depth buffer (from better to worst: D3DFMT_D32, D3DFMT_D24X8, D3DFMT_D24S8, D3DFMT_D24X4S4, D3DFMT_D16, D3DFMT_D15S1) and stores it on fmtDepthSelected (which defaults to an invalid format when I initialize it) After checking all formats (to see if they're supported and if it's compatible with the back buffer), if fmtDepthSelected is a valid format, then I just add those lines on _FocusPresentParams. _FocusPresentParams.EnableAutoDepthStencil=True ' true if we want z-buffer _FocusPresentParams.AutoDepthStencilFormat=fmtDepthSelected then in the line below (from your code), the D3DDevice is created, using _FocusPresentParams - this is what enables or not the depth buffer, depending on how "EnableAutoDepthStencil" and "AutoDepthStencilFormat" is set. If _Direct3D9.CreateDevice( 0,D3DDEVTYPE_HAL,_FocusHWND, ... ,_FocusPresentParams,_Direct3DDevice9)<>D3D_OK P.S> Edited the line above so the forum layout didnt break ;) |
| ||
@Slotman, I think you misunderstand my question as to why you had the depth buffer turned on. By default the setting is off, I did a debug trace through the driver and the lines of code you commented out are not executed. Now I dont question that your are seeing this behavior, I am just curious as to how the depth buffer flag got nothing. Doug |
| ||
Ah, just remembered I used the DEPTHBUFFER flag when creating Graphics in my game prototype. It works on all the other drivers (probably they test if the card supports it), so don't stress yourself on that ;) |
| ||
Ok, very cool, I have tweaked the change a bit on the fix to the with the GrabPixmap to only convert the pixmap if it is X8R8G8B8 as the routine is supposed to maintain Alpha if actually working with surfaces that support alpha. As for the Depth Buffer, I was reviewing over the code and its pretty weak for testing compatibility of the display formats. I made some pretty gross assumptions that all cards support particular depth or stencil formats as it was not really needed for the 2d work have not really expanded upon it. I have opened a project on Google Code and will be uploading version 0.7 which should have your issue fixed and improved performance. I am cleaning up the files and will be putting up a download. Once I see a new version of Max I will upload a proper project as a Mod. Thanks for the support Doug |