Engine.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /***************************************************************************
  2. Engine.h - description
  3. -------------------
  4. begin : Wed Jan 26 2000
  5. copyright : (C) 2000 by Henrik Enqvist
  6. email : henqvist@excite.com
  7. ***************************************************************************/
  8. #ifndef ENGINE_H
  9. #define ENGINE_H
  10. #ifndef PRIVATE_H
  11. #error Must include Private.h before Engine.h
  12. #endif
  13. #include "TextureUtil.h"
  14. #include "Group.h"
  15. class Light;
  16. class Camera;
  17. /** The engine in the system.
  18. * @see Group
  19. * @see Shape3D
  20. * @see Light
  21. * @see Sound */
  22. class Engine : public Group {
  23. public:
  24. /** Engine(argc, argv). All arguments belonging to the engine are removed from the vector. */
  25. Engine(int & argc, char** argv);
  26. ~Engine();
  27. /** Shutdown the engine */
  28. void stopEngine();
  29. void clearScreen();
  30. /** Deallocate all objects in engine. */
  31. void clear();
  32. /** Draws a background to the screen. Do not use inside render loop, it
  33. might put OpenGL in a weird state. */
  34. void drawSplash(EmTexture * tex);
  35. /** Aligns vertices, calculates light, clears the screen and draws the polygons to
  36. * the GL buffer. */
  37. void render();
  38. /** Swaps the SDL buffers. Extern GLs must use something else. */
  39. void swap();
  40. /** Moves objects, detects collision, etc. Does NOT align vertices, caclulate light or
  41. * draw any polygons. Call the render() function for those things that. */
  42. void tick();
  43. void setEngineCamera(Group*);
  44. /** Sets diffuse and ambient light. The light source is straight above. */
  45. void setLightning(float diffuse, float ambient);
  46. void addLight(Light*);
  47. /** Use this function to limit the main loop to a desired frame rate.
  48. ** Returns false if the thread is behind schedule else true.
  49. ** Available FSP 100, 50, 40, 33, 25, 20 */
  50. bool nextTickFPS(int fps);
  51. void resetTick();
  52. // bool limitFPS(int fps);
  53. void delay(int ms);
  54. void setClearColor(float r, float g, float b, float a);
  55. static float getFps() { return m_fFps; };
  56. /** A short cut to the last created engine, NULL if non created. */
  57. inline static Engine * getCurrentEngine() { return p_Engine; };
  58. #if EM_THREADS
  59. /** When using threaded ticks you must use this function instead of render(). */
  60. void renderThreadSafe();
  61. void startTickThread();
  62. void pauseTickThread();
  63. void resumeTickThread();
  64. void endTickThread();
  65. #endif
  66. private:
  67. static float m_fFps;
  68. static Engine * p_Engine;
  69. };
  70. #endif // ENGINE_H