texture trouble :/

BlitzMax Forums/BlitzMax OpenGL Programming/texture trouble :/

My texture renders as all black(or violet with GL_NEAREST instead of GL_LINEAR modes), Im pretty certain that the U,V coordinates are right. On fullscreen it crashes with Flushmem(), without it its the same problems as in windowed mode.

Texture type:
Type Texture
	Field GLID

	Function Create:Texture(Filename$)
		Local Txt:Texture = New Texture
		
		Local Pixmap:TPixmap = LoadPixmap(Filename$)
		If Not Pixmap Then
			Print "Could not load texture!"
			Return Null
		EndIf
		
		Txt.GLID = bglTexFromPixmap(Pixmap)
		If Not Txt.GLID Then
			Print "Could not apply texture to opengl!"
			Return Null
		EndIf
		
		
		glBindTexture GL_TEXTURE_2D,Txt.GLID
		
		glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT
		glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT		
	
		glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST
		glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST
		


		Pixmap = Null
		FlushMem
		
		Return Txt
	End Function
	
End type


Render function (parts from it)
				'Texture
				If Ent.Txt <> Null Then
					glBindTexture(GL_TEXTURE_2D,Ent.Txt.GLID)
					glEnable(GL_TEXTURE_2D)
				end if

				'Tri1
				If Ent.Alpha# <> 1.0 Then
					glColor4f(Pol.P[0].R/255.0,Pol.P[0].G/255.0,Pol.P[0].B/255.0,Ent.Alpha#)
				Else
					glColor3f(Pol.P[0].R/255.0,Pol.P[0].G/255.0,Pol.P[0].B/255.0)
				EndIf
				glTexCoord2f(Pol.P[0].U#,Pol.P[0].V#)
				glVertex3f(Pol.P[0].X#,Pol.P[0].Y#,Pol.P[0].Z#)


This is creating 2 triangle entity with my own lib
'Create entity
Local Cube:Entity = Entity.Create()
'Add(x,y,z,u,v)
Cube.Add(-1,1,-1,0,0)
Cube.Add(-1,-1,-1,0,1)
Cube.Add(1,-1,-1,1,1)

Cube.Add(1,-1,-1,0,0)
Cube.Add(1,1,-1,1,0)
Cube.Add(-1,1,-1,1,1)