Identifier 'ObjectLst' not found

Übersicht BlitzMax, BlitzMax NG Beginners-Corner

Neue Antwort erstellen

Xaymar

ehemals "Cgamer"

Betreff: Identifier 'ObjectLst' not found

BeitragMi, März 18, 2009 22:10
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich versuche mich seit ein paar tagen in opengl und types und bin dabei zu einem mir unbekanntem fehler gekommen.(Siehe Titel)
Ich weiß nicht was an der Zeile falsch ist, aber ich denke ich muss die List vorher initialisieren
Code: [AUSKLAPPEN]
Strict

Global Width = 800
Global Height= 600
Global Depth = 32
Global Hertz = 0

GLGraphics Width, Height, Depth, Hertz
Init()

Local ObjPtr:Objects

ObjPtr:Objects = New Objects
ListAddLast(ObjectLst, ObjPtr) 'hier kommt der fehler

ObjPtr.AddQuad(- 1, 1, 1,  ..
             1, 1, 1,  ..
            - 1, - 1, 1,  ..
             1, - 1, 1)
ObjPtr.SetVertexColor(0, 0, 1.0, .0, .0)
ObjPtr.SetVertexColor(0, 1, .0, 1.0, .0)
ObjPtr.SetVertexColor(0, 2, .0, .0, 1.0)
ObjPtr.SetVertexColor(0, 3, 1.0, 1.0, 1.0)

While Not KeyHit(KEY_ESCAPE)
   
   Draw()
   Flip
Wend
glFlush()
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
End


'Object Drawing
   Global ObjectLst:TList
   Global CamX:Float, CamY:Float, CamZ:Float
   Global CamPitch:Float, CamYaw:Float, CamRoll:Float
   Type Objects
      Field RotX:Float, RotY:Float, RotZ:Float, Amount:Float
      Field TraX:Float, TraY:Float, TraZ:Float
      Field GLVertex:Float[32, 4, 3], VertexCount
      Field GLColor:Float[32, 4, 3]
      
      Method AddQuad(X1:Float, Y1:Float, Z1:Float, X2:Float, Y2:Float, Z2:Float, X3:Float, Y3:Float, Z3:Float, X4:Float, Y4:Float, Z4:Float)
         GLVertex[VertexCount, 0, 0] = X1
         GLVertex[VertexCount, 0, 1] = Y1
         GLVertex[VertexCount, 0, 2] = Z1
         GLVertex[VertexCount, 1, 0] = X2
         GLVertex[VertexCount, 1, 1] = Y2
         GLVertex[VertexCount, 1, 2] = Z2
         GLVertex[VertexCount, 2, 0] = X3
         GLVertex[VertexCount, 2, 1] = Y3
         GLVertex[VertexCount, 2, 2] = Z3
         GLVertex[VertexCount, 3, 0] = X4
         GLVertex[VertexCount, 3, 1] = Y4
         GLVertex[VertexCount, 3, 2] = Z4
         VertexCount:+1
      EndMethod
      
      Method SetVertexColor(QuadNr:Int, VertexNr:Int, R:Float, G:Float, B:Float)
         GLColor[QuadNr, VertexNr, 0] = R
         GLColor[QuadNr, VertexNr, 1] = G
         GLColor[QuadNr, VertexNr, 2] = B
      End Method
      
      Method RotateObject(X:Float, Y:Float, Z:Float, Amount:Float)
         RotX = X
         RotY = Y
         RotZ = Z
         Amount = Amount
      EndMethod
      
      Method GetPitch()
         Return RotX * Amount
      End Method
      
      Method GetYaw()
         Return RotY * Amount
      EndMethod
      
      Method GetRoll()
         Return RotZ * Amount
      EndMethod
      
      Method MoveObject(X:Float, Y:Float, Z:Float)
         TraX = X
         TraY = Y
         TraZ = Z
      EndMethod
      
      Method GetX()
         Return TraX
      EndMethod
      
      Method GetY()
         Return TraY
      End Method
      
      Method GetZ()
         Return TraZ
      End Method
   EndType
   
   'Types End
   
   'Functions Start
   Function Init()
      glViewport(0, 0, Width, Height)
      glMatrixMode(GL_PROJECTION)
      glLoadIdentity()
         glEnable(GL_TEXTURE_2D)
         glShadeModel(GL_SMOOTH)
         gluPerspective(45.0, Width/Height, 0.1, 10000.0)
         glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST)
         glEnable(GL_BLEND)
         glEnable(GL_DEPTH_TEST)
         glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
         glMatrixMode(GL_MODELVIEW)
      glLoadIdentity()
      If TList(ObjectLst)
         Local ObjectPtr:Objects
         For ObjectPtr = EachIn ObjectLst
            Release ObjectPtr
         Next
         ClearList(ObjectLst)
      Else
         ObjectLst = CreateList()
      End If
   End Function
   
   Function Draw()
      glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
      glRotatef(CamPitch-90, 1.0, 0.0, 0.0)
      glRotatef(CamYaw, 0.0, 1.0, 0.0)
      glRotatef(CamRoll, 0.0, 0.0, 1.0)
      For ObjectPtr = EachIn ObjectLst
         glLoadIdentity()
         glRotatef(ObjectPtr.Amount, ObjectPtr.RotX, ObjectPtr.RotY, ObjectPtr.RotZ)
         glTranslatef(ObjectPtr.TraX + CamX, ObjectPtr.TraY + CamY, ObjectPtr.TraZ + CamZ)
         glBegin(GL_QUADS)
            For Local A = 0 To ObjectPtr.VertexCount
               For Local B = 0 To 3
                  glColor3f(ObjectPtr.GLColor[A, B, 0], ObjectPtr.GLColor[A, B, 1], ObjectPtr.GLColor[A, B, 2])
                  glVertex3f(ObjectPtr.GLVertex[A, B, 0], ObjectPtr.GLVertex[A, B, 1], ObjectPtr.GLVertex[A, B, 2])
               Next
            Next
         glEnd()
      Next
   EndFunction


erbitte etwas hilfe
Warbseite

ChaosCoder

BeitragMi, März 18, 2009 22:22
Antworten mit Zitat
Benutzer-Profile anzeigen
Identifer not found heißt, dass er die Variable, auf die du da zugreifen willst, nicht kennt, in dem Fall ObjectLst. Ist auch kein Wunder, wenn du erst ein paar Zeilen darunter
Code: [AUSKLAPPEN]
'Object Drawing
Global ObjectLst:TList
schreibst. Definier die Liste vorher und erzeuge auch ein Instanz einer List mit Code: [AUSKLAPPEN]
Global ObjectLst:TList=CreateList()

und schon sollte es funzen Wink viel spaß!

Edit:
Ahh hab grad gesehen, letzteres machst du in der Init Funktion, damit fällt das weg. Einfach vor dem Benutzen der Variable ObjectLst diese auch definieren, statt erst später.
Projekte: Geolaria | aNemy
Webseite: chaosspace.de

Neue Antwort erstellen


Übersicht BlitzMax, BlitzMax NG Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group