Jump to content
  • Advertisement
Sign in to follow this  
Stukey

Something Wrong With This? Directx 9.0 Visual Basic

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

    Public Sub Render(ByRef pct As Windows.Forms.PictureBox)

        D3DDev.Clear(ClearFlags.Target, Color.Black, 1.0F, 0)

        D3DDev.BeginScene()
        sprOut.Begin(SpriteFlags.AlphaBlend)

        If pct.Name = "pctTiles" Then
            sprOut.Draw2D(Textures.Item(Tileset), _
            New Rectangle(0, 0, 100, 100), _
            New Rectangle(0, 0, 100, 100), _
            New Point(0, 0), Color.Magenta)
        End If

        sprOut.End()

        D3DDev.EndScene()
        D3DDev.Present(pct)

    End Sub


This works, I'm just wondering if for some reason changing the target of the device everytime I render is a bad idea. The render sub takes a picturebox as an argument and uses it to render to. I mean is the command D3DDev.Present(Pct) a bad idea because when I asked how to render multiple targets people said to use swapchains or viewports but this seems to work.

Share this post


Link to post
Share on other sites
Advertisement
The backbuffer doesn't change it's size automatically, so if it's and the presentation target's dimensions vary, the image gets filtered on the way to the screen. This may be a performance concern, but if it works for your purposes, by all means use it!

Note that any fixed-sized geometry gets scaled also, if the scaling in presentation is performed. While this doesn't affect normal polygonal graphics much, text, for example, can become unreadable when scaled too small.

Share this post


Link to post
Share on other sites
Thanks, yes this is an issue and if you could give me some direction as how to actually use swapchains in managed code it would be helpful because all I can find is help in c++.

Share this post


Link to post
Share on other sites
See the "SwapChain class" topic from the SDK documentation for more info on how to create them.

In each swap chain's presentation parameters, you set the DeviceWindow member to the pointer to the window/control that you want to use as the presentation window.

To render to a particular swapchain, you must set it's backbuffer as the current rendertarget of the device. After rendering, you need to call Present for each individual swapchain, which causes the buffers to be transferred to their bound windows.

I recommend cross-referencing the Managed and C++ SDK docs even if you only use Managed DX, because the C++ docs often have much deeper background information for any topic. Microsoft is working on deepening the Managed docs in the future, though.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!