Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2012
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.69 KB | None | 0 0
  1. Imports System.Windows.Forms
  2.  
  3. Public Class FrmMain
  4.  
  5.     Public GD As GraphicsDevice
  6.     Public GC As clsContent.GameContent
  7.     Public SB As SpriteBatch
  8.  
  9.     Public IsRunning As Boolean = True
  10.  
  11.     Private bg As Texture2D
  12.     Private debugfont As SpriteFont
  13.  
  14.     Private Sub FrmMain_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  15.         Me.Show()
  16.         Me.Focus()
  17.  
  18.         If InitGFX(pbScreen) = False Then
  19.             IsRunning = False
  20.             End
  21.         End If
  22.  
  23.         GLoop()
  24.     End Sub
  25.  
  26.     Private Function InitGFX(Screen As PictureBox) As Boolean
  27.         Dim bSuccess As Boolean = False
  28.  
  29.         Try
  30.             'CREAR UNA "PRESENTACION"
  31.             Dim PP As New PresentationParameters
  32.             PP.PresentationInterval = PresentInterval.Default
  33.             PP.DeviceWindowHandle = Screen.Handle
  34.             PP.IsFullScreen = False
  35.  
  36.             'CREAR Y CONFIGURAR EL DISPOSITIVO GRÁFICO (GD) Y EL ADAPTADOR GRÁFICO (GA)
  37.             Dim GA As GraphicsAdapter = GraphicsAdapter.Adapters.Item(0)
  38.             GD = New GraphicsDevice(GA, GraphicsProfile.Reach, PP)
  39.  
  40.             'ESTABLECER EL 'GAME CONTENT' para la carga de los recursos (gráficos, fuentes, shaders, modelos 3d, etc)
  41.             GC = New clsContent.GameContent(GD)
  42.             GC.Content.RootDirectory = "Content"
  43.  
  44.             'CREAR SPRITEBATCH
  45.             SB = New SpriteBatch(GD)
  46.  
  47.             'CARGAR LOS GRÁFICOS en el 'GAME CONTENT' para esta demo
  48.             LoadGFX()
  49.  
  50.             bSuccess = True
  51.  
  52.         Catch ex As Exception
  53.             bSuccess = False
  54.             MessageBox.Show("Graphics failed to initialize" & vbCrLf & vbCrLf & "Error: " & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  55.         End Try
  56.  
  57.         Return bSuccess
  58.     End Function
  59.  
  60.     Private Sub LoadGFX()
  61.         'Textura que actúa como 'fondo de pantalla'
  62.         bg = GC.Content.Load(Of Texture2D)("background")
  63.  
  64.         'fuente que se visualizará DENTRO de Dispositivo Gráfico (GD) en XNA
  65.         debugfont = GC.Content.Load(Of SpriteFont)("debug")
  66.  
  67.     End Sub
  68.  
  69.     Private Sub GLoop()
  70.         Do While IsRunning = True
  71.             Application.DoEvents()
  72.  
  73.             Draw()
  74.  
  75.         Loop
  76.     End Sub
  77.  
  78.     Private Sub Draw()
  79.         GD.Clear(Color.Black)
  80.  
  81.         SB.Begin()
  82.         SB.Draw(bg, Vector2.Zero, Color.White)
  83.         SB.DrawString(debugfont, "Hola Mnudo!!!", New Vector2(10, 4), Color.White)
  84.         SB.End()
  85.  
  86.         GD.Present()
  87.     End Sub
  88.  
  89.     Private Sub FrmMain_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  90.         IsRunning = False
  91.         End
  92.     End Sub
  93.  
  94. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement