Jump to content
  • Advertisement
Sign in to follow this  
xyuri

Make windowed?

This topic is 5410 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

gday, I'm new to DirectX (Well, game developement all together really) and have been working through a tutorial to healp learn the ropes. I have managed to make DX run in fullscreen btu thats not how I want it, I'm using the following code snippet: FDraw.SetCooperativeLevel(Me, Microsoft.DirectX.DirectDraw.CooperativeLevelFlags.FullscreenExclusive) FDraw.SetDisplayMode(WID, HGT, 16, 0, False) How can I make it just run in a window instead of full screen? Maybe even in a certain part of a window?

Share this post


Link to post
Share on other sites
Advertisement
Use the windowed flag. The main thing about running in a window is you cannot change resolution etc. but have to use what the user has it set to. Not sure in managed where all the flags are. To render in just part of a window you would need to use SetViewport.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Awsome, thanks, I'll give it a shot when I get home and let you know how it goes. :)

Share this post


Link to post
Share on other sites
Didnt work for me. I have copied the "windowed" example that comes with the DX9 SDK but I cannot make the back surface plain (without an image one it). I'm hopeless at this.

Thanks for your help dude :)

Share this post


Link to post
Share on other sites
Here is the code i'm using to get it(Direct3D, DDraw should be similar) in windowed mode:

PresentParameters pParams = new PresentParameters();

pParams.Windowed=true;
pParams.SwapEffect=SwapEffect.Discard

device = new Device(0,DeviceType.Hardware,
this,CreateFlags.HardwareVertexProcessing,pParams);

device.DeviceReset+= new EventHandler(this.OnDeviceReset);
this.OnDeviceReset(device,null);

I'm trying to run it in a portion of a window too, however when I set the viewport, Direct3D updates the viewport I specifiy, but the rest of the screen is garbage. Any ideas? Here is my overrided OnPaint():

protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
Viewport vp = new Viewport();

vp = device.Viewport;
vp.Width/=2;
vp.Height/=2;
device.Viewport=vp;

device.Clear(ClearFlags.Target,Color.Firebrick,1.0f,0);
device.BeginScene();
device.EndScene();
device.Present();
base.OnPaint(e);
}


Share this post


Link to post
Share on other sites
Well, i think i answered my own question.

By specifying the viewport rectangle in Present() like this:

device.Present(rect,false);

And adding this to the OnDeviceReset():

Viewport vp;
vp = device.Viewport;
vp.Width=this.Width/2;
vp.Height=this.Height/2;
vp.X = 0;
vp.Y = 0;
device.Viewport=vp;

Windows paints the form, and I have a viewport for Direct3D. xyuri...if you want my code let me know. I'm sure its not the best way to do it, but it works :)

Share this post


Link to post
Share on other sites
No thanks :)

I'm just playing around with DX in my free time, if I get too stuck on it I'll definatelt let you know.

Thanks a lot :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!