Jump to content

Render Texture on secondary window.


Recoil

Recommended Posts

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.

Link to comment
Share on other sites

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()

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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...