Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Windows.Forms
- Public Class FrmMain
- Public GD As GraphicsDevice
- Public GC As clsContent.GameContent
- Public SB As SpriteBatch
- Public IsRunning As Boolean = True
- Private bg As Texture2D
- Private debugfont As SpriteFont
- Private Sub FrmMain_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
- Me.Show()
- Me.Focus()
- If InitGFX(pbScreen) = False Then
- IsRunning = False
- End
- End If
- GLoop()
- End Sub
- Private Function InitGFX(Screen As PictureBox) As Boolean
- Dim bSuccess As Boolean = False
- Try
- 'CREAR UNA "PRESENTACION"
- Dim PP As New PresentationParameters
- PP.PresentationInterval = PresentInterval.Default
- PP.DeviceWindowHandle = Screen.Handle
- PP.IsFullScreen = False
- 'CREAR Y CONFIGURAR EL DISPOSITIVO GRÁFICO (GD) Y EL ADAPTADOR GRÁFICO (GA)
- Dim GA As GraphicsAdapter = GraphicsAdapter.Adapters.Item(0)
- GD = New GraphicsDevice(GA, GraphicsProfile.Reach, PP)
- 'ESTABLECER EL 'GAME CONTENT' para la carga de los recursos (gráficos, fuentes, shaders, modelos 3d, etc)
- GC = New clsContent.GameContent(GD)
- GC.Content.RootDirectory = "Content"
- 'CREAR SPRITEBATCH
- SB = New SpriteBatch(GD)
- 'CARGAR LOS GRÁFICOS en el 'GAME CONTENT' para esta demo
- LoadGFX()
- bSuccess = True
- Catch ex As Exception
- bSuccess = False
- MessageBox.Show("Graphics failed to initialize" & vbCrLf & vbCrLf & "Error: " & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
- End Try
- Return bSuccess
- End Function
- Private Sub LoadGFX()
- 'Textura que actúa como 'fondo de pantalla'
- bg = GC.Content.Load(Of Texture2D)("background")
- 'fuente que se visualizará DENTRO de Dispositivo Gráfico (GD) en XNA
- debugfont = GC.Content.Load(Of SpriteFont)("debug")
- End Sub
- Private Sub GLoop()
- Do While IsRunning = True
- Application.DoEvents()
- Draw()
- Loop
- End Sub
- Private Sub Draw()
- GD.Clear(Color.Black)
- SB.Begin()
- SB.Draw(bg, Vector2.Zero, Color.White)
- SB.DrawString(debugfont, "Hola Mnudo!!!", New Vector2(10, 4), Color.White)
- SB.End()
- GD.Present()
- End Sub
- Private Sub FrmMain_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
- IsRunning = False
- End
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement