You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.4 KiB

  1. -------------------------------------------------------------------------------------------
  2. --
  3. -- raylib [core] example - Initialize 3d mode
  4. --
  5. -- This example has been created using raylib 1.6 (www.raylib.com)
  6. -- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  7. --
  8. -- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
  9. --
  10. -------------------------------------------------------------------------------------------
  11. -- Initialization
  12. -------------------------------------------------------------------------------------------
  13. local screenWidth = 800
  14. local screenHeight = 450
  15. InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d mode")
  16. -- Define the camera to look into our 3d world
  17. local camera = {}
  18. camera.position = Vector3(0.0, 10.0, 10.0) -- Camera position
  19. camera.target = Vector3(0.0, 0.0, 0.0) -- Camera looking at point
  20. camera.up = Vector3(0.0, 1.0, 0.0) -- Camera up vector (rotation towards target)
  21. camera.fovy = 45.0 -- Camera field-of-view Y
  22. local cubePosition = Vector3(0.0, 0.0, 0.0)
  23. SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
  24. -------------------------------------------------------------------------------------------
  25. -- Main game loop
  26. while not WindowShouldClose() do -- Detect window close button or ESC key
  27. -- Update
  28. ---------------------------------------------------------------------------------------
  29. -- TODO: Update your variables here
  30. ---------------------------------------------------------------------------------------
  31. -- Draw
  32. ---------------------------------------------------------------------------------------
  33. BeginDrawing()
  34. ClearBackground(RAYWHITE)
  35. Begin3dMode(camera) -- ERROR: Lua Error: attempt to index a number value (?)
  36. DrawCube(cubePosition, 2.0, 2.0, 2.0, RED)
  37. DrawCubeWires(cubePosition, 2.0, 2.0, 2.0, MAROON)
  38. DrawGrid(10, 1.0)
  39. End3dMode()
  40. DrawText("Welcome to the third dimension!", 10, 40, 20, DARKGRAY)
  41. DrawFPS(10, 10)
  42. EndDrawing()
  43. ---------------------------------------------------------------------------------------
  44. end
  45. -- De-Initialization
  46. -------------------------------------------------------------------------------------------
  47. CloseWindow() -- Close window and OpenGL context
  48. -------------------------------------------------------------------------------------------