Jump to content

Recommended Posts

Posted

Here is what I have:  A secondary window that displays the same map as the primary window on an update boolean in the Render_Graphics sub.  This works.

However, if I have to move the window slightly off screen, or change its size, it will erase some portions.  I have created a render texture (_rt) to draw stuff to instead of the player window.

In the Render_Graphics sub:

_playerWindow.SetView(New View(New FloatRect(0, 0, MaxMapx * 32, MaxMapy * 32)))
_playerWindow.DispatchEvents()
_playerWindow.Clear(Color.Black)

_rt.Clear(Color.Black)

'''Draw the same tiles on _rt instead of _playerwindow

_rt.Display()
_playerWindow.Draw(_rt)
_playerWindow.Display()

I know I have asked about this in the chatbox, but everytime I look back, the messages are gone, and I seem to be forgetting what I was advised to do so this will work.

Posted

Everytime the player window changes you will want to redraw the rendertexture to it. The form will redraw and then you will want to redraw on top of that.

Posted

Yes, but even with it drawing everytime it is not working.  Here is how I planned to check if it needed to be redrawn or not:

_playerWindow.SetView(New View(New FloatRect(0, 0, MaxMapx * 32, MaxMapy * 32)))
_playerWindow.DispatchEvents()
_playerWindow.Clear(Color.Black)

        If UpdateSecondary = True Then

            _rt.Clear(Color.Black)
            ' this same boolean would catch and -rt would be redrawn to...

        Else

            ' dont bother clearing it, just redraw the same image.

        End If

_rt.Display()
_playerWindow.Draw(_rt)
_playerWindow.Display()

Posted

Don't call _rt.Display() unless you are updating it in some way. Throw that into your if statement.

Otherwise I am not sure what is going wrong. Everything looks straightforward and simple.

Posted

Codez -_-

Public Sub Render_Graphics()

        Dim x As Long
        Dim y As Long

        If UpdateSecondary = True Then
            _rt = New RenderTexture(PlayerViewer.playerscreen.Width, PlayerViewer.playerscreen.Height)
        End If
        _playerWindow.SetView(New View(New FloatRect(0, 0, MaxMapx * 32, MaxMapy * 32)))
        _dmWindow.SetView(New View(New FloatRect(0, 0, MaxMapx * 32, MaxMapy * 32)))

        UpdateCamera()
        DoEvents() 

        _playerWindow.DispatchEvents()
        _playerWindow.Clear(Color.Black)

        _dmWindow.DispatchEvents()
        _dmWindow.Clear(Color.Black)

        ' ...draw the stuffs...
        
        If Not UpdateSecondary = True Then
            
            If _rt Is Nothing Then
                _rt = New RenderTexture(PlayerViewer.playerscreen.Width, PlayerViewer.playerscreen.Height)
                _rt.Clear(Color.Black)
            End If

        End If

        _rt.Display()

        Dim tmpSprite As Sprite = New Sprite(_rt.Texture)
        tmpSprite.TextureRect = New IntRect(PlayerViewer.playerscreen.Location.X, PlayerViewer.playerscreen.Location.Y, PlayerViewer.playerscreen.Width, PlayerViewer.playerscreen.Height)
        
        _playerWindow.Draw(tmpSprite) '_rt)
        _playerWindow.Display()
        _dmWindow.Display()

        UpdateSecondary = False

    End Sub

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
×
×
  • Create New...