home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 February / maximum-cd-2009-02.iso / DiscContents / SMC_1.6_win32.exe / src / video / renderer.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-07-01  |  5.0 KB  |  238 lines

  1. /***************************************************************************
  2.  * renderer.h  -  header for the corresponding cpp file
  3.  *
  4.  * Copyright (C) 2006 - 2008 Florian Richter
  5.  ***************************************************************************/
  6. /*
  7.    This program is free software; you can redistribute it and/or modify
  8.    it under the terms of the GNU General Public License as published by
  9.    the Free Software Foundation; either version 3 of the License, or
  10.    (at your option) any later version.
  11.    
  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  14. */
  15.  
  16. #ifndef SMC_RENDERER_H
  17. #define SMC_RENDERER_H
  18.  
  19. #include "../core/globals.h"
  20. #include "../video/video.h"
  21. #include "../core/math/rect.h"
  22.  
  23. /* *** *** *** *** *** *** *** Render Types *** *** *** *** *** *** *** *** *** *** */
  24.  
  25. enum RenderType
  26. {
  27.     REND_NOTHING = 0,
  28.     REND_RECT = 1,
  29.     REND_GRADIENT = 2,
  30.     REND_SURFACE = 3,
  31.     REND_TEXT = 4, // todo
  32.     REND_LINE = 5,
  33.     REND_CIRCLE = 6
  34. };
  35.  
  36. /* *** *** *** *** *** *** cRenderRequest *** *** *** *** *** *** *** *** *** *** *** */
  37.  
  38. class cRenderRequest
  39. {
  40. public:
  41.     cRenderRequest( void );
  42.     virtual ~cRenderRequest( void );
  43.  
  44.     // Draw the Render Request
  45.     virtual void Draw( void );
  46.  
  47.     // start Rendering
  48.     void Begin_Render( void );
  49.     // end Rendering
  50.     void End_Render( void );
  51.  
  52.     // add color combine
  53.     void Begin_Color_Combine( void );
  54.     // remove color combine
  55.     void End_Color_Combine( void );
  56.  
  57.     // render type
  58.     RenderType type;
  59.  
  60.     // globalscale
  61.     bool globalscale;
  62.     // if not set camera position is subtracted
  63.     bool no_camera;
  64.  
  65.     // Z position
  66.     float pos_z;
  67.     // blending
  68.     GLenum blend_sfactor;
  69.     GLenum blend_dfactor;
  70.     // shadow position
  71.     float shadow_pos;
  72.     // shadow color
  73.     Color shadow_color;
  74.  
  75.     // combine type
  76.     GLint combine_type;
  77.     // combine color
  78.     float combine_col[3];
  79.  
  80.     // times to render until deletion
  81.     int render_count;
  82. };
  83.  
  84. typedef vector<cRenderRequest *> RenderList;
  85.  
  86. /* *** *** *** *** *** *** cLineRequest *** *** *** *** *** *** *** *** *** *** *** */
  87.  
  88. class cLineRequest : public cRenderRequest
  89. {
  90. public:
  91.     cLineRequest( void );
  92.     virtual ~cLineRequest( void );
  93.  
  94.     // draw
  95.     virtual void Draw( void );
  96.  
  97.     // color
  98.     Color color;
  99.     // line
  100.     GL_line line;
  101.     // line width
  102.     float line_width;
  103. };
  104.  
  105. /* *** *** *** *** *** *** cRectRequest *** *** *** *** *** *** *** *** *** *** *** */
  106.  
  107. class cRectRequest : public cRenderRequest
  108. {
  109. public:
  110.     cRectRequest( void );
  111.     virtual ~cRectRequest( void );
  112.  
  113.     // draw
  114.     virtual void Draw( void );
  115.     // color
  116.     Color color;
  117.     // rect
  118.     GL_rect rect;
  119.     // rect is filled
  120.     bool filled;
  121. };
  122.  
  123. /* *** *** *** *** *** *** cGradientRequest *** *** *** *** *** *** *** *** *** *** *** */
  124.  
  125. class cGradientRequest : public cRenderRequest
  126. {
  127. public:
  128.     cGradientRequest( void );
  129.     virtual ~cGradientRequest( void );
  130.  
  131.     // draw
  132.     virtual void Draw( void );
  133.  
  134.     // rect
  135.     GL_rect rect;
  136.     // direction
  137.     ObjectDirection dir;
  138.     // colors
  139.     Color color_1;
  140.     Color color_2;
  141. };
  142.  
  143. /* *** *** *** *** *** *** cCircleRequest *** *** *** *** *** *** *** *** *** *** *** */
  144.  
  145. class cCircleRequest : public cRenderRequest
  146. {
  147. public:
  148.     cCircleRequest( void );
  149.     virtual ~cCircleRequest( void );
  150.  
  151.     // draw
  152.     virtual void Draw( void );
  153.     // color
  154.     Color color;
  155.     // position
  156.     GL_point pos;
  157.     // radius
  158.     float radius;
  159.     // if set circle is not filled
  160.     float line_width;
  161. };
  162.  
  163. /* *** *** *** *** *** *** cSurfaceRequest *** *** *** *** *** *** *** *** *** *** *** */
  164.  
  165. class cSurfaceRequest : public cRenderRequest
  166. {
  167. public:
  168.     cSurfaceRequest( void );
  169.     virtual ~cSurfaceRequest( void );
  170.  
  171.     // Draw
  172.     virtual void Draw( void );
  173.  
  174.     // texture id
  175.     GLuint texture_id;
  176.     // position
  177.     float pos_x, pos_y;
  178.     // rotation
  179.     float rotx, roty, rotz;
  180.     // size
  181.     float w, h;
  182.     // scale
  183.     float scale_x;
  184.     float scale_y;
  185.     float scale_z;
  186.  
  187.     // color
  188.     Color color;
  189.  
  190.     // delete texture after request finished
  191.     bool delete_texture;
  192. };
  193.  
  194. /* *** *** *** *** *** *** cRenderQueue *** *** *** *** *** *** *** *** *** *** *** */
  195.  
  196. class cRenderQueue
  197. {
  198. public:
  199.     cRenderQueue( unsigned int reserve_items );
  200.     ~cRenderQueue( void );
  201.  
  202.     /* Add a Render Request
  203.     */
  204.     void Add( cRenderRequest *obj );
  205.  
  206.     /* if clear is not set doesn't clear the data
  207.     */
  208.     void Render( bool clear = 1 );
  209.  
  210.     /* clear the render data
  211.      * if force is given all objects will be removed
  212.     */
  213.     void Clear( bool force = 1 );
  214.  
  215.     // renderdata array
  216.     RenderList renderdata;
  217.  
  218.     // Z position sort
  219.     struct zpos_sort
  220.     {
  221.         bool operator()( const cRenderRequest *a, const cRenderRequest *b ) const
  222.         {
  223.             return a->pos_z < b->pos_z;
  224.         }
  225.     };
  226. };
  227.  
  228. /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
  229.  
  230. // Renderer class
  231. extern cRenderQueue *pRenderer;
  232. // Renderer after GUI was drawn
  233. extern cRenderQueue *pRenderer_GUI;
  234.  
  235. /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
  236.  
  237. #endif
  238.