DX 10 Render Shrinking with form size

Oblivion165

Newcomer
Joined
Mar 28, 2010
http://img716.imageshack.us/img716/8881/blurrytext.jpg

Thanks to ThePentiumGuy I have this base rendering class down here but I cant seem to get the text or other sprites to come out clear in windowed mode.

Is there some simple viewport style that I can use?

Windows 7 Ultimate 64-bit
Visual Studio 2008
DirectX 10 SDK

Code:
        Public D3Ddev As Device = Nothing
        Public D3Dpp As PresentParameters = Nothing
        Public DP As DisplayMode = Nothing
        Public GameOver As Boolean
        Public Sub Start(ByVal TargetForm As Form, ByVal FullScreen As Boolean)
            Game.MainForm = TargetForm
            Game.Fullscreen = FullScreen
            If FullScreen = True Then
                DP.Width = 800
                DP.Height = 600
                DP.Format = Format.R5G6B5
            Else
                DP = Manager.Adapters.Default.CurrentDisplayMode
            End If
            D3Dpp = New PresentParameters
            D3Dpp.BackBufferFormat = DP.Format
            D3Dpp.BackBufferWidth = DP.Width
            D3Dpp.BackBufferHeight = DP.Height
            D3Dpp.SwapEffect = SwapEffect.Discard
            D3Dpp.PresentationInterval = PresentInterval.Immediate
            If FullScreen = True Then
                D3Dpp.Windowed = False
            Else
                D3Dpp.Windowed = True
            End If
            D3Ddev = New Device(Manager.Adapters.Default.Adapter, DeviceType.Hardware, TargetForm.Handle, CreateFlags.SoftwareVertexProcessing, D3Dpp)
            D3Ddev.Transform.View = Matrix.OrthoOffCenterLH(0, DP.Width, DP.Height, 0, 1, 10)
            D3Ddev.RenderState.Lighting = False
            Game.DisText = New clsText(D3Ddev)
        End Sub

        Public Sub RenderScene()
            Do While Not GameOver
                D3Ddev.BeginScene()
                D3Ddev.Clear(ClearFlags.Target, Color.FromArgb(33, 33, 33), 0, 0)

                '/////// Draw Space
                'D3Ddev.Transform.World = Matrix.Translation(0, 0, 0)
                'Alex.Render()

                Game.DisText.Drawtext("Apple", Color.White, 0, 0)

                'D3Ddev.Transform.World = Matrix.Translation(0, 0, 0)

                D3Ddev.EndScene()
                D3Ddev.Present()
                Game.CheckKeys()
                Application.DoEvents()
                Call FPS()
            Loop
            Terminate()
        End Sub

Code:
    Public Class clsText
        Public pDevice As Device
        Public TheFont As Font = Nothing
        Public Rect As New Rectangle(0, 0, 0, 0)
        Public S As Direct3D.Sprite
        Public Y, X As Integer

        Public Sub New(ByVal pDevice As Device, Optional ByVal FontName As String = "Courier New", Optional ByVal Size As Integer = 18)
            TheFont = New Font(pDevice, New System.Drawing.Font(FontName, Size))
            S = New Sprite(pDevice)
            Y = 0
        End Sub

        Protected Overrides Sub Finalize()
            S = Nothing
            TheFont = Nothing
            Rect = Nothing
        End Sub

        Public Sub Drawtext(ByVal text As String, ByVal cColor As System.Drawing.Color, ByVal X As Integer, ByVal Y As Integer)
            S.Begin(SpriteFlags.AlphaBlend Or SpriteFlags.SortTexture)
            TheFont.DrawText(S, text, X, Y, cColor)
            S.End()
        End Sub
    End Class
 

snarfblam

Ultimate Contributor
Joined
Jun 10, 2003
Location
USA
Hmmm... I know a lot more about XNA than MDX. Sorry if it seems like a silly question, but does the size of your back buffer match the client size of the output window?

It looks like it is scaling the output down with a nearest neighbor interpolation.
 
Top Bottom