core_3d_camera_mode.bmx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. SuperStrict
  2. Framework Ray.Lib
  3. ' Initialization
  4. '--------------------------------------------------------------------------------------
  5. Const screenWidth:Int = 800
  6. Const screenHeight:Int = 450
  7. InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera mode")
  8. ' Define the camera to look into our 3d world
  9. Local camera:RCamera = New RCamera
  10. camera.position = New RVector3(0.0, 10.0, 10.0) ' Camera position
  11. camera.target = New RVector3(0.0, 0.0, 0.0) ' Camera looking at point
  12. camera.up = New RVector3(0.0, 1.0, 0.0) ' Camera up vector (rotation towards target)
  13. camera.fovy = 45.0 ' Camera field-of-view Y
  14. camera.projection = CAMERA_PERSPECTIVE ' Camera mode type
  15. Local cubePosition:RVector3 = New RVector3(0.0, 0.0, 0.0)
  16. SetTargetFPS(60) ' Set our game to run at 60 frames-per-second
  17. '--------------------------------------------------------------------------------------
  18. ' Main game loop
  19. While Not WindowShouldClose() ' Detect window close button or ESC key
  20. ' Update
  21. '----------------------------------------------------------------------------------
  22. ' TODO: Update your variables here
  23. '----------------------------------------------------------------------------------
  24. ' Draw
  25. '----------------------------------------------------------------------------------
  26. BeginDrawing()
  27. ClearBackground(RAYWHITE)
  28. BeginMode3D(camera)
  29. DrawCube(cubePosition, 2.0, 2.0, 2.0, RED)
  30. DrawCubeWires(cubePosition, 2.0, 2.0, 2.0, MAROON)
  31. DrawGrid(10, 1.0)
  32. EndMode3D()
  33. DrawText("Welcome to the third dimension!", 10, 40, 20, DARKGRAY)
  34. DrawFPS(10, 10)
  35. EndDrawing()
  36. '----------------------------------------------------------------------------------
  37. Wend
  38. ' De-Initialization
  39. '--------------------------------------------------------------------------------------
  40. CloseWindow() ' Close window and OpenGL context
  41. '--------------------------------------------------------------------------------------