Sign in to follow this  

Initialize Direct3D to draw in a part of the window

This topic is 3113 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I am trying to write a very basic program which draws just a few colored triangles. I found a few good tutorials on this in my programming language (Turbo Delphi 2006). I have a big problem with initializing D3D though, as I want it to draw just in a small area of my window. I know that probably most of you use C++ but maybe you can point me to what i am doing wrong. Thanks for your help! Here is my Code: procedure D3DInit; var hr : HRESULT; d3dpp : TD3DPRESENTPARAMETERS; begin lpd3d:=nil; lpd3ddevice:=nil; red:=0; green:=0; blue:=0; lpd3d:=Direct3DCreate8(D3D_SDK_VERSION); if(lpd3d=nil) then FatalError(0,'error creating D3D'); // reset D3DPRESENT_PARAMETERS ZeroMemory(@d3dpp, SizeOf(d3dpp)); with d3dpp do begin SwapEffect:=D3DSWAPEFFECT_DISCARD; //this is where i try to force d3d to draw on the //panel (a delphi-class similar to MFC's CRect) //by passing the handle of the panel instead //to the one of the window (called form1 in delphi) hDeviceWindow:=Form1.panel1.handle; BackBufferCount:=1; Windowed := true; BackBufferWidth := 640; BackBufferHeight := 480; BackBufferFormat := D3DFind16BitMode; end; //this is where the initialization breaks //error says wrong parameters hr:=lpd3d.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Form1.Panel1.Handle,//here again the handle of my panel D3DCREATE_SOFTWARE_VERTEXPROCESSING, d3dpp, lpd3ddevice); if FAILED(hr) then FatalError(hr,'error creating the 3d-device'); end;

Share this post


Link to post
Share on other sites
Did everything work fine when you used the handle from the form, rather than the panel? and it was only after switching to the panel handle that things started to fail?

I would suggest playing around with this property:
D3DFind16BitMode

try 24 or 32 bits

Also, you should be getting a specific error back. While Failed() will just tell you that it was not successful, looking up the error will give you a more detailed description of the issue.

I'm also curious about your choice of the software vertex processing mode.

Share this post


Link to post
Share on other sites

This topic is 3113 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this