125 glPushAttrib(GL_TEXTURE_BIT);
126 glPushAttrib(GL_COLOR_BUFFER_BIT);
129 depth_texture.
enable(ctx, tex_unit);
135 glActiveTextureARB(GL_TEXTURE0_ARB+tex_unit);
139 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB);
141 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, front_to_back?GL_GEQUAL:GL_LEQUAL);
143 glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA);
145 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
174 static GLdouble transAndScale[] = {
180 glGetDoublev(GL_PROJECTION_MATRIX, &mp[0]);
183 glGetDoublev(GL_MODELVIEW_MATRIX, &mm[0]);
186 GLenum current_matrix_mode;
187 glGetIntegerv(GL_MATRIX_MODE, (GLint*)¤t_matrix_mode);
188 glMatrixMode(GL_TEXTURE);
192 glLoadMatrixd(transAndScale);
197 glGetDoublev(GL_TEXTURE_MATRIX, mm);
204 glMatrixMode(current_matrix_mode);
207 GLdouble rowForS[] = {mm[0], mm[4], mm[8], mm[12]};
208 GLdouble rowForT[] = {
209 _invert_t ? (mm[3] -mm[1]) : mm[1],
210 _invert_t ? (mm[7] -mm[5]) : mm[5],
211 _invert_t ? (mm[11]-mm[9]) : mm[9],
212 _invert_t ? (mm[15]-mm[13]) : mm[13] };
214 GLdouble rowForR[] = {
215 front_to_back?(mm[2]-mm[3]*depth_bias):(mm[2]+mm[3]*depth_bias),
216 front_to_back?(mm[6]-mm[7]*depth_bias):(mm[6]+mm[7]*depth_bias),
217 front_to_back?(mm[10]-mm[11]*depth_bias):(mm[10]+mm[11]*depth_bias),
218 front_to_back?(mm[14]-mm[15]*depth_bias):(mm[14]+mm[15]*depth_bias)
220 GLdouble rowForQ[] = {mm[3], mm[7], mm[11], mm[15]};
223 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
224 glTexGendv(GL_S, GL_EYE_PLANE, rowForS);
225 glEnable(GL_TEXTURE_GEN_S);
227 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
228 glTexGendv(GL_T, GL_EYE_PLANE, rowForT);
229 glEnable(GL_TEXTURE_GEN_T);
231 glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
232 glTexGendv(GL_R, GL_EYE_PLANE, rowForR);
233 glEnable(GL_TEXTURE_GEN_R);
235 glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
236 glTexGendv(GL_Q, GL_EYE_PLANE, rowForQ);
237 glEnable(GL_TEXTURE_GEN_Q);
240 glActiveTextureARB(GL_TEXTURE0_ARB);
243 glGenQueriesARB(1, &query);
244 glBeginQueryARB(GL_SAMPLES_PASSED_ARB, query);
247 glEnable(GL_ALPHA_TEST);
248 glAlphaFunc(GL_GREATER, 0.01f);
base class for all drawables, which is independent of the used rendering API.
bool create(const context &ctx, TextureType _tt=TT_UNDEF, unsigned width=-1, unsigned height=-1, unsigned depth=-1)
create the texture of dimension and resolution specified in the data format base class.
void set_compare_function(CompareFunction compare_function)
set the texture compare function
bool replace_from_buffer(const context &ctx, int x, int y, int x_buffer, int y_buffer, int width, int height, int level=-1)
replace a block within a 2d texture from the current read buffer.
bool disable(const context &ctx)
disable texture and restore state from before last enable call
bool enable(const context &ctx, int tex_unit=-1)
enable this texture in the given texture unit, -1 corresponds to the current unit.
bool destruct(const context &ctx)
destruct the texture and free texture memory and handle
void set_compare_mode(bool use_compare_function)
set the texture compare mode and function