Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TileRender.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2010, The Barbarian Group
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
6  the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this list of conditions and
9  the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
11  the following disclaimer in the documentation and/or other materials provided with the distribution.
12 
13  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
14  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
15  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
16  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
17  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
19  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
20  POSSIBILITY OF SUCH DAMAGE.
21 */
22 
23 #pragma once
24 
25 #include "cinder/Cinder.h"
26 #include "cinder/gl/gl.h"
27 #include "cinder/Exception.h"
28 #include "cinder/Surface.h"
29 #include "cinder/Camera.h"
30 
31 namespace cinder { namespace gl {
32 
33 class TileRender {
34  public:
35  TileRender( int32_t imageWidth, int32_t imageHeight, int32_t tileWidth = 512, int32_t tileHeight = 512 );
36 
37  bool nextTile();
38 
39  int32_t getImageWidth() const { return mImageWidth; }
40  int32_t getImageHeight() const { return mImageHeight; }
41  float getImageAspectRatio() const { return mImageWidth / (float)mImageHeight; }
42  Area getCurrentTileArea() const { return mCurrentArea; }
43  Surface getSurface() const { return mSurface; }
44 
45  void setMatricesWindow( int32_t windowWidth, int32_t windowHeight );
46  void setMatricesWindow( const Vec2i &windowSize ) { setMatricesWindow( windowSize.x, windowSize.y ); }
47  void setMatricesWindowPersp( int screenWidth, int screenHeight, float fovDegrees = 60.0f, float nearPlane = 1.0f, float farPlane = 1000.0f );
48  void setMatricesWindowPersp( const Vec2i &windowSize, float fovDegrees = 60.0f, float nearPlane = 1.0f, float farPlane = 1000.0f )
49  { setMatricesWindowPersp( windowSize.x, windowSize.y, fovDegrees, nearPlane, farPlane ); }
50  void setMatrices( const Camera &camera );
51 
52  void frustum( float left, float right, float bottom, float top, float nearPlane, float farPlane );
53  void ortho( float left, float right, float bottom, float top, float nearPlane, float farPlane );
54 
55  protected:
56  void updateFrustum();
57 
61 
62  int32_t mCurrentTile;
67 
70 };
71 
72 } } // namespace cinder::gl
float mCurrentFrustumFar
Definition: TileRender.h:65
GLdouble GLdouble GLdouble GLdouble top
Definition: GLee.h:13559
Area mSavedViewport
Definition: TileRender.h:68
Definition: Area.h:37
int32_t mNumTilesY
Definition: TileRender.h:60
void setMatricesWindow(const Vec2i &windowSize)
Definition: TileRender.h:46
void setMatricesWindow(int32_t windowWidth, int32_t windowHeight)
Definition: TileRender.cpp:90
void setMatricesWindowPersp(int screenWidth, int screenHeight, float fovDegrees=60.0f, float nearPlane=1.0f, float farPlane=1000.0f)
Definition: TileRender.cpp:84
int32_t mTileWidth
Definition: TileRender.h:59
T x
Definition: Vector.h:71
int32_t mCurrentTile
Definition: TileRender.h:62
int32_t mImageHeight
Definition: TileRender.h:58
void updateFrustum()
Definition: TileRender.cpp:131
bool nextTile()
Definition: TileRender.cpp:45
int32_t getImageHeight() const
Definition: TileRender.h:40
void setMatrices(const Camera &camera)
Definition: TileRender.cpp:97
Definition: Camera.h:36
void ortho(float left, float right, float bottom, float top, float nearPlane, float farPlane)
Definition: TileRender.cpp:122
TileRender(int32_t imageWidth, int32_t imageHeight, int32_t tileWidth=512, int32_t tileHeight=512)
Definition: TileRender.cpp:32
float getImageAspectRatio() const
Definition: TileRender.h:41
Definition: TileRender.h:33
void setMatricesWindowPersp(const Vec2i &windowSize, float fovDegrees=60.0f, float nearPlane=1.0f, float farPlane=1000.0f)
Definition: TileRender.h:48
GLdouble left
Definition: GLee.h:13559
int32_t mNumTilesX
Definition: TileRender.h:60
GLdouble GLdouble right
Definition: GLee.h:13559
int32_t mImageWidth
Definition: TileRender.h:58
int32_t getImageWidth() const
Definition: TileRender.h:39
T y
Definition: Vector.h:71
Rectf mCurrentFrustumCoords
Definition: TileRender.h:64
bool mCurrentFrustumPersp
Definition: TileRender.h:66
float mCurrentFrustumNear
Definition: TileRender.h:65
Area mCurrentArea
Definition: TileRender.h:63
GLdouble GLdouble GLdouble bottom
Definition: GLee.h:13559
Surface getSurface() const
Definition: TileRender.h:43
Surface mSurface
Definition: TileRender.h:69
int32_t mTileHeight
Definition: TileRender.h:59
GLclampf f
Definition: GLee.h:15307
void frustum(float left, float right, float bottom, float top, float nearPlane, float farPlane)
Definition: TileRender.cpp:113
Area getCurrentTileArea() const
Definition: TileRender.h:42