/usr/include/OpenLayer/TextureInfo.hpp is in libopenlayer-dev 2.1-2.1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | #ifndef OL_TEXTURE_INFO_HPP
#define OL_TEXTURE_INFO_HPP
#include "Includes.hpp"
#include "Vec2D.hpp"
#include "Rgba.hpp"
#include "OlRectangle.hpp"
#include "Declspec.hpp"
// INTERNAL TEXTURE CLASSES //
namespace ol {
// Internal rectangle class //
/*
class OlRect {
public:
OlRect( float x = 0.0, float y = 0.0, float w = 0.0, float h = 0.0 ) : x( x ), y( y ), w( w ), h( h ) {}
OlRect ClippedTo( const OlRect &rect ) const;
float x, y, w, h;
};*/
typedef OL_LIB_DECLSPEC OlRectangle< float > OlRect;
// OpenLayer's internal texture information //
class OL_LIB_DECLSPEC OlTextureInfo {
public:
OlTextureInfo( int textureWidth, int textureHeight,
int imageWidth, int imageHeight,
GLenum format, GLuint index = 0 );
OlTextureInfo();
// Create a sub-texture //
OlTextureInfo( const OlTextureInfo &other, OlRect clipRect );
inline void SetIndex( GLuint index ) {
this->index = index;
}
inline int GetIndex() const {
return index;
}
inline static void StartRendering() {
glBegin( GL_QUADS );
}
inline void OutputTexturedQuad() const {
OutputTexturedQuad( imgWidth, imgHeight );
}
inline static void FinishRendering() {
glEnd();
}
inline void OutputTexturedQuad( float x, float y, float w, float h ) const {
glBegin( GL_TRIANGLE_FAN );
OutputVertices( x, y, w, h );
glEnd();
}
inline void OutputTexturedQuad( float w, float h ) const {
OutputTexturedQuad( 0.0, 0.0, w, h );
}
inline void OutputTexturedQuadXY( float x, float y ) const {
OutputTexturedQuad( x, y, imgWidth, imgHeight );
}
inline void OutputVertices( float x, float y, float w, float h ) const {
glTexCoord2f( rect.x, rect.y );
glVertex2f( x, y + h );
glTexCoord2f( rect.x + rect.w, rect.y );
glVertex2f( x + w, y + h );
glTexCoord2f( rect.x + rect.w, rect.y + rect.h );
glVertex2f( x + w, y );
glTexCoord2f( rect.x, rect.y + rect.h );
glVertex2f( x, y );
}
/*
inline void OutputTexturedQuadSpecialWorkaround() const {
float x = 0.0, y = 0.0, w = imgWidth, h = imgHeight;
glBegin( GL_TRIANGLE_FAN );
glTexCoord2f( rect.x, rect.y );
glVertex2f( x, y + h+0.99 );
glTexCoord2f( rect.x + rect.w, rect.y );
glVertex2f( x + w+0.5, y + h+0.99 );
glTexCoord2f( rect.x + rect.w, rect.y + rect.h );
glVertex2f( x + w+0.5, y );
glTexCoord2f( rect.x, rect.y + rect.h );
glVertex2f( x, y );
glEnd();
}
*/
inline void OutputVertices( float x, float y ) const {
OutputVertices( x, y, imgWidth, imgHeight );
}
inline void OutputTexturedQuad( Vec2D topleft, Vec2D topright,
Vec2D bottomright, Vec2D bottomleft ) const {
glBegin( GL_TRIANGLE_FAN );
glTexCoord2f( rect.x, rect.y );
glVertex2f( bottomleft.x, bottomleft.y );
glTexCoord2f( rect.x + rect.w, rect.y );
glVertex2f( bottomright.x, bottomright.y );
glTexCoord2f( rect.x + rect.w, rect.y + rect.h );
glVertex2f( topright.x, topright.y );
glTexCoord2f( rect.x, rect.y + rect.h );
glVertex2f( topleft.x, topleft.y );
glEnd();
}
inline void Select() const {
glBindTexture( GL_TEXTURE_2D, index );
}
inline void GetReadyToRender() const {
Select();
glEnable( GL_TEXTURE_2D );
Rgba::WHITE.Select();
}
int GetBytesPerPixel() const;
bool HasAlphaChannel() const;
friend class Bitmap;
GLenum format;
GLuint index;
int texWidth, texHeight;
int imgWidth, imgHeight;
int fullImgWidth, fullImgHeight;
float xMul, yMul;
OlRect rect;
private:
inline float ConvDimension( float imgSize, float texSize ) {
return float( imgSize )/float( texSize );
}
};
// Internal texture coordinate class //
class OL_LIB_DECLSPEC OlTexCoords {
public:
OlTexCoords( const OlTextureInfo &texture )
: texture( texture ),
x1( 0.0 ), x2( texture.imgWidth ),
y1( 0.0 ), y2( texture.imgHeight ),
convx1( 0.0 ), convx2( 0.0 ), convy1( 0.0 ), convy2( 0.0 ),
flipW( false ), flipH( false ), colors( 0 ) {}
/*
OlTexCoords( const OlTexCoords &orign, float x1 = 0.0, float y1 = 0.0, float x2 = 0.0, float y2 = 0.0 )
: w( orign.w ), h( orign.h ), x1( x1 ), y1( y1 ), x2( x2 ), y2( y2 ),
convx1( orign.convx1 ), convx2( orign.convx2 ), convy1( orign.convy1 ), convy2( orign.convy2 ),
flipW( orign.flipW ), flipH( orign.flipH ) {}
*/
inline void FlipHorizontal() { flipW = !flipW; }
inline void FlipVertical() { flipH = !flipH; }
inline float GetAreaW() const { return fabs( x1 - x2 ); }
inline float GetAreaH() const { return fabs( y1 - y2 ); }
void CalculateTextureCoords();
OlTexCoords ClippedTo( const OlRect &rect ) const;
inline bool ChangesColors() const {
return colors != 0;
}
inline const Rgba &GetColor( int index ) const {
return colors[index];
}
inline void SetColors( const Rgba *colors ) {
this->colors = colors;
}
const OlTextureInfo &texture;
float x1, x2, y1, y2;
float convx1, convx2, convy1, convy2;
bool flipW, flipH;
const Rgba *colors;
};
}
#endif // OL_TEXTURE_INFO_HPP
|