Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Shader.cpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #include <vlGraphics/Shader.hpp>
33 #include <vlGraphics/GLSL.hpp>
34 #include <vlGraphics/Light.hpp>
35 #include <vlGraphics/ClipPlane.hpp>
37 #include <vlCore/Log.hpp>
38 #include <vlCore/Say.hpp>
39 
40 using namespace vl;
41 
42 //------------------------------------------------------------------------------
43 // Shader
44 //------------------------------------------------------------------------------
46 {
47  VL_DEBUG_SET_OBJECT_NAME()
48  mLastUpdateTime = 0;
49  // shader user data
50  #ifdef VL_USER_DATA_SHADER
51  mShaderUserData = NULL;
52  #endif
53 }
54 //------------------------------------------------------------------------------
56 {
57 }
58 //------------------------------------------------------------------------------
60 {
61  return static_cast<const GLSLProgram*>( getRenderStateSet()->renderState( RS_GLSLProgram ) );
62 }
63 //------------------------------------------------------------------------------
65 {
66  return static_cast<GLSLProgram*>( getRenderStateSet()->renderState( RS_GLSLProgram ) );
67 }
68 //------------------------------------------------------------------------------
69 // state getters
70 //------------------------------------------------------------------------------
71 #define GET_OR_CREATE(RS)\
72  RS* rs = static_cast<RS*>( gocRenderStateSet()->renderState( RS_##RS ) ); \
73  if ( rs == NULL ) \
74  { \
75  rs = new RS; \
76  gocRenderStateSet()->setRenderState( rs, -1 ); \
77  } \
78  return rs;
79 //------------------------------------------------------------------------------
80 #define GET_OR_CREATE_IDX(RS, index)\
81  RS* rs = static_cast<RS*>( gocRenderStateSet()->renderState( RS_##RS, index ) ); \
82  if ( rs == NULL ) \
83  { \
84  rs = new RS; \
85  gocRenderStateSet()->setRenderState( rs, index ); \
86  } \
87  return rs;
88 //------------------------------------------------------------------------------
90 //------------------------------------------------------------------------------
92 //------------------------------------------------------------------------------
94 //------------------------------------------------------------------------------
96 //------------------------------------------------------------------------------
98 //------------------------------------------------------------------------------
100 //------------------------------------------------------------------------------
102 //------------------------------------------------------------------------------
104 //------------------------------------------------------------------------------
106 //------------------------------------------------------------------------------
108 //------------------------------------------------------------------------------
110 //------------------------------------------------------------------------------
112 //------------------------------------------------------------------------------
114 //------------------------------------------------------------------------------
116 //------------------------------------------------------------------------------
118 //------------------------------------------------------------------------------
120 //------------------------------------------------------------------------------
122 //------------------------------------------------------------------------------
124 //------------------------------------------------------------------------------
126 //------------------------------------------------------------------------------
128 //------------------------------------------------------------------------------
130 //------------------------------------------------------------------------------
132 //------------------------------------------------------------------------------
134 //------------------------------------------------------------------------------
136 //------------------------------------------------------------------------------
138 //------------------------------------------------------------------------------
140 //------------------------------------------------------------------------------
142 //------------------------------------------------------------------------------
144 //------------------------------------------------------------------------------
146 //------------------------------------------------------------------------------
148 //------------------------------------------------------------------------------
150 //------------------------------------------------------------------------------
152 //------------------------------------------------------------------------------
154 //------------------------------------------------------------------------------
155 const VertexAttrib* Shader::getVertexAttrib(int attr_index) const { if (!getRenderStateSet()) return NULL; else return static_cast<const VertexAttrib*>( getRenderStateSet()->renderState( RS_VertexAttrib, attr_index ) ); }
156 //------------------------------------------------------------------------------
157 VertexAttrib* Shader::getVertexAttrib(int attr_index) { if (!getRenderStateSet()) return NULL; else return static_cast<VertexAttrib*>( getRenderStateSet()->renderState( RS_VertexAttrib, attr_index ) ); }
158 //------------------------------------------------------------------------------
159 Light* Shader::gocLight(int light_index) { GET_OR_CREATE_IDX(Light, light_index) }
160 //------------------------------------------------------------------------------
161 const Light* Shader::getLight(int light_index) const { if (!getRenderStateSet()) return NULL; else return static_cast<const Light*>( getRenderStateSet()->renderState( RS_Light, light_index ) ); }
162 //------------------------------------------------------------------------------
163 Light* Shader::getLight(int light_index) { if (!getRenderStateSet()) return NULL; else return static_cast<Light*>( getRenderStateSet()->renderState( RS_Light, light_index ) ); }
164 //------------------------------------------------------------------------------
165 ClipPlane* Shader::gocClipPlane(int plane_index) { GET_OR_CREATE_IDX(ClipPlane, plane_index) }
166 //------------------------------------------------------------------------------
167 const ClipPlane* Shader::getClipPlane(int plane_index) const { if (!getRenderStateSet()) return NULL; else return static_cast<const ClipPlane*>( getRenderStateSet()->renderState( RS_ClipPlane, plane_index) ); }
168 //------------------------------------------------------------------------------
169 ClipPlane* Shader::getClipPlane(int plane_index) { if (!getRenderStateSet()) return NULL; else return static_cast<ClipPlane*>( getRenderStateSet()->renderState( RS_ClipPlane, plane_index) ); }
170 //------------------------------------------------------------------------------
172 //------------------------------------------------------------------------------
173 TexGen* Shader::gocTexGen(int unit_index) { GET_OR_CREATE_IDX(TexGen, unit_index) }
174 //------------------------------------------------------------------------------
175 TexEnv* Shader::gocTexEnv(int unit_index) { GET_OR_CREATE_IDX(TexEnv, unit_index) }
176 //------------------------------------------------------------------------------
178 //------------------------------------------------------------------------------
179 // PixelTransfer
180 //------------------------------------------------------------------------------
181 void PixelTransfer::apply(int, const Camera*, OpenGLContext*) const
182 {
183  glPixelTransferi(GL_MAP_COLOR, mapColor() ? GL_TRUE : GL_FALSE);
184  glPixelTransferi(GL_MAP_STENCIL, mapStencil() ? GL_TRUE : GL_FALSE);
185  glPixelTransferi(GL_INDEX_SHIFT, indexShift() );
186  glPixelTransferi(GL_INDEX_OFFSET, indexOffset() );
187  glPixelTransferf(GL_RED_SCALE, redScale() );
188  glPixelTransferf(GL_GREEN_SCALE, greenScale() );
189  glPixelTransferf(GL_BLUE_SCALE, blueScale() );
190  glPixelTransferf(GL_ALPHA_SCALE, alphaScale() );
191  glPixelTransferf(GL_DEPTH_SCALE, depthScale() );
192  glPixelTransferf(GL_RED_BIAS, redBias() );
193  glPixelTransferf(GL_GREEN_BIAS, greenBias() );
194  glPixelTransferf(GL_BLUE_BIAS, blueBias() );
195  glPixelTransferf(GL_ALPHA_BIAS, alphaBias() );
196  glPixelTransferf(GL_DEPTH_BIAS, depthBias() );
197  VL_CHECK_OGL()
198  if (Has_GL_ARB_imaging)
199  {
200  glPixelTransferf(GL_POST_COLOR_MATRIX_RED_SCALE, postColorMatrixRedScale() );
201  glPixelTransferf(GL_POST_COLOR_MATRIX_GREEN_SCALE, postColorMatrixGreenScale() );
202  glPixelTransferf(GL_POST_COLOR_MATRIX_BLUE_SCALE, postColorMatrixBlueScale() );
203  glPixelTransferf(GL_POST_COLOR_MATRIX_ALPHA_SCALE, postColorMatrixAlphaScale() );
204  glPixelTransferf(GL_POST_COLOR_MATRIX_RED_BIAS, postColorMatrixRedBias() );
205  glPixelTransferf(GL_POST_COLOR_MATRIX_GREEN_BIAS, postColorMatrixGreenBias() );
206  glPixelTransferf(GL_POST_COLOR_MATRIX_BLUE_BIAS, postColorMatrixBlueBias() );
207  glPixelTransferf(GL_POST_COLOR_MATRIX_ALPHA_BIAS, postColorMatrixAlphaBias() );
208  glPixelTransferf(GL_POST_CONVOLUTION_RED_SCALE, postConvolutionRedScale() );
209  glPixelTransferf(GL_POST_CONVOLUTION_GREEN_SCALE, postConvolutionGreenScale() );
210  glPixelTransferf(GL_POST_CONVOLUTION_BLUE_SCALE, postConvolutionBlueScale() );
211  glPixelTransferf(GL_POST_CONVOLUTION_ALPHA_SCALE, postConvolutionAlphaScale() );
212  glPixelTransferf(GL_POST_CONVOLUTION_RED_BIAS, postConvolutionRedBias() );
213  glPixelTransferf(GL_POST_CONVOLUTION_GREEN_BIAS, postConvolutionGreenBias() );
214  glPixelTransferf(GL_POST_CONVOLUTION_BLUE_BIAS, postConvolutionBlueBias() );
215  glPixelTransferf(GL_POST_CONVOLUTION_ALPHA_BIAS, postConvolutionAlphaBias() );
216  VL_CHECK_OGL()
217  }
218 }
219 //------------------------------------------------------------------------------
220 // Hint
221 //------------------------------------------------------------------------------
222 void Hint::apply(int, const Camera*, OpenGLContext*) const
223 {
224  VL_CHECK_OGL()
225 
227  {
228  glHint( GL_PERSPECTIVE_CORRECTION_HINT, mPerspectiveCorrectionHint ); VL_CHECK_OGL()
229 
230  glHint( GL_FOG_HINT, mFogHint ); VL_CHECK_OGL()
231 
233  {
234  glHint( GL_GENERATE_MIPMAP_HINT, mGenerateMipmapHint ); VL_CHECK_OGL()
235  }
236  }
237 
238  if ( !Has_GLES )
239  {
240  glHint( GL_POLYGON_SMOOTH_HINT, mPolygonSmoothHint ); VL_CHECK_OGL()
241  glHint( GL_LINE_SMOOTH_HINT, mLineSmoothHint ); VL_CHECK_OGL()
242  }
243  if ( Has_GL_Version_1_1 )
244  {
245  glHint( GL_POINT_SMOOTH_HINT, mPointSmoothHint ); VL_CHECK_OGL()
246  }
247 }
248 //------------------------------------------------------------------------------
249 // CullFace
250 //------------------------------------------------------------------------------
251 void CullFace::apply(int, const Camera*, OpenGLContext*) const
252 {
253  glCullFace(mFaceMode); VL_CHECK_OGL()
254 }
255 //------------------------------------------------------------------------------
256 // FrontFace
257 //------------------------------------------------------------------------------
258 void FrontFace::apply(int, const Camera*, OpenGLContext*) const
259 {
260  glFrontFace(mFrontFace); VL_CHECK_OGL()
261 }
262 //------------------------------------------------------------------------------
263 // DepthFunc
264 //------------------------------------------------------------------------------
265 void DepthFunc::apply(int, const Camera*, OpenGLContext*) const
266 {
267  glDepthFunc(mDepthFunc); VL_CHECK_OGL()
268 }
269 //------------------------------------------------------------------------------
270 // DepthMask
271 //------------------------------------------------------------------------------
272 void DepthMask::apply(int, const Camera*, OpenGLContext*) const
273 {
274  glDepthMask(mDepthMask?GL_TRUE:GL_FALSE); VL_CHECK_OGL()
275 }
276 //------------------------------------------------------------------------------
277 // PolygonMode
278 //------------------------------------------------------------------------------
279 void PolygonMode::apply(int, const Camera*, OpenGLContext*) const
280 {
281  // required by GL 3.1 CORE
282  if ( mFrontFace == mBackFace )
283  {
284  glPolygonMode(GL_FRONT_AND_BACK, mFrontFace); VL_CHECK_OGL()
285  }
286  else
287  {
288  glPolygonMode(GL_FRONT, mFrontFace); VL_CHECK_OGL()
289  glPolygonMode(GL_BACK, mBackFace); VL_CHECK_OGL()
290  }
291 }
292 //------------------------------------------------------------------------------
293 // ShadeModel
294 //------------------------------------------------------------------------------
295 void ShadeModel::apply(int, const Camera*, OpenGLContext*) const
296 {
297  glShadeModel(mShadeModel); VL_CHECK_OGL()
298 }
299 //------------------------------------------------------------------------------
300 // BlendFunc
301 //------------------------------------------------------------------------------
302 void BlendFunc::apply(int, const Camera*, OpenGLContext*) const
303 {
304  if (Has_GL_EXT_blend_func_separate||Has_GL_Version_1_4||Has_GL_Version_3_0||Has_GL_Version_4_0||Has_GL_OES_blend_func_separate||Has_GLES_Version_2_0)
305  {
306  VL_glBlendFuncSeparate(mSrcRGB, mDstRGB, mSrcAlpha, mDstAlpha); VL_CHECK_OGL()
307  }
308  else
309  {
310  glBlendFunc(mSrcRGB, mDstRGB); VL_CHECK_OGL() // modifies rgb and alpha
311  }
312 }
313 //------------------------------------------------------------------------------
314 // BlendEquation
315 //------------------------------------------------------------------------------
316 void BlendEquation::apply(int, const Camera*, OpenGLContext*) const
317 {
318  if (Has_GL_Version_2_0||Has_GL_EXT_blend_equation_separate)
319  { VL_glBlendEquationSeparate(mModeRGB, mModeAlpha); VL_CHECK_OGL() }
320  else
321  { VL_glBlendEquation(mModeRGB); VL_CHECK_OGL() }
322 }
323 //------------------------------------------------------------------------------
324 // AlphaFunc
325 //------------------------------------------------------------------------------
326 void AlphaFunc::apply(int, const Camera*, OpenGLContext*) const
327 {
328  glAlphaFunc(mAlphaFunc, mRefValue); VL_CHECK_OGL()
329 }
330 //------------------------------------------------------------------------------
331 // Material
332 //------------------------------------------------------------------------------
334 {
335  VL_DEBUG_SET_OBJECT_NAME()
336  mFrontAmbient = fvec4(0.2f, 0.2f, 0.2f, 1.0f);
337  mFrontDiffuse = fvec4(0.8f, 0.8f, 0.8f, 1.0f);
338  mFrontSpecular = fvec4(0.0f, 0.0f, 0.0f, 1.0f);
339  mFrontEmission = fvec4(0.0f, 0.0f, 0.0f, 1.0f);
340  mFrontShininess = 0;
341 
342  mBackAmbient = fvec4(0.2f, 0.2f, 0.2f, 1.0f);
343  mBackDiffuse = fvec4(0.8f, 0.8f, 0.8f, 1.0f);
344  mBackSpecular = fvec4(0.0f, 0.0f, 0.0f, 1.0f);
345  mBackEmission = fvec4(0.0f, 0.0f, 0.0f, 1.0f);
346  mBackShininess = 0;
347 
348  mColorMaterialEnabled = false;
349  mColorMaterialFace = PF_FRONT_AND_BACK;
350  mColorMaterial = CM_AMBIENT_AND_DIFFUSE;
351 }
352 //------------------------------------------------------------------------------
354 {
355  float min_alpha = std::min( mFrontAmbient.a(), mBackAmbient.a() );
356  min_alpha = std::min( min_alpha, mFrontDiffuse.a() );
357  min_alpha = std::min( min_alpha, mBackDiffuse.a() );
358  min_alpha = std::min( min_alpha, mFrontSpecular.a());
359  min_alpha = std::min( min_alpha, mBackSpecular.a() );
360  min_alpha = std::min( min_alpha, mFrontEmission.a());
361  min_alpha = std::min( min_alpha, mBackEmission.a() );
362  return min_alpha;
363 }
364 //------------------------------------------------------------------------------
366 {
367  mFrontAmbient.a() *= alpha;
368  mBackAmbient.a() *= alpha;
369  mFrontDiffuse.a() *= alpha;
370  mBackDiffuse.a() *= alpha;
371  mFrontSpecular.a() *= alpha;
372  mBackSpecular.a() *= alpha;
373  mFrontEmission.a() *= alpha;
374  mBackEmission.a() *= alpha;
375 }
376 //------------------------------------------------------------------------------
377 void Material::setTransparency(float alpha)
378 {
379  mFrontAmbient.a() = mBackAmbient.a() = alpha;
380  mFrontDiffuse.a() = mBackDiffuse.a() = alpha;
381  mFrontSpecular.a() = mBackSpecular.a() = alpha;
382  mFrontEmission.a() = mBackEmission.a() = alpha;
383 }
384 //------------------------------------------------------------------------------
386 {
387  mFrontAmbient.a() = alpha;
388  mFrontDiffuse.a() = alpha;
389  mFrontSpecular.a() = alpha;
390  mFrontEmission.a() = alpha;
391 }
392 //------------------------------------------------------------------------------
394 {
395  mBackAmbient.a() = alpha;
396  mBackDiffuse.a() = alpha;
397  mBackSpecular.a() = alpha;
398  mBackEmission.a() = alpha;
399 }
400 //------------------------------------------------------------------------------
402 {
403  mFrontAmbient = 0;
404  mFrontDiffuse = 0;
405  mFrontSpecular = 0;
406  mFrontEmission = color;
407  mFrontShininess = 0;
408  setFrontTransparency(color.a());
409 }
410 //------------------------------------------------------------------------------
412 {
413  mBackAmbient = 0;
414  mBackDiffuse = 0;
415  mBackSpecular = 0;
416  mBackEmission = color;
417  mBackShininess = 0;
418  setBackTransparency(color.a());
419 }
420 //------------------------------------------------------------------------------
421 void Material::setFlatColor(const fvec4& color)
422 {
423  setFrontFlatColor(color);
424  setBackFlatColor(color);
425 }
426 //------------------------------------------------------------------------------
427 void Material::apply(int, const Camera*, OpenGLContext*) const
428 {
429  VL_CHECK_OGL();
430 
431 #if defined(VL_OPENGL)
432 
433  if (mColorMaterialEnabled)
434  {
435  glColorMaterial(colorMaterialFace(), colorMaterial()); VL_CHECK_OGL();
436  glEnable(GL_COLOR_MATERIAL); VL_CHECK_OGL();
437  }
438  else
439  {
440  glDisable(GL_COLOR_MATERIAL); VL_CHECK_OGL();
441  }
442 
443  if ( mFrontAmbient == mBackAmbient )
444  {
445  glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mFrontAmbient.ptr());
446  }
447  else
448  {
449  glMaterialfv(GL_FRONT, GL_AMBIENT, mFrontAmbient.ptr());
450  glMaterialfv(GL_BACK, GL_AMBIENT, mBackAmbient.ptr());
451  }
452 
453  if ( mFrontDiffuse == mBackDiffuse )
454  {
455  glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mFrontDiffuse.ptr());
456  }
457  else
458  {
459  glMaterialfv(GL_FRONT, GL_DIFFUSE, mFrontDiffuse.ptr());
460  glMaterialfv(GL_BACK, GL_DIFFUSE, mBackDiffuse.ptr());
461  }
462 
463  if ( mFrontSpecular == mBackSpecular )
464  {
465  glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mFrontSpecular.ptr());
466  }
467  else
468  {
469  glMaterialfv(GL_FRONT, GL_SPECULAR, mFrontSpecular.ptr());
470  glMaterialfv(GL_BACK, GL_SPECULAR, mBackSpecular.ptr());
471  }
472 
473  if ( mFrontEmission == mBackEmission )
474  {
475  glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, mFrontEmission.ptr());
476  }
477  else
478  {
479  glMaterialfv(GL_FRONT, GL_EMISSION, mFrontEmission.ptr());
480  glMaterialfv(GL_BACK, GL_EMISSION, mBackEmission.ptr());
481  }
482 
483  if ( mFrontShininess == mBackShininess )
484  {
485  glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, mFrontShininess); VL_CHECK_OGL();
486  }
487  else
488  {
489  glMaterialf(GL_FRONT, GL_SHININESS, mFrontShininess); VL_CHECK_OGL();
490  glMaterialf(GL_BACK, GL_SHININESS, mBackShininess); VL_CHECK_OGL();
491  }
492 
493 
494 #else
495 
496  if (mColorMaterialEnabled)
497  {
498  // OpenGL ES supports only this
499  if (colorMaterial() != CM_AMBIENT_AND_DIFFUSE)
500  {
501  Log::error("OpenGL ES 1.x supports only CM_AMBIENT_AND_DIFFUSE color material mode!\n");
502  VL_TRAP();
503  }
504  glEnable(GL_COLOR_MATERIAL); VL_CHECK_OGL();
505  }
506  else
507  {
508  glDisable(GL_COLOR_MATERIAL); VL_CHECK_OGL();
509  }
510 
511  glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mFrontAmbient.ptr());
512  glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mFrontDiffuse.ptr());
513  glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mFrontSpecular.ptr());
514  glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, mFrontEmission.ptr());
515  glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, mFrontShininess); VL_CHECK_OGL();
516 
517 #endif
518 
519  VL_CHECK_OGL();
520 }
521 //------------------------------------------------------------------------------
522 // LightModel
523 //------------------------------------------------------------------------------
524 void LightModel::apply(int, const Camera*, OpenGLContext*) const
525 {
526  if (Has_GL_Version_1_2||Has_GL_EXT_separate_specular_color)
527  {
528  glLightModelf(GL_LIGHT_MODEL_COLOR_CONTROL, (float)mColorControl); VL_CHECK_OGL()
529  }
530 
531  if (Has_GL_Version_1_1)
532  glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, mLocalViewer ? 1.0f : 0.0f ); VL_CHECK_OGL()
533 
534  // Supported by GLES 1.x as well.
535  glLightModelfv(GL_LIGHT_MODEL_AMBIENT, mAmbientColor.ptr()); VL_CHECK_OGL()
536  glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, mTwoSide ? 1.0f : 0.0f ); VL_CHECK_OGL()
537 }
538 //------------------------------------------------------------------------------
539 // Fog
540 //------------------------------------------------------------------------------
541 void Fog::apply(int, const Camera*, OpenGLContext*) const
542 {
543  glFogf(GL_FOG_MODE, (float)mMode); VL_CHECK_OGL()
544  glFogf(GL_FOG_DENSITY, mDensity); VL_CHECK_OGL()
545  glFogf(GL_FOG_START, mStart); VL_CHECK_OGL()
546  glFogf(GL_FOG_END, mEnd); VL_CHECK_OGL()
547  glFogfv(GL_FOG_COLOR, mColor.ptr()); VL_CHECK_OGL()
548 }
549 
550 //------------------------------------------------------------------------------
551 // PolygonOffset
552 //------------------------------------------------------------------------------
553 void PolygonOffset::apply(int, const Camera*, OpenGLContext*) const
554 {
555  glPolygonOffset(mFactor, mUnits); VL_CHECK_OGL()
556 }
557 //------------------------------------------------------------------------------
558 // LogicOp
559 //------------------------------------------------------------------------------
560 void LogicOp::apply(int, const Camera*, OpenGLContext*) const
561 {
562  glLogicOp(mLogicOp); VL_CHECK_OGL()
563 }
564 //------------------------------------------------------------------------------
565 // DepthRange
566 //------------------------------------------------------------------------------
567 void DepthRange::apply(int, const Camera*, OpenGLContext*) const
568 {
569  glDepthRange(mZNear, mZFar); VL_CHECK_OGL()
570 }
571 //------------------------------------------------------------------------------
572 // LineWidth
573 //------------------------------------------------------------------------------
574 void LineWidth::apply(int, const Camera*, OpenGLContext*) const
575 {
576  glLineWidth(mLineWidth); VL_CHECK_OGL()
577 }
578 //------------------------------------------------------------------------------
579 // PointSize
580 //------------------------------------------------------------------------------
581 void PointSize::apply(int, const Camera*, OpenGLContext*) const
582 {
583  glPointSize(mPointSize); VL_CHECK_OGL()
584 }
585 //------------------------------------------------------------------------------
586 // PolygonStipple
587 //------------------------------------------------------------------------------
589 {
590  VL_DEBUG_SET_OBJECT_NAME()
591  memset(mMask, 0xFF, sizeof(unsigned char)*32*32/8);
592 }
593 //------------------------------------------------------------------------------
594 PolygonStipple::PolygonStipple(const unsigned char* mask)
595 {
596  VL_DEBUG_SET_OBJECT_NAME()
597  set(mask);
598 }
599 //------------------------------------------------------------------------------
600 void PolygonStipple::set(const unsigned char* mask)
601 {
602  memcpy(mMask, mask, sizeof(unsigned char)*32*32/8);
603 }
604 //------------------------------------------------------------------------------
605 void PolygonStipple::apply(int, const Camera*, OpenGLContext*) const
606 {
607  glPolygonStipple(mask()); VL_CHECK_OGL()
608 }
609 //------------------------------------------------------------------------------
610 // LineStipple
611 //------------------------------------------------------------------------------
612 void LineStipple::apply(int, const Camera*, OpenGLContext*) const
613 {
614  glLineStipple(mFactor, mPattern); VL_CHECK_OGL()
615 }
616 //------------------------------------------------------------------------------
617 // PointParameter
618 //------------------------------------------------------------------------------
619 void PointParameter::apply(int, const Camera*, OpenGLContext*) const
620 {
622  {
623  VL_glPointParameterf(GL_POINT_SIZE_MIN, mSizeMin); VL_CHECK_OGL()
624  VL_glPointParameterf(GL_POINT_SIZE_MAX, mSizeMax); VL_CHECK_OGL()
625  VL_glPointParameterfv(GL_POINT_DISTANCE_ATTENUATION, (const float*)mDistanceAttenuation.ptr()); VL_CHECK_OGL()
626  }
628  {
629  VL_glPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE, mFadeThresholdSize); VL_CHECK_OGL()
630  }
632  {
633  VL_glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, mPointSpriteCoordOrigin); VL_CHECK_OGL()
634  }
635 }
636 //------------------------------------------------------------------------------
637 // StencilFunc
638 //------------------------------------------------------------------------------
639 void StencilFunc::apply(int, const Camera*, OpenGLContext*) const
640 {
642  {
643  VL_glStencilFuncSeparate(GL_FRONT, mFunction_Front, mRefValue_Front, mMask_Front); VL_CHECK_OGL()
644  VL_glStencilFuncSeparate(GL_BACK, mFunction_Back, mRefValue_Back, mMask_Back); VL_CHECK_OGL()
645  }
646  else
647  {
648  glStencilFunc(mFunction_Front, mRefValue_Front, mMask_Front); VL_CHECK_OGL()
649  }
650 }
651 //------------------------------------------------------------------------------
652 // StencilOp
653 //------------------------------------------------------------------------------
654 void StencilOp::apply(int, const Camera*, OpenGLContext*) const
655 {
657  {
658  VL_glStencilOpSeparate(GL_FRONT, mSFail_Front, mDpFail_Front, mDpPass_Front); VL_CHECK_OGL()
659  VL_glStencilOpSeparate(GL_BACK, mSFail_Back, mDpFail_Back, mDpPass_Back); VL_CHECK_OGL()
660  }
661  else
662  {
663  glStencilOp(mSFail_Front, mDpFail_Front, mDpPass_Front); VL_CHECK_OGL()
664  }
665 }
666 //------------------------------------------------------------------------------
667 // StencilMask
668 //------------------------------------------------------------------------------
669 void StencilMask::apply(int, const Camera*, OpenGLContext*) const
670 {
672  {
673  glStencilMaskSeparate(GL_FRONT, mMask_Front); VL_CHECK_OGL()
674  glStencilMaskSeparate(GL_BACK, mMask_Back); VL_CHECK_OGL()
675  }
676  else
677  {
678  glStencilMask(mMask_Front); VL_CHECK_OGL()
679  }
680 }
681 //------------------------------------------------------------------------------
682 // BlendColor
683 //------------------------------------------------------------------------------
684 void BlendColor::apply(int, const Camera*, OpenGLContext*) const
685 {
686  VL_glBlendColor(mBlendColor.r(), mBlendColor.g(), mBlendColor.b(), mBlendColor.a()); VL_CHECK_OGL()
687 }
688 //------------------------------------------------------------------------------
689 // VertexAttrib
690 //------------------------------------------------------------------------------
691 void VertexAttrib::apply(int index, const Camera*, OpenGLContext* ctx) const
692 {
693  glVertexAttrib4fv( index, mValue.ptr() ); VL_CHECK_OGL()
694  ctx->mVertexAttribValue[index] = mValue;
695 }
696 //------------------------------------------------------------------------------
697 // Color
698 //------------------------------------------------------------------------------
699 void Color::apply(int, const Camera*, OpenGLContext* ctx) const
700 {
701  VL_CHECK( ctx );
702  glColor4f( mColor.r(), mColor.g(), mColor.b(), mColor.a() ); VL_CHECK_OGL()
703  ctx->mColor = mColor;
704 }
705 //------------------------------------------------------------------------------
706 // SecondaryColor
707 //------------------------------------------------------------------------------
708 void SecondaryColor::apply(int, const Camera*, OpenGLContext* ctx) const
709 {
710  VL_glSecondaryColor3f( mSecondaryColor.r(), mSecondaryColor.g(), mSecondaryColor.b() ); VL_CHECK_OGL()
711  ctx->mSecondaryColor = mSecondaryColor;
712 }
713 //------------------------------------------------------------------------------
714 // Normal
715 //------------------------------------------------------------------------------
716 void Normal::apply(int, const Camera*, OpenGLContext* ctx) const
717 {
718  glNormal3f( mNormal.x(), mNormal.y(), mNormal.z() ); VL_CHECK_OGL()
719  ctx->mNormal = mNormal;
720 }
721 //------------------------------------------------------------------------------
722 // ColorMask
723 //------------------------------------------------------------------------------
724 void ColorMask::apply(int, const Camera*, OpenGLContext*) const
725 {
726  glColorMask(mRed?GL_TRUE:GL_FALSE, mGreen?GL_TRUE:GL_FALSE, mBlue?GL_TRUE:GL_FALSE, mAlpha?GL_TRUE:GL_FALSE); VL_CHECK_OGL()
727 }
728 //------------------------------------------------------------------------------
729 // SampleCoverage
730 //------------------------------------------------------------------------------
731 void SampleCoverage::apply(int, const Camera*, OpenGLContext*) const
732 {
733  VL_glSampleCoverage(mValue, mInvert?GL_TRUE:GL_FALSE); VL_CHECK_OGL()
734 }
735 //------------------------------------------------------------------------------
736 // TexParameter
737 //------------------------------------------------------------------------------
739 {
740  mDirty = true;
741  setMinFilter(TPF_LINEAR);
742  setMagFilter(TPF_LINEAR);
743  setWrapS(TPW_REPEAT);
744  setWrapT(TPW_REPEAT);
745  setWrapR(TPW_REPEAT);
746  setBorderColor(fvec4(0,0,0,0));
747  setAnisotropy(1.0f);
748  setGenerateMipmap(false);
749  setCompareFunc(TCF_LEQUAL);
750  setCompareMode(TCM_NONE);
751  setDepthTextureMode(DTM_LUMINANCE);
752 }
753 //------------------------------------------------------------------------------
755 {
756  mDirty = true;
757 
758  switch(magfilter)
759  {
760  case TPF_LINEAR:
761  case TPF_NEAREST:
762  {
763  mMagfilter = magfilter;
764  break;
765  }
766  default:
767  {
768  mMagfilter = TPF_LINEAR;
769  #ifndef NDEBUG
770  Log::bug("TexParameter::setMagFilter() accepts only the following values: TPF_LINEAR, TPF_NEAREST.\n");
771  #endif
772  }
773  }
774 }
775 //------------------------------------------------------------------------------
777 {
778  VL_CHECK_OGL()
779 
780 #ifndef NDEBUG
781  if (dimension == TD_TEXTURE_RECTANGLE)
782  {
783  bool err = (wrapS() != GL_CLAMP && wrapS() != GL_CLAMP_TO_EDGE && wrapS() != GL_CLAMP_TO_BORDER) |
784  (wrapT() != GL_CLAMP && wrapT() != GL_CLAMP_TO_EDGE && wrapT() != GL_CLAMP_TO_BORDER) |
785  (wrapR() != GL_CLAMP && wrapR() != GL_CLAMP_TO_EDGE && wrapR() != GL_CLAMP_TO_BORDER);
786  if (err)
787  {
788  Log::bug("ARB_texture_rectangle extension allows only the following wrapping modes: GL_CLAMP, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_BORDER.\n"); VL_TRAP()
789  }
790  }
791 
792  if (wrapS() == GL_MIRRORED_REPEAT || wrapT() == GL_MIRRORED_REPEAT || wrapR() == GL_MIRRORED_REPEAT)
793  {
794  if( !(Has_GL_IBM_texture_mirrored_repeat || Has_GL_ARB_texture_mirrored_repeat || Has_GL_Version_1_4 || Has_GL_Version_3_0 || Has_GL_Version_4_0 || Has_GLES_Version_2_0) )
795  {
796  Log::bug("GL_MIRRORED_REPEAT not supported by your OpenGL implementation.\n"); VL_TRAP()
797  }
798  }
799 
800  if (wrapS() == GL_CLAMP_TO_EDGE || wrapT() == GL_CLAMP_TO_EDGE || wrapR() == GL_CLAMP_TO_EDGE)
801  {
802  if( !(Has_GL_SGIS_texture_edge_clamp || Has_GL_Version_1_2 || Has_GL_Version_3_0 || Has_GL_Version_4_0 || Has_GLES_Version_1_1 || Has_GLES_Version_2_0) )
803  {
804  Log::bug("GL_CLAMP_TO_EDGE not supported by your OpenGL implementation.\n"); VL_TRAP()
805  }
806  }
807 
808  if (wrapS() == GL_CLAMP_TO_BORDER || wrapT() == GL_CLAMP_TO_BORDER || wrapR() == GL_CLAMP_TO_BORDER)
809  {
810  if( !(Has_GL_SGIS_texture_border_clamp || Has_GL_ARB_texture_border_clamp || Has_GL_Version_1_3 || Has_GL_Version_3_0 || Has_GL_Version_4_0) )
811  {
812  Log::bug("GL_CLAMP_TO_BORDER not supported by your OpenGL implementation.\n"); VL_TRAP()
813  }
814  }
815 #endif
816 
817  // none of these are supported by texture buffers and multisample textures
818 
819  if (dimension != TD_TEXTURE_BUFFER && dimension != TD_TEXTURE_2D_MULTISAMPLE && dimension != TD_TEXTURE_2D_MULTISAMPLE_ARRAY)
820  {
821 #if defined(VL_OPENGL)
822  glTexParameterfv(dimension, GL_TEXTURE_BORDER_COLOR, borderColor().ptr()); VL_CHECK_OGL()
823 #endif
824  glTexParameteri(dimension, GL_TEXTURE_MIN_FILTER, minFilter()); VL_CHECK_OGL()
825  glTexParameteri(dimension, GL_TEXTURE_MAG_FILTER, magFilter()); VL_CHECK_OGL()
826  glTexParameteri(dimension, GL_TEXTURE_WRAP_S, wrapS()); VL_CHECK_OGL()
827  glTexParameteri(dimension, GL_TEXTURE_WRAP_T, wrapT()); VL_CHECK_OGL()
828  if (Has_Texture_3D)
829  glTexParameteri(dimension, GL_TEXTURE_WRAP_R, wrapR()); VL_CHECK_OGL()
830 
831  if (Has_GL_EXT_texture_filter_anisotropic)
832  glTexParameterf( dimension, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy() ); VL_CHECK_OGL()
833 
834  if (Has_GL_GENERATE_MIPMAP && dimension != TD_TEXTURE_RECTANGLE)
835  glTexParameteri(dimension, GL_GENERATE_MIPMAP, generateMipmap() ? GL_TRUE : GL_FALSE); VL_CHECK_OGL()
836 
838  {
839  glTexParameteri(dimension, GL_TEXTURE_COMPARE_MODE, compareMode() ); VL_CHECK_OGL()
840  glTexParameteri(dimension, GL_TEXTURE_COMPARE_FUNC, compareFunc() ); VL_CHECK_OGL()
842  glTexParameteri(dimension, GL_DEPTH_TEXTURE_MODE, depthTextureMode() ); VL_CHECK_OGL()
843  }
844  }
845 
846  mDirty = false;
847 
848  VL_CHECK_OGL()
849 }
850 //------------------------------------------------------------------------------
851 // TexEnv
852 //------------------------------------------------------------------------------
854 {
855  VL_DEBUG_SET_OBJECT_NAME()
856 
857  mMode = TEM_MODULATE;
858  mColor = fvec4(0,0,0,0);
859 
860  // combiner settings
861  mRGBScale = 1.0f;
862  mCombineRGB = TEM_REPLACE;
863  mSource0RGB = TES_TEXTURE;
864  mSource1RGB = TES_TEXTURE;
865  mSource2RGB = TES_TEXTURE;
866  mOperand0RGB = TEO_SRC_COLOR;
867  mOperand1RGB = TEO_SRC_COLOR;
868  mOperand2RGB = TEO_SRC_COLOR;
869 
870  mAlphaScale = 1.0f;
871  mCombineAlpha = TEM_REPLACE;
872  mSource0Alpha = TES_TEXTURE;
873  mSource1Alpha = TES_TEXTURE;
874  mSource2Alpha = TES_TEXTURE;
875  mOperand0Alpha = TEO_SRC_ALPHA;
876  mOperand1Alpha = TEO_SRC_ALPHA;
877  mOperand2Alpha = TEO_SRC_ALPHA;
878 
879  mLodBias = 0.0;
880  mPointSpriteCoordReplace = false;
881 }
882 //------------------------------------------------------------------------------
883 void TexEnv::apply(int index, const Camera*, OpenGLContext* ctx) const
884 {
885  VL_CHECK_OGL()
886  VL_CHECK(index < VL_MAX_LEGACY_TEXTURE_UNITS)
887  VL_CHECK(index < ctx->textureCoordCount())
888 
889  // if this fails probably you requested a texture unit index not supported by your OpenGL implementation.
890  VL_glActiveTexture( GL_TEXTURE0 + index ); VL_CHECK_OGL();
891 
892  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode()); VL_CHECK_OGL()
893 
894  // red book 1.4 p411
895  if (mode() == TEM_BLEND)
896  {
897  glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color().ptr()); VL_CHECK_OGL()
898  }
899 
900  // combiner settings
901  // red book 1.4 p438
902  if (mode() == TEM_COMBINE && (Has_GL_EXT_texture_env_combine || Has_GL_Version_1_3))
903  {
904  glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, rgbScale()); VL_CHECK_OGL()
905  glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, combineRGB()); VL_CHECK_OGL()
906  glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, source0RGB()); VL_CHECK_OGL()
907  glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, source1RGB()); VL_CHECK_OGL()
908  glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, operand0RGB()); VL_CHECK_OGL()
909  glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, operand1RGB()); VL_CHECK_OGL()
910  if (combineRGB() == TEM_INTERPOLATE)
911  {
912  glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, source2RGB()); VL_CHECK_OGL()
913  glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, operand2RGB()); VL_CHECK_OGL()
914  }
915 
916  glTexEnvf(GL_TEXTURE_ENV, GL_ALPHA_SCALE, alphaScale()); VL_CHECK_OGL()
917  glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, combineAlpha()); VL_CHECK_OGL()
918  glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, source0Alpha()); VL_CHECK_OGL()
919  glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, source1Alpha()); VL_CHECK_OGL()
920  glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, operand0Alpha()); VL_CHECK_OGL()
921  glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, operand1Alpha()); VL_CHECK_OGL()
922  if (combineAlpha() == TEM_INTERPOLATE)
923  {
924  glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA, source2Alpha()); VL_CHECK_OGL()
925  glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA, operand2Alpha()); VL_CHECK_OGL()
926  }
927  }
928 
929  // no need to do it if point sprite is disabled but we cannot know it here
930  if (Has_Point_Sprite)
931  {
932  glTexEnvi( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, mPointSpriteCoordReplace ? GL_TRUE : GL_FALSE ); VL_CHECK_OGL()
933  }
934 
935  if (Has_GL_Version_1_4||Has_GL_EXT_texture_lod_bias)
936  {
937  glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, mLodBias); VL_CHECK_OGL()
938  }
939 }
940 //-----------------------------------------------------------------------------
941 // TexGen
942 //-----------------------------------------------------------------------------
947 {
948  VL_DEBUG_SET_OBJECT_NAME()
949  mEyePlaneS = fvec4(1,0,0,0);
950  mObjectPlaneS = fvec4(1,0,0,0);
951  mEyePlaneT = fvec4(0,1,0,0);
952  mObjectPlaneT = fvec4(0,1,0,0);
953  mEyePlaneR = fvec4(0,0,1,0);
954  mObjectPlaneR = fvec4(0,0,1,0);
955  mEyePlaneQ = fvec4(0,0,0,1);
956  mObjectPlaneQ = fvec4(0,0,0,1);
957  mGenModeS = TGM_DISABLED;
958  mGenModeT = TGM_DISABLED;
959  mGenModeR = TGM_DISABLED;
960  mGenModeQ = TGM_DISABLED;
961 }
962 //-----------------------------------------------------------------------------
963 void TexGen::apply(int index, const Camera*, OpenGLContext* ctx) const
964 {
965  VL_CHECK_OGL();
966 
967  VL_CHECK(index < VL_MAX_LEGACY_TEXTURE_UNITS)
968  VL_CHECK(index < ctx->textureCoordCount())
969 
970  VL_glActiveTexture( GL_TEXTURE0 + index );
971  // if this fails probably you requested a texture unit index not supported by your OpenGL implementation.
972  VL_CHECK_OGL();
973 
974 #if defined(VL_OPENGL)
975 
976  if (genModeS() || genModeT() || genModeR() || genModeQ())
977  {
978  glMatrixMode(GL_MODELVIEW);
979  glPushMatrix();
980  glLoadIdentity();
981 
982  if (genModeS())
983  {
984  glEnable(GL_TEXTURE_GEN_S);
985  glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, genModeS());
986  // Note: these are not supported by OpenGL ES
987  if (genModeS() == TGM_OBJECT_LINEAR) glTexGenfv(GL_S, GL_OBJECT_PLANE, objectPlaneS().ptr());
988  if (genModeS() == TGM_EYE_LINEAR) glTexGenfv(GL_S, GL_EYE_PLANE, eyePlaneS().ptr());
989  }
990 
991  VL_CHECK_OGL();
992 
993  if (genModeT())
994  {
995  glEnable(GL_TEXTURE_GEN_T);
996  glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, genModeT());
997  // Note: these are not supported by OpenGL ES
998  if (genModeT() == TGM_OBJECT_LINEAR) glTexGenfv(GL_T, GL_OBJECT_PLANE, objectPlaneT().ptr());
999  if (genModeT() == TGM_EYE_LINEAR) glTexGenfv(GL_T, GL_EYE_PLANE, eyePlaneT().ptr());
1000  }
1001 
1002  VL_CHECK_OGL();
1003 
1004  if (genModeR())
1005  {
1006  glEnable(GL_TEXTURE_GEN_R);
1007  glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, genModeR());
1008  // Note: these are not supported by OpenGL ES
1009  if (genModeR() == TGM_OBJECT_LINEAR) glTexGenfv(GL_R, GL_OBJECT_PLANE, objectPlaneR().ptr());
1010  if (genModeR() == TGM_EYE_LINEAR) glTexGenfv(GL_R, GL_EYE_PLANE, eyePlaneR().ptr());
1011  }
1012 
1013  VL_CHECK_OGL();
1014 
1015  if (genModeQ())
1016  {
1017  glEnable(GL_TEXTURE_GEN_Q);
1018  glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, genModeQ());
1019  // Note: these are not supported by OpenGL ES
1020  if (genModeQ() == TGM_OBJECT_LINEAR) glTexGenfv(GL_Q, GL_OBJECT_PLANE, objectPlaneQ().ptr());
1021  if (genModeQ() == TGM_EYE_LINEAR) glTexGenfv(GL_Q, GL_EYE_PLANE, eyePlaneQ().ptr());
1022  }
1023 
1024  glPopMatrix();
1025  }
1026 
1027  // these needs to be done here to apply a TexGen which has all components disabled
1028  // and to finish up the TexGen which mixed enabled/disabled components.
1029 
1030  VL_CHECK_OGL();
1031 
1032  if (!genModeS())
1033  glDisable(GL_TEXTURE_GEN_S);
1034 
1035  if (!genModeT())
1036  glDisable(GL_TEXTURE_GEN_T);
1037 
1038  if (!genModeR())
1039  glDisable(GL_TEXTURE_GEN_R);
1040 
1041  if (!genModeQ())
1042  glDisable(GL_TEXTURE_GEN_Q);
1043 
1044 #elif defined(VL_OPENGL_ES1)
1045 
1046  if ( genModeS() != TGM_DISABLED && genModeS() != TGM_REFLECTION_MAP && genModeS() != TGM_NORMAL_MAP )
1047  {
1048  Log::bug("OpenGL ES does not support GL_SPHERE_MAP, GL_EYE_LINEAR or GL_OBJECT_LINEAR texture coordinate generation!\n"); VL_TRAP();
1049  return;
1050  }
1051 
1052  if ( genModeS() != genModeT() || genModeT() != genModeR() )
1053  {
1054  Log::bug("OpenGL ES requires the same texture coordinate generation mode for S, T and R!\n"); VL_TRAP();
1055  return;
1056  }
1057 
1058  if(!Has_GL_OES_texture_cube_map)
1059  {
1060  Log::bug("Use of vl::TexGen under OpenGL ES requires GL_OES_texture_cube_map extension!\n"); VL_TRAP();
1061  return;
1062  }
1063 
1064  if (genModeS() && genModeT() && genModeR())
1065  {
1066  glMatrixMode(GL_MODELVIEW); VL_CHECK_OGL();
1067  glPushMatrix(); VL_CHECK_OGL();
1068  glLoadIdentity(); VL_CHECK_OGL();
1069 
1070  glEnable(GL_TEXTURE_GEN_STR_OES); VL_CHECK_OGL();
1071  glTexGeni( GL_TEXTURE_GEN_STR_OES, GL_TEXTURE_GEN_MODE, genModeS() ); VL_CHECK_OGL();
1072 
1073  glPopMatrix(); VL_CHECK_OGL();
1074  }
1075  else
1076  {
1077  glTexGeni( GL_TEXTURE_GEN_STR_OES, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_OES ); VL_CHECK_OGL();
1078  glEnable(GL_TEXTURE_GEN_STR_OES); VL_CHECK_OGL();
1079  glDisable(GL_TEXTURE_GEN_STR_OES); VL_CHECK_OGL();
1080  }
1081 
1082 #endif
1083 }
1084 //-----------------------------------------------------------------------------
1085 // TextureMatrix
1086 //-----------------------------------------------------------------------------
1087 void TextureMatrix::apply(int index, const Camera* camera, OpenGLContext* ctx) const
1088 {
1089  VL_CHECK_OGL();
1090  VL_CHECK(index < VL_MAX_LEGACY_TEXTURE_UNITS)
1091  VL_CHECK(index < ctx->textureCoordCount())
1092 
1093  VL_glActiveTexture( GL_TEXTURE0 + index ); VL_CHECK_OGL();
1094 
1095  glMatrixMode(GL_TEXTURE); VL_CHECK_OGL();
1096  if (useCameraRotationInverse()) {
1097  VL_glLoadMatrix( ((mat4)matrix()*camera->modelingMatrix().as3x3()).ptr() ); VL_CHECK_OGL();
1098  }
1099  else {
1100  VL_glLoadMatrix( ((mat4)matrix()).ptr() ); VL_CHECK_OGL();
1101  }
1102 }
1103 //-----------------------------------------------------------------------------
1104 // TextureSampler
1105 //-----------------------------------------------------------------------------
1107 {
1108  return mTexture && mTexture->handle();
1109 }
1110 //------------------------------------------------------------------------------
1111 void TextureSampler::apply(int index, const Camera*, OpenGLContext* ctx) const
1112 {
1113  VL_CHECK_OGL();
1114  VL_CHECK(index < VL_MAX_TEXTURE_IMAGE_UNITS)
1115  VL_CHECK(index < ctx->textureImageUnitCount())
1116 
1117  // activate the appropriate texture unit
1118  VL_glActiveTexture( GL_TEXTURE0 + index ); VL_CHECK_OGL()
1119 
1120  // disable and unbind previous active texture target on this texture unit.
1121  vl::ETextureDimension prev_tex_target = ctx->texUnitBinding( index );
1122  if (prev_tex_target)
1123  {
1124  // this is not strictly necessary, it also avoids interaction witht FBOs etc.
1125  glBindTexture( prev_tex_target, 0 ); VL_CHECK_OGL()
1126 
1127  /* GL_TEXTURE_1D_ARRAY and GL_TEXTURE_2D_ARRAY are not supported by the OpenGL fixed function pipeline */
1129  {
1130  switch(prev_tex_target)
1131  {
1132  case TD_TEXTURE_1D_ARRAY:
1133  case TD_TEXTURE_2D_ARRAY:
1136  case TD_TEXTURE_BUFFER:
1137  break;
1138  default:
1139  glDisable( prev_tex_target ); VL_CHECK_OGL()
1140  }
1141  }
1142  }
1143 
1144  if (hasTexture())
1145  {
1146  // bind the texture
1147  glBindTexture( texture()->dimension(), texture()->handle() ); VL_CHECK_OGL()
1148 
1149  // if we request mipmapped filtering then we must have a mip-mapped texture.
1150 #if !defined(NDEBUG) && defined(VL_OPENGL) // glGetTexLevelParameter* is not supported under OpenGL ES
1151  if ( texture()->dimension() != TD_TEXTURE_BUFFER && (texture()->width() > 1 || texture()->height() > 1 || texture()->depth() > 1) )
1152  {
1153  GLint width = 0;
1154  ETextureDimension tex_target = texture()->dimension() == vl::TD_TEXTURE_CUBE_MAP ? (ETextureDimension)GL_TEXTURE_CUBE_MAP_POSITIVE_X : texture()->dimension();
1155  glGetTexLevelParameteriv( tex_target, 1, GL_TEXTURE_WIDTH, &width );
1156  VL_CHECK_OGL()
1157  if ( !width )
1158  {
1159  switch(texture()->getTexParameter()->minFilter())
1160  {
1165  {
1166  Log::bug( vl::Say("TextureSampler::apply() error: requested mipmapping texture filtering on a Texture with no mipmaps! (%s)\n") << texture()->objectName() );
1167  VL_TRAP()
1168  break;
1169  }
1170 
1171  default:
1172  break;
1173  }
1174  }
1175  }
1176 #endif
1177 
1178  // enable the texture
1180  {
1181  /* GL_TEXTURE_1D_ARRAY and GL_TEXTURE_2D_ARRAY are not supported by the OpenGL fixed function pipeline */
1182  switch(texture()->dimension())
1183  {
1184  case TD_TEXTURE_1D_ARRAY:
1185  case TD_TEXTURE_2D_ARRAY:
1188  case TD_TEXTURE_BUFFER:
1189  break;
1190  default:
1191  glEnable( texture()->dimension() ); VL_CHECK_OGL()
1192  }
1193  }
1194 
1195  // track currently used texture target
1196  ctx->setTexUnitBinding( index, texture()->dimension() );
1197 
1198  // texture parameters
1199  if ( texture()->getTexParameter()->dirty() )
1200  texture()->getTexParameter()->apply( texture()->dimension(), ctx );
1201  }
1202 }
1203 //-----------------------------------------------------------------------------
float getMinimumAlpha() const
Definition: Shader.cpp:353
bool Has_GLES_Version_1_1
Definition: OpenGL.cpp:67
Material * gocMaterial()
Definition: Shader.cpp:119
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:567
bool Has_GL_Version_1_4
Definition: OpenGL.cpp:52
#define GET_OR_CREATE(RS)
Definition: Shader.cpp:71
Hint * gocHint()
Definition: Shader.cpp:93
CullFace * gocCullFace()
Definition: Shader.cpp:95
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:699
RenderState wrapping the OpenGL function glPointParameter(), see also http://www.opengl.org/sdk/docs/man/xhtml/glPointParameter.xml for more information.
Definition: Shader.hpp:1221
bool hasTexture() const
Definition: Shader.cpp:1106
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:265
Normal * gocNormal()
Definition: Shader.cpp:107
RenderState wrapping the OpenGL function glStencilOp() and glStencilOpSeparate(), see also http://www...
Definition: Shader.hpp:1346
LineWidth * gocLineWidth()
Definition: Shader.cpp:131
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:612
Color * gocColor()
Definition: Shader.cpp:103
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:316
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:574
bool Has_GL_Version_1_1
Definition: OpenGL.cpp:49
RenderState wrapping the OpenGL function glDepthFunc(), see also http://www.opengl.org/sdk/docs/man/xhtml/glDepthFunc.xml for more information.
Definition: Shader.hpp:461
RenderState wrapping the OpenGL function glHint(), see also http://www.opengl.org/sdk/docs/man/xhtml/...
Definition: Shader.hpp:346
Vector4< float > fvec4
A 4 components vector with float precision.
Definition: Vector4.hpp:279
StencilFunc * gocStencilFunc()
Definition: Shader.cpp:141
A simple String formatting class.
Definition: Say.hpp:124
RenderState wrapping the OpenGL function glPolygonOffset(), see also http://www.opengl.org/sdk/docs/man/xhtml/glPolygonOffset.xml for more information.
Definition: Shader.hpp:963
RenderState wrapping the OpenGL function glPolygonMode(), see also http://www.opengl.org/sdk/docs/man/xhtml/glPolygonMode.xml for more information.
Definition: Shader.hpp:527
TextureSampler * gocTextureSampler(int unit_index)
Definition: Shader.cpp:171
RenderState wrapping the OpenGL function glNormal(), see also http://www.opengl.org/sdk/docs/man/xhtm...
Definition: Shader.hpp:162
ETexParamFilter
void set(const unsigned char *mask)
Definition: Shader.cpp:600
RenderState wrapping the OpenGL function glLogicOp(), see also http://www.opengl.org/sdk/docs/man/xht...
Definition: Shader.hpp:1005
RenderState wrapping the OpenGL function glLightModel(), see also http://www.opengl.org/sdk/docs/man/xhtml/glLightModel.xml for more information.
Definition: Shader.hpp:859
ETextureDimension texUnitBinding(int unit_i) const
Returnes the texture target currently active for the specified texture unit. - For internal use only...
StencilOp * gocStencilOp()
Definition: Shader.cpp:143
RenderState wrapping the OpenGL function glBlendFunc(), see also http://www.opengl.org/sdk/docs/man/xhtml/glBlendFunc.xml for more information.
Definition: Shader.hpp:600
Represents an OpenGL context, possibly a widget or a pbuffer, which can also respond to keyboard...
void setTransparency(float alpha)
Definition: Shader.cpp:377
RenderState wrapping the OpenGL function glPolygonStipple(), see also http://www.opengl.org/sdk/docs/man/xhtml/glPolygonStipple.xml for more information.
Definition: Shader.hpp:1149
RenderState wrapping the OpenGL function glFrontFace(), see also http://www.opengl.org/sdk/docs/man/xhtml/glFrontFace.xml for more information.
Definition: Shader.hpp:428
RenderState * renderState(ERenderState type, int index=-1)
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
Definition: Log.cpp:165
RenderState wrapping the OpenGL function glShadeModel(), see also http://www.opengl.org/sdk/docs/man/xhtml/glShadeModel.xml for more information.
Definition: Shader.hpp:567
bool Has_Point_Sprite
Definition: OpenGL.cpp:98
LineStipple * gocLineStipple()
Definition: Shader.cpp:135
GLSLProgram * gocGLSLProgram()
Gets or creates a GLSLProgram and returns it.
Definition: Shader.cpp:89
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:181
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:963
Wraps a GLSL program to which you can bind vertex, fragment and geometry shaders. ...
Definition: GLSL.hpp:233
PixelTransfer * gocPixelTransfer()
Definition: Shader.cpp:91
Light * gocLight(int light_index)
Definition: Shader.cpp:159
RenderState wrapping the OpenGL function glDepthMask(), see also http://www.opengl.org/sdk/docs/man/xhtml/glDepthMask.xml for more information.
Definition: Shader.hpp:494
AlphaFunc * gocAlphaFunc()
Definition: Shader.cpp:117
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:581
bool Has_GL_Version_4_0
Definition: OpenGL.cpp:60
ClipPlane * gocClipPlane(int plane_index)
Definition: Shader.cpp:165
PointSize * gocPointSize()
Definition: Shader.cpp:133
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:427
TextureMatrix * gocTextureMatrix(int unit_index)
Definition: Shader.cpp:177
void setFrontTransparency(float alpha)
Definition: Shader.cpp:385
PolygonMode * gocPolygonMode()
Definition: Shader.cpp:111
void apply(ETextureDimension dimension, OpenGLContext *gl) const
Definition: Shader.cpp:776
PointParameter * gocPointParameter()
Definition: Shader.cpp:139
RenderState wrapping the OpenGL function glPixelTransfer(), see also http://www.opengl.org/sdk/docs/man/xhtml/glPixelTransfer.xml for more information.
Definition: Shader.hpp:196
bool Has_GL_Version_3_0
Definition: OpenGL.cpp:56
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:1087
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:724
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:1111
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:524
BlendColor * gocBlendColor()
Definition: Shader.cpp:147
TexGen()
The eye and object planes are not transformed by any matrix (unlike usually with OpenGL), which means that the object plane is specified in object coordinates and that, the eye plane is specified in camera coordinates.
Definition: Shader.cpp:946
const Light * getLight(int light_index) const
Definition: Shader.cpp:161
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:654
RenderState wrapping the OpenGL function glColor(), see also http://www.opengl.org/sdk/docs/man/xhtml...
Definition: Shader.hpp:94
The TextureMatrix class uses a 4x4 matrix to transform the texture coordinates of a texture unit...
Definition: Shader.hpp:1539
RenderState wrapping the OpenGL function glDepthRange(), see also http://www.opengl.org/sdk/docs/man/xhtml/glDepthRange.xml for more information.
Definition: Shader.hpp:1038
Visualization Library main namespace.
PolygonOffset * gocPolygonOffset()
Definition: Shader.cpp:125
BlendEquation * gocBlendEquation()
Definition: Shader.cpp:115
DepthRange * gocDepthRange()
Definition: Shader.cpp:129
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:708
SampleCoverage * gocSampleCoverage()
Definition: Shader.cpp:151
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:560
RenderState wrapping the OpenGL function glTexEnv(), see also http://www.opengl.org/sdk/docs/man/xhtm...
Definition: Shader.hpp:1589
RenderState wrapping the OpenGL function glBlendColor(), see also http://www.opengl.org/sdk/docs/man/xhtml/glBlendColor.xml for more information.
Definition: Shader.hpp:1455
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:541
DepthFunc * gocDepthFunc()
Definition: Shader.cpp:99
RenderState wrapping the OpenGL function glLineStipple(), see also http://www.opengl.org/sdk/docs/man/xhtml/glLineStipple.xml for more information.
Definition: Shader.hpp:1181
bool Has_GLES_Version_2_0
Definition: OpenGL.cpp:68
FrontFace * gocFrontFace()
Definition: Shader.cpp:97
static void bug(const String &message)
Use this function to provide information about programming errors: wrong parameter initialization...
Definition: Log.cpp:175
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:279
#define VL_TRAP()
Definition: checks.hpp:70
Wraps the OpenGL function glClipPlane().
Definition: ClipPlane.hpp:49
bool Has_GL_Version_1_3
Definition: OpenGL.cpp:51
RenderState wrapping the OpenGL function glColorMask(), see also http://www.opengl.org/sdk/docs/man/xhtml/glColorMask.xml for more information.
Definition: Shader.hpp:1488
RenderState wrapping the OpenGL function glVertexAttrib(), see also http://www.opengl.org/sdk/docs/man3/xhtml/glVertexAttrib.xml for more information.
Definition: Shader.hpp:60
Not supported under OpenGL ES 1.x.
float min(float a, float b)
Definition: Vector2.hpp:307
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:272
The TextureSampler class associates a Texture object to an OpenGL texture unit.
Definition: Shader.hpp:1747
const mat4 & modelingMatrix() const
Returns the Camera&#39;s modelingMatrix() (inverse of the view matrix).
Definition: Camera.hpp:169
bool Has_GL_GENERATE_MIPMAP
Definition: OpenGL.cpp:97
Shader()
Constructor.
Definition: Shader.cpp:45
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:251
RenderState wrapping the OpenGL function glTexGen(), see also http://www.opengl.org/sdk/docs/man/xhtm...
Definition: Shader.hpp:1682
RenderState wrapping the OpenGL function glLineWidth(), see also http://www.opengl.org/sdk/docs/man/xhtml/glLineWidth.xml for more information.
Definition: Shader.hpp:1083
LightModel * gocLightModel()
Definition: Shader.cpp:121
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:553
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:605
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:619
bool Has_GLES
Definition: OpenGL.cpp:69
Wraps the OpenGL functions glStencilFunc() and glStencilFuncSeparate(), see also http://www.opengl.org/sdk/docs/man/xhtml/glStencilFunc.xml and http://www.opengl.org/sdk/docs/man/xhtml/glStencilFuncSeparate.xml for more information.
Definition: Shader.hpp:1279
#define NULL
Definition: OpenGLDefs.hpp:81
real mLastUpdateTime
Definition: Shader.hpp:2351
RenderState wrapping the OpenGL function glBlendEquation()/glBlendEquationSeparate(), see also http://www.opengl.org/sdk/docs/man/xhtml/glBlendEquation.xml and http://www.opengl.org/sdk/docs/man/xhtml/glBlendEquationSeparate.xml for more information.
Definition: Shader.hpp:657
RenderState wrapping the OpenGL function glMaterial() and glColorMaterial(), see also http://www...
Definition: Shader.hpp:774
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:326
void setBackFlatColor(const fvec4 &color)
Definition: Shader.cpp:411
const GLSLProgram * getGLSLProgram() const
Returns a GLSLProgram if it exists or NULL otherwise.
Definition: Shader.cpp:59
ETextureDimension
#define GET_OR_CREATE_IDX(RS, index)
Definition: Shader.cpp:80
VertexAttrib * gocVertexAttrib(int attr_index)
Definition: Shader.cpp:153
RenderState wrapping the OpenGL function glPointSize(), see also http://www.opengl.org/sdk/docs/man/xhtml/glPointSize.xml for more information.
Definition: Shader.hpp:1116
#define VL_CHECK_OGL()
Definition: OpenGL.hpp:156
void multiplyTransparency(float alpha)
Definition: Shader.cpp:365
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:669
const std::string & objectName() const
The name of the object, by default set to the object&#39;s class name.
Definition: Object.hpp:217
virtual ~Shader()
Destructor.
Definition: Shader.cpp:55
ColorMask * gocColorMask()
Definition: Shader.cpp:109
const VertexAttrib * getVertexAttrib(int attr_index) const
Definition: Shader.cpp:155
RenderStateSet * getRenderStateSet()
Definition: Shader.hpp:2235
RenderState wrapping the OpenGL function glAlphaFunc(), see also http://www.opengl.org/sdk/docs/man/xhtml/glAlphaFunc.xml for more information.
Definition: Shader.hpp:737
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:295
bool Has_GL_Version_2_0
Definition: OpenGL.cpp:54
TexGen * gocTexGen(int unit_index)
Definition: Shader.cpp:173
BlendFunc * gocBlendFunc()
Definition: Shader.cpp:149
void setFrontFlatColor(const fvec4 &color)
Definition: Shader.cpp:401
fvec4 mVertexAttribValue[VA_MaxAttribCount]
Wraps the OpenGL function glLight().
Definition: Light.hpp:51
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:222
LogicOp * gocLogicOp()
Definition: Shader.cpp:127
bool Has_Fixed_Function_Pipeline
OpenGL: true if !Is_OpenGL_Forward_Compatible && !Is_OpenGL_Core_Profile OpenGL ES 1: always true Ope...
Definition: OpenGL.cpp:63
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:302
void setTexUnitBinding(int unit_i, ETextureDimension target)
Declares that texture unit unit_i is currently bound to the specified texture target. - For internal use only.
ShadeModel * gocShadeModel()
Definition: Shader.cpp:113
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:716
void setFlatColor(const fvec4 &color)
Definition: Shader.cpp:421
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
Definition: Camera.hpp:50
bool Has_GL_Version_1_2
Definition: OpenGL.cpp:50
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:684
RenderState wrapping the OpenGL function glStencilMask() and glStencilMaskSeparate(), see also http://www.opengl.org/sdk/docs/man/xhtml/glStencilMask.xml and http://www.opengl.org/sdk/docs/man/xhtml/glStencilMaskSeparate.xml for more information.
Definition: Shader.hpp:1413
Matrix4 as3x3() const
Definition: Matrix4.hpp:310
Fog * gocFog()
Definition: Shader.cpp:123
Not supported under OpenGL ES 1.x.
void setMagFilter(ETexParamFilter magfilter)
Definition: Shader.cpp:754
SecondaryColor * gocSecondaryColor()
Definition: Shader.cpp:105
TexEnv * gocTexEnv(int unit_index)
Definition: Shader.cpp:175
#define VL_CHECK(expr)
Definition: checks.hpp:73
DepthMask * gocDepthMask()
Definition: Shader.cpp:101
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:639
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:691
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:731
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:258
bool Has_Texture_3D
Definition: OpenGL.cpp:91
void setBackTransparency(float alpha)
Definition: Shader.cpp:393
virtual void apply(int index, const Camera *, OpenGLContext *ctx) const
The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it...
Definition: Shader.cpp:883
RenderState wrapping the OpenGL function glFog(), see also http://www.opengl.org/sdk/docs/man/xhtml/g...
Definition: Shader.hpp:907
PolygonStipple * gocPolygonStipple()
Definition: Shader.cpp:137
const ClipPlane * getClipPlane(int plane_index) const
Definition: Shader.cpp:167
RenderState wrapping the OpenGL function glSecondaryColor(), see also http://www.opengl.org/sdk/docs/man/xhtml/glSecondaryColor.xml for more information.
Definition: Shader.hpp:128
const T_Scalar & a() const
Definition: Vector4.hpp:114
StencilMask * gocStencilMask()
Definition: Shader.cpp:145
RenderState wrapping the OpenGL function glSampleCoverage(), see also http://www.opengl.org/sdk/docs/man/xhtml/glSampleCoverage.xml for more information.
Definition: Shader.hpp:697
RenderState wrapping the OpenGL function glCullFace(), see also http://www.opengl.org/sdk/docs/man/xhtml/glCullFace.xml for more information.
Definition: Shader.hpp:395