Here's a picture showing it.
First question is do I need to create the meshes differently when using OpenGL?
Maybe you can only create them through OpenGL's commands. I just assumed Purebasic's mesh commands would work with both DirectX and OpenGL.
It would be great if someone could help me with this.
Now for my second question. It looks like OpenGL is trying to light up the cube even though I haven't set any vertex normals.
You can kinda notice it in the picture above. Does OpenGL always try to add light to the entity even without vertex normals?
Here's the code.
I'm using PB 5.2 on Windows 7 x64.
Make sure your subsystem is set to opengl.
Code: Select all
ExamineDesktops()
If InitEngine3D()
Else
Debug "failed"
EndIf
InitSprite()
InitKeyboard()
DesktopW=DesktopWidth(0)
DesktopH=DesktopHeight(0)
If OpenWindow(0, 5, 5, DesktopW, DesktopH, "Test")
If OpenWindowedScreen(WindowID(0), 0, 0, DesktopW, DesktopH, 0, 0, 0)
Texture=CreateTexture(#PB_Any,8,8)
StartDrawing(TextureOutput(Texture))
Box(0,0,8,8,RGB(155,155,155))
StopDrawing()
Material=CreateMaterial(#PB_Any,TextureID(Texture))
Mesh=CreateMesh(#PB_Any)
MeshVertexPosition(2,2,2)
MeshVertexPosition(2,-2,2)
MeshVertexPosition(-2,-2,2)
MeshVertexPosition(-2,2,2)
MeshVertexPosition(2,2,-2)
MeshVertexPosition(2,-2,-2)
MeshVertexPosition(-2,-2,-2)
MeshVertexPosition(-2,2,-2)
MeshFace(0,2,1)
MeshFace(0,3,2)
MeshFace(4,5,6)
MeshFace(4,6,7)
MeshFace(0,1,4)
MeshFace(1,5,4)
MeshFace(2,3,6)
MeshFace(3,7,6)
MeshFace(0,4,3)
MeshFace(3,4,7)
MeshFace(1,2,5)
MeshFace(2,6,5)
FinishMesh(#True)
CreateEntity(#PB_Any,MeshID(Mesh),MaterialID(Material))
Camera=CreateCamera(#PB_Any,0,0,100,100)
MoveCamera(Camera,8,0,10,#PB_Absolute)
CameraLookAt(Camera,0,0,0)
CreateLight(#PB_Any,RGB(255,255,255),2,2,2)
EndIf
EndIf
Repeat
Event=WaitWindowEvent()
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Up)
MoveCamera(Camera, 0, 0, -0.4)
ElseIf KeyboardPushed(#PB_Key_Down)
MoveCamera(Camera, 0, 0, 0.4)
EndIf
If KeyboardPushed(#PB_Key_Left)
MoveCamera(Camera, -0.4, 0, 0)
CameraLookAt(Camera, 0, 0, 0)
ElseIf KeyboardPushed(#PB_Key_Right)
MoveCamera(Camera, 0.4, 0, 0)
CameraLookAt(Camera, 0, 0, 0)
EndIf
EndIf
RenderWorld()
FlipBuffers()
Until Event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)


