1 #include <Base/Common/W32Compat.hh>
2 #include "GeometryGL.hh"
7 #include <Base/Debug/DebugSimple.hh>
8 #include <Base/Debug/TimeMeasure.hh>
9 #include <Base/Math/Vector2.hh>
10 #include <Base/Math/Vector3.hh>
11 #include <Base/Math/Matrix3x3.hh>
12 #include <Base/Math/Matrix3x4.hh>
13 #include <Geometry/RMatrix.hh>
14 #include <Geometry/PMatrix.hh>
16 #include <Base/Image/ImageBase.hh>
21 #define GL2Cbool(arg) (unsigned int)(arg)<< (arg?" (true)":" (false)")
39 GLfloat modelviewMatrix[16];
40 glGetFloatv(GL_MODELVIEW_MATRIX, &modelviewMatrix[0]);
41 GLfloat projectionMatrix[16];
42 glGetFloatv(GL_PROJECTION_MATRIX, &projectionMatrix[0]);
43 GLfloat textureMatrix0[16];
44 glGetFloatv(GL_TEXTURE_MATRIX, &textureMatrix0[0]);
47 os <<
"GL_MODELVIEW_MATRIX = (column-major!)"<<endl;
48 for (row=0; row<4; row++) {
49 os<<std::setprecision(10)<<modelviewMatrix[row+ 0]<<
" \t";
50 os<<std::setprecision(10)<<modelviewMatrix[row+ 4]<<
" \t";
51 os<<std::setprecision(10)<<modelviewMatrix[row+ 8]<<
" \t";
52 os<<std::setprecision(10)<<modelviewMatrix[row+12];
55 os <<
"GL_PROJECTION_MATRIX = (column-major!) "<<endl;
56 for (row=0; row<4; row++) {
57 os<<std::setprecision(10)<<projectionMatrix[row+ 0]<<
" \t";
58 os<<std::setprecision(10)<<projectionMatrix[row+ 4]<<
" \t";
59 os<<std::setprecision(10)<<projectionMatrix[row+ 8]<<
" \t";
60 os<<std::setprecision(10)<<projectionMatrix[row+12];
63 os <<
"GL_TEXTURE_MATRIX = (column-major!) "<<endl;
64 for (row=0; row<4; row++) {
65 os<<std::setprecision(10)<<textureMatrix0[row+ 0]<<
" \t";
66 os<<std::setprecision(10)<<textureMatrix0[row+ 4]<<
" \t";
67 os<<std::setprecision(10)<<textureMatrix0[row+ 8]<<
" \t";
68 os<<std::setprecision(10)<<textureMatrix0[row+12];
80 for (i=0; i<MAX_GL_DISPLIST_ID; i++)
82 if(glIsList(i) == GL_TRUE)
85 os<<
"valid displaylistID="<<i<<endl;
88 os<<
"** found a total of "<<foundDisplists<<
" valid display lists/IDs <MAX_GL_DISPLIST_ID="<<MAX_GL_DISPLIST_ID<<
" **"<<endl;
95 const bool & noOutputIfInvalid)
97 if (!glIsTexture(
id)) {
98 if (!noOutputIfInvalid)
99 os<<
"texid="<<
id<<
" invalid."<<endl;
104 GLint target=GL_TEXTURE_2D;
105 GLint resident=GL_FALSE;
107 GLint width=0, height=0;
108 GLint min_tex=0, mag_tex=0;
112 GLint components=0, red=0, green=0, blue=0, alpha=0;
115 glBindTexture(GL_TEXTURE_2D,
id );
116 glGetIntegerv(GL_TEXTURE_2D, &tex_state);
118 glGetTexParameteriv(target, GL_TEXTURE_WIDTH, &width);
119 glGetTexParameteriv(target, GL_TEXTURE_HEIGHT, &height);
120 glGetTexParameteriv(target, GL_TEXTURE_INTERNAL_FORMAT, &int_fmt);
121 glGetTexParameteriv(target, GL_TEXTURE_COMPONENTS, &components );
122 glGetTexParameteriv(target, GL_TEXTURE_RED_SIZE, &red);
123 glGetTexParameteriv(target, GL_TEXTURE_GREEN_SIZE, &green);
124 glGetTexParameteriv(target, GL_TEXTURE_BLUE_SIZE, &blue);
125 glGetTexParameteriv(target, GL_TEXTURE_ALPHA_SIZE, &alpha);
127 glGetTexParameteriv(target, GL_TEXTURE_MAG_FILTER, &mag_tex);
128 glGetTexParameteriv(target, GL_TEXTURE_MIN_FILTER, &min_tex);
129 glGetTexParameteriv(target, GL_TEXTURE_RESIDENT, &resident);
130 glGetTexParameterfv(target, GL_TEXTURE_PRIORITY, &priority);
132 glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &tex_env);
135 os<<
"valid texID="<<
id<<
" : "<<endl;
136 os<<
"\tminifiction filter = "<<GetName(min_tex)<<endl;
137 os<<
"\tmagnifictaion filter = "<<GetName(mag_tex)<<endl;
139 os<<
"\tdim "<<width<<
" x "<<height<<endl;
140 os<<
"\tcomponents "<<components<<endl;
141 os<<
"\ttex red bits "<<red<<endl;
142 os<<
"\ttex green bits "<<green<<endl;
143 os<<
"\ttex blue bits "<<blue<<endl;
144 os<<
"\ttex alpha bits "<<alpha<<endl;
146 os<<
"\tinternal_fmt="<<GetName(int_fmt)<<endl;
147 os<<
"\ttex_state ="<<GetName(tex_state)<<endl;
148 os<<
"\ttex_env ="<<GetName(tex_env)<<endl;
149 os<<
"\tresident="<<GetName(resident)<<
" priority="<<(float)priority<<endl;
150 const unsigned int maxLevels=(
unsigned int)(log((
float)max(width,height))/log(2.0f));
151 for (
int level=-1*(
int)(maxLevels); level<=(int)maxLevels; level++){
153 glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
154 glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
156 if ((width!=0) || (height!=0))
159 os<<
"\t"<<level<<
". level dim: "<<width<<
"x"<<height<<endl;
168 for (
unsigned int id=0;
id<MAX_GL_TEXOBJ_ID;
id++)
170 GetInfoGLTexID(
id, foundTextures, os);
172 os<<
"** found a total of "<<foundTextures<<
" validtextures/IDs <MAX_GL_TEXOBJ_ID="<<MAX_GL_TEXOBJ_ID<<
" **"<<endl;
180 if ( NULL==(
char *) glGetString(GL_VENDOR)) {
181 BIASERR(
"No Context available (NULL ptr). Skipping RenderGL::GetInfo."<<endl<<flush);;
185 #ifdef BIAS_HAVE_GLEW
186 string strGlewVersion = (
char*) glewGetString(GLEW_VERSION);
187 #endif // BIAS_HAVE_GLEW
188 string strVendor = (
char *) glGetString(GL_VENDOR);
189 string strRenderer = (
char *) glGetString(GL_RENDERER);
190 string strVersion = (
char *) glGetString(GL_VERSION);
191 string strExtensions = (
char *) glGetString(GL_EXTENSIONS);
194 unsigned int index = 0;
195 while ((index = strExtensions.find(
' ', index)) != string::npos)
196 strExtensions[index++] =
'\n';
199 string strWglExtensions;
201 # ifdef BIAS_HAVE_GLEW
202 if (WGLEW_EXT_extensions_string)
204 strWglExtensions = (
char*) wglGetExtensionsStringEXT();
208 while ((index = strWglExtensions.find(
' ', index)) != string::npos)
209 strWglExtensions[index++]=
'\n';
211 # endif // BIAS_HAVE_GLEW
214 GLint max_texture_units=0;
215 #if defined(BIAS_HAVE_GLEW)
216 glGetIntegerv(GL_MAX_TEXTURE_UNITS, &max_texture_units);
220 GLint max_texture_image_units=0;
221 #ifdef BIAS_HAVE_GLEW
222 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &max_texture_image_units);
223 #endif // BIAS_HAVE_GLEW
239 glGetIntegerv(GL_RED_BITS, &red_bits);
241 glGetIntegerv(GL_GREEN_BITS, &green_bits);
243 glGetIntegerv(GL_BLUE_BITS, &blue_bits);
245 glGetIntegerv(GL_ALPHA_BITS, &alpha_bits);
247 glGetFloatv(GL_ALPHA_BIAS, &alpha_bias);
249 glGetFloatv(GL_ALPHA_SCALE, &alpha_scale);
251 glGetBooleanv(GL_CULL_FACE, &cull_face);
253 glGetFloatv(GL_DEPTH_SCALE, &depth_scale);
255 glGetIntegerv(GL_DEPTH_BITS, &depth_bits);
257 glGetFloatv(GL_DEPTH_BIAS, &depth_bias);
258 GLfloat depth_range[2];
259 glGetFloatv(GL_DEPTH_BIAS, &depth_range[0]);
260 GLfloat depth_clear_value;
261 glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depth_clear_value);
263 glGetBooleanv(GL_FOG, &fog);
265 glGetFloatv(GL_LINE_WIDTH, &line_width);
267 glGetBooleanv(GL_LIGHTING, &lighting);
268 GLint max_modelview_stack_depth;
269 glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &max_modelview_stack_depth);
270 GLint max_projection_stack_depth;
271 glGetIntegerv(GL_MAX_PROJECTION_STACK_DEPTH, &max_projection_stack_depth);
272 GLint max_texture_stack_depth;
273 glGetIntegerv(GL_MAX_TEXTURE_STACK_DEPTH, &max_texture_stack_depth);
274 GLint max_texture_size;
275 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
276 GLint max_viewport_dims[2];
277 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_viewport_dims[0]);
278 GLint name_stack_depth;
279 glGetIntegerv(GL_NAME_STACK_DEPTH, &name_stack_depth);
280 GLint max_name_stack_depth;
281 glGetIntegerv(GL_MAX_NAME_STACK_DEPTH, &max_name_stack_depth);
283 glGetIntegerv(GL_POINT_SIZE, &point_size);
284 GLint point_size_range[2];
285 glGetIntegerv(GL_POINT_SIZE_RANGE, &point_size_range[0]);
287 glGetBooleanv(GL_RGBA_MODE, &rgba_mode);
288 GLboolean stencil_test;
289 glGetBooleanv(GL_STENCIL_TEST, &stencil_test);
291 glGetIntegerv(GL_STENCIL_BITS, &stencil_bits);
294 glGetIntegerv(GL_DRAW_BUFFER, &draw_buffer);
296 glGetIntegerv(GL_AUX_BUFFERS, &aux_buffers);
297 GLboolean double_buffer;
298 glGetBooleanv(GL_DOUBLEBUFFER, &double_buffer);
300 glGetBooleanv(GL_STEREO, &stereo);
301 GLint polygon_mode[2];
302 glGetIntegerv(GL_POLYGON_MODE, &polygon_mode[0]);
303 GLint max_cube_map_texture_size=0;
304 #if defined(BIAS_HAVE_GLEW)
305 glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT, &max_cube_map_texture_size);
309 glGetIntegerv(GL_VIEWPORT, &viewport[0]);
312 GLint max_texture_lod_bias=0;
313 #if defined(BIAS_HAVE_GLEW)
314 glGetIntegerv(GL_MAX_TEXTURE_LOD_BIAS_EXT, &max_texture_lod_bias);
319 os <<
"Getting Info about OpenGL: " << endl;
320 #ifdef BIAS_HAVE_GLEW
321 os <<
"GLEW_VERSION = " << strGlewVersion << endl;
322 #endif // BIAS_HAVE_GLEW
323 os <<
"GL_VENDOR = " << strVendor << endl;
324 os <<
"GL_RENDERER = " << strRenderer << endl;
325 os <<
"GL_VERSION = " << strVersion << endl;
326 os <<
"* GL_EXTENSIONS: " << endl << strExtensions << endl;
327 os <<
"* WGL_EXTENSIONS: " << endl << strWglExtensions << endl;
331 os<<
"GL_RED_BITS = "<<red_bits<<endl;
332 os<<
"GL_GREEN_BITS= "<<green_bits<<endl;
333 os<<
"GL_BLUE_BITS = "<<blue_bits<<endl;
334 os<<
"GL_ALPHA_BITS= "<<alpha_bits<<endl;
335 os<<
"GL_DEPTH_BITS ="<<depth_bits<<endl;
336 os<<
"GL_STENCIL_BITS="<<stencil_bits<< endl;
338 os <<
"GL_MAX_TEXTURE_UNITS= "<<max_texture_units<<
" (detected texture units)" << endl;
339 os <<
"GL_MAX_TEXTURE_IMAGE_UNITS= " << max_texture_image_units <<endl;
345 os <<
"GL_ALPHA_SCALE = " << alpha_scale << endl;
346 os <<
"GL_ALPHA_BIAS = " << alpha_bias << endl;
347 os <<
"GL_CULL_FACE = " << GL2Cbool(cull_face) << endl;
348 os <<
"GL_STENCIL_TEST = " << GL2Cbool(stencil_test) << endl;
349 os <<
"GL_DEPTH_SCALE = " << depth_scale << endl;
350 os <<
"GL_DEPTH_BIAS = " << depth_bias << endl;
351 os <<
"GL_DEPTH_RANGE = " << depth_range[0] <<
" " <<depth_range[1] << endl;
352 os <<
"GL_DEPTH_CLEAR_VALUE= " << depth_clear_value << endl;
353 os <<
"GL_DRAW_BUFFER = " << GetName(draw_buffer)<<endl;
354 os <<
"GL_AUX_BUFFERS = " << aux_buffers <<endl;
355 os <<
"GL_DOUBLE_BUFFER = " << GL2Cbool(double_buffer)<<endl;
356 os <<
"GL_STEREO = " << GL2Cbool(stereo);
357 if (stereo) os<<
" (but not neccessarily enabled)"<<endl;
359 os <<
"GL_FOG = " << GL2Cbool(fog) << endl;
360 os <<
"GL_LINE_WIDTH = " << line_width << endl;
361 os <<
"GL_LIGHTING = " << GL2Cbool(lighting) << endl;
362 os <<
"GL_MAX_MODELVIEW_STACK_DEPTH = " <<max_modelview_stack_depth << endl;
363 os <<
"GL_MAX_PROJECTION_STACK_DEPTH= " <<max_projection_stack_depth << endl;
364 os <<
"GL_MAX_TEXTURE_LOD_BIAS_EXT = " << max_texture_lod_bias << endl;
365 os <<
"GL_MAX_TEXTURE_STACK_DEPTH = " << max_texture_stack_depth<< endl;
366 os <<
"GL_MAX_TEXTURE_SIZE = " << max_texture_size << endl;
367 os <<
"GL_MAX_VIEWPORT_DIMS= " << max_viewport_dims[0]
368 <<
" "<<max_viewport_dims[1] << endl;
369 os <<
"GL_POINT_SIZE = " << point_size << endl;
370 os <<
"GL_POINT_SIZE_RANGE = " << point_size_range[0]
371 <<
" "<<point_size_range[1] << endl;
373 os <<
"GL_MAX_CUBE_MAP_TEXTURE_SIZE="<<max_cube_map_texture_size<<endl;
375 os <<
"GL_MAX_NAME_STACK_DEPTH = " << max_name_stack_depth<<endl;
376 os <<
"GL_NAME_STACK_DEPTH = " << name_stack_depth<<endl;
378 os <<
"GL_POLYGON_MODE = ("<<GetName(polygon_mode[0])<<
", "<<GetName(polygon_mode[1])<<
")"<<endl;
379 os <<
"GL_RGBA_MODE = " << GL2Cbool(rgba_mode) << endl;
380 os <<
"GL_VIEWPORT = x="<<viewport[0]<<
" y="<<viewport[1]<<
" w="<<viewport[2]<<
" h="<<viewport[3]<<endl;
387 GLboolean depth_writemask;
388 glGetBooleanv(GL_DEPTH_WRITEMASK, &depth_writemask);
390 GLboolean color_writemask[4] = {
false,
false,
false,
false};
391 glGetBooleanv(GL_COLOR_WRITEMASK, color_writemask);
393 GLboolean stencil_writemask;
394 glGetBooleanv(GL_STENCIL_WRITEMASK, &stencil_writemask);
396 GLboolean index_writemask;
397 glGetBooleanv(GL_INDEX_WRITEMASK, &index_writemask);
399 os<<
"GL_DEPTH_WRITEMASK = "<<depth_writemask<<endl;
400 os<<
"GL_COLOR_WRITEMASK = "
401 <<color_writemask[0]<<
" "
402 <<color_writemask[1]<<
" "
403 <<color_writemask[2]<<
" "
404 <<color_writemask[3]<<
" "
406 os<<
"GL_STENCIL_WRITEMASK = "<<stencil_writemask<<endl;
407 os<<
"GL_INDEX_WRITEMASK = "<<index_writemask<<endl;
413 GetInfoGLenvironment(os);
414 GetInfoGLWriteMasks(os);
415 GetInfoGLmatrices(os);
416 GetInfoGLDisplayLists(os);
417 GetInfoGLTexObjects(os);
429 glClearColor(0, 0, 0, 0);
431 glClearAccum(0,0,0,0);
435 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
442 glDisable(GL_ALPHA_TEST);
443 glDisable(GL_LIGHTING);
447 glDisable(GL_CULL_FACE);
449 glDisable(GL_NORMALIZE);
452 glEnable(GL_DEPTH_TEST);
456 glDisable(GL_STENCIL_TEST);
459 glDisable(GL_TEXTURE_2D);
463 glDepthFunc(GL_LEQUAL);
464 glAlphaFunc(GL_LEQUAL, (GLclampf)1 );
467 glMatrixMode(GL_PROJECTION);
469 glMatrixMode(GL_TEXTURE);
471 glMatrixMode(GL_MODELVIEW);
486 glEnable(GL_CULL_FACE);
489 glEnable(GL_CULL_FACE);
491 glDisable(GL_CULL_FACE);
512 DisplaySceneExampleSimple();
520 glDisable(GL_LIGHTING);
521 glEnable(GL_DEPTH_TEST);
522 glShadeModel(GL_SMOOTH);
524 const float z = 1.0f;
525 const float xd= 0.9f;
526 const float yd= 0.9f;
538 glVertex3fv( &(p0[0]));
541 glVertex3fv( &(p1[0]));
544 glVertex3fv( &(p2[0]));
547 glVertex3fv( &(p3[0]));
555 #ifdef BIAS_HAVE_FONTGL
557 const float & linewidth,
559 const std::string & LabelX,
560 const std::string & LabelY,
561 const std::string & LabelZ )
563 DisplayCoordCrossAxesLabel(size, font, LabelX, LabelY, LabelZ);
564 DisplayCoordCross(size, linewidth);
570 const std::string & LabelX,
571 const std::string & LabelY,
572 const std::string & LabelZ )
575 BIASERR(
"font not initialized. Please do it on your OpenGLCanvas (because of the context). aborting");
596 #endif //BIAS_HAVE_FONTGL
599 const float & linewidth )
603 glDisable(GL_TEXTURE_2D);
604 glDisable(GL_LIGHTING);
606 if ((linewidth>=1.0) && (linewidth<32.0))
607 glLineWidth((GLfloat)linewidth);
609 glLineWidth((GLfloat)1.0);
611 glColor4f(1,0,0, VISIBLEALPHA);
614 glVertex3f(size,0,0);
617 glColor4f(0,1,0, VISIBLEALPHA);
620 glVertex3f(0,size,0);
623 glColor4f(0,0,1, VISIBLEALPHA);
626 glVertex3f(0,0,size);
636 const unsigned int & width,
637 const unsigned int & height,
642 BIASASSERT(width>=0);
643 BIASASSERT(height>=0);
644 BIASASSERT(fovY>0.0);
645 BIASASSERT(fovY<180.0);
647 glMatrixMode(GL_PROJECTION);
651 if ((height==0) || (width==0)) {
655 aspect = (float)width/(
float)height;
663 glViewport((GLint)x0, (GLint)y0,
664 (GLsizei)width, (GLsizei)height);
686 glMatrixMode(GL_MODELVIEW);
688 gluLookAt((GLdouble)C[0],
703 ,
const unsigned int & h
704 ,
const unsigned int & corner
711 #if defined(BIAS_HAVE_GLEW)
712 if (texMode==GL_TEXTURE_RECTANGLE_NV)
730 BIASASSERT(0<height);
740 if (flipY)
return Vector2<double>(width, height);
741 return Vector2<double>(width, 0.0);
744 if (flipY)
return Vector2<double>(width, 0.0);
745 return Vector2<double>(width, height);
748 if (flipY)
return Vector2<double>(0.0, 0.0);
749 return Vector2<double>(0.0, height);
752 BIASERR(
"corner="<<corner<<
" invalid."<<endl);
753 return Vector2<double>(0.0, 0.0);
762 ,
const unsigned int & w
763 ,
const unsigned int & h
764 ,
const unsigned int & corner
765 ,
const double & scale )
791 BIASERR(
"corner="<<corner<<
" invalid."<<endl);
798 p3d = P.
GetC() + scale * dir;
805 ,
const unsigned int & w
806 ,
const unsigned int & h
808 ,
const int & texTarget
809 ,
const double & scale
814 BIASASSERT( GL_TRUE == glIsTexture( texID ) );
815 glEnable( texTarget );
816 glBindTexture(texTarget, texID );
818 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
823 glColor4fv( & vertexColor[0] );
825 glTexCoord2dv( & GetImgCorner2d(w,h,
LOWER_LEFT, texTarget, flipY)[0] );
826 glVertex3dv( & GetImgCorner3d(P,w,h,
LOWER_LEFT, scale)[0]);
828 glTexCoord2dv( & GetImgCorner2d(w,h,
LOWER_RIGHT, texTarget, flipY)[0] );
829 glVertex3dv( & GetImgCorner3d(P,w,h,
LOWER_RIGHT, scale)[0] );
831 glTexCoord2dv( & GetImgCorner2d(w,h,
UPPER_RIGHT, texTarget, flipY)[0] );
832 glVertex3dv( & GetImgCorner3d(P,w,h,
UPPER_RIGHT, scale)[0] );
834 glTexCoord2dv( & GetImgCorner2d(w,h,
UPPER_LEFT, texTarget, flipY)[0] );
835 glVertex3dv( & GetImgCorner3d(P,w,h,
UPPER_LEFT, scale)[0] );
843 ,
const unsigned int & w
844 ,
const unsigned int & h
845 ,
const double & scale
846 ,
const float & linewidth
852 const float alpha = VISIBLEALPHA;
857 glDisable(GL_TEXTURE_2D);
858 glLineWidth(linewidth);
861 glBegin(GL_LINE_LOOP);
862 glColor4f(0,1,0, alpha);
863 glVertex4d( GetImgCorner3d(P,w,h,
LOWER_LEFT, scale)[0],
870 glVertex3dv( & GetImgCorner3d(P,w,h,
LOWER_RIGHT,scale)[0] );
871 glVertex3dv( & GetImgCorner3d(P,w,h,
UPPER_RIGHT,scale)[0] );
872 glVertex3dv( & GetImgCorner3d(P,w,h,
UPPER_LEFT, scale)[0] );
877 glColor4f(1,0,0, alpha);
878 glVertex3dv( & C[0] );
879 glColor4f(0,0,1, alpha);
883 glColor4f(0,1,0, alpha);
884 glVertex3dv( & GetImgCorner3d(P,w,h,
LOWER_LEFT, scale)[0] );
885 glColor4f(1,0,0, alpha);
886 glVertex3dv( & C[0] );
888 glColor4f(0,1,0, alpha);
889 glVertex3dv( & GetImgCorner3d(P,w,h,
LOWER_RIGHT, scale)[0] );
890 glColor4f(1,0,0, alpha);
891 glVertex3dv( & C[0] );
893 glColor4f(0,1,0, alpha);
894 glVertex3dv( & GetImgCorner3d(P,w,h,
UPPER_LEFT, scale)[0] );
895 glColor4f(1,0,0, alpha);
896 glVertex3dv( & C[0] );
898 glColor4f(0,1,0, alpha);
899 glVertex3dv( & GetImgCorner3d(P,w,h,
UPPER_RIGHT, scale)[0] );
900 glColor4f(1,0,0, alpha);
901 glVertex3dv( & C[0] );
909 ,
const unsigned int w
910 ,
const unsigned int h
911 ,
const bool & useRECTcoord )
926 if (!useRECTcoord ) {
941 for (
int s=0; s<4; s++) {
942 result[0][s] = newP[0][s];
943 result[1][s] = newP[1][s];
945 result[3][s] = newP[2][s];
949 result /= result[3][3];
957 const bool & additionalFlipY)
959 glMatrixMode(GL_MODELVIEW);
963 glMatrixMode(GL_PROJECTION);
967 DisplayQuadTexCoord2D(texobj, additionalFlipY);
969 glMatrixMode(GL_PROJECTION);
972 glMatrixMode(GL_MODELVIEW);
977 const bool & additionalFlipY)
982 BIASASSERT(glIsTexture(texobj.
id));
1008 if (!additionalFlipY) {
1011 tc1.
Set( width, 0 );
1012 tc2.
Set( width, height);
1013 tc3.
Set( 0, height);
1016 tc0.
Set(0, height );
1017 tc1.
Set( width, height );
1025 #ifdef BIAS_HAVE_GLEW
1026 glActiveTexture( GL_TEXTURE0 );
1027 #endif // BIAS_HAVE_GLEW
1029 glEnable( texobj.
target );
1030 glBindTexture(texobj.
target, texobj.
id );
1031 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
1041 #ifdef BIAS_HAVE_GLEW
1043 const unsigned int maxTU=4;
1045 #endif // BIAS_HAVE_GLEW
1048 glTexCoord2fv( &tc0[0] );
1049 #ifdef BIAS_HAVE_GLEW
1050 for (i=0; i<maxTU;i++)
1051 glMultiTexCoord2fv(GL_TEXTURE0+i, &tc0[0]);
1052 #endif // BIAS_HAVE_GLEW
1053 glVertex3f(-1,-1, z);
1054 glTexCoord2fv(&tc1[0]);
1055 #ifdef BIAS_HAVE_GLEW
1056 for (i=0; i<maxTU;i++)
1057 glMultiTexCoord2fv(GL_TEXTURE0+i, &tc1[0]);
1058 #endif // BIAS_HAVE_GLEW
1059 glVertex3f( 1,-1, z);
1060 glTexCoord2fv(&tc2[0]);
1061 #ifdef BIAS_HAVE_GLEW
1062 for (i=0; i<maxTU;i++)
1063 glMultiTexCoord2fv(GL_TEXTURE0+i, &tc2[0]);
1064 #endif // BIAS_HAVE_GLEW
1065 glVertex3f( 1, 1, z);
1066 glTexCoord2fv(&tc3[0]);
1067 #ifdef BIAS_HAVE_GLEW
1068 for (i=0; i<maxTU;i++)
1069 glMultiTexCoord2fv(GL_TEXTURE0+i, &tc3[0]);
1070 #endif // BIAS_HAVE_GLEW
1071 glVertex3f(-1, 1, z);
1075 glDisable( texobj.
target );
1083 #ifndef BIAS_HAVE_GLUT
1084 BIASERR(
"not implemented without glut, please recompile BIAS with USE_GLUT to see a a fancy dispal ylist scene !");
1086 #else // BIAS_HAVE_GLUT
1089 static bool initDone=
false;
1096 dplistID = glGenLists(1);
1097 glNewList(dplistID, GL_COMPILE );
1101 GLfloat light_position0[] = {10.0f, 10.0, 10.0f, 0.0f};
1102 GLfloat light_maincolor0[] = {1.0f, 1.0, 1.0f, 1.0f};
1103 GLfloat light_ambientcolor0[] = {0.4f, 0.2f, 0.2f, 1.0f};
1106 glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
1107 glLightfv(GL_LIGHT0, GL_DIFFUSE, light_maincolor0);
1108 glLightfv(GL_LIGHT0, GL_SPECULAR, light_maincolor0);
1109 glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambientcolor0);
1111 glEnable(GL_LIGHT0);
1112 glEnable(GL_LIGHTING);
1113 glEnable(GL_DEPTH_TEST);
1116 GLfloat paintcolor0[] = { 0.9, 0.2, 0.5, 1.0};
1117 GLfloat specularcolor0[] = { 1.0, 1.0, 1.0, 1.0};
1118 GLfloat shininess0[] = { 70. };
1120 GLfloat paintcolor1[] = { 0.3, 0.9, 0.4, 1.0};
1121 GLfloat paintcolor2[] = { 0.1, 0.2, 0.9, 0.5};
1122 GLfloat paintcolor3[] = { 0.5, 0.0, 0.5, 1.0};
1124 glMatrixMode(GL_MODELVIEW);
1128 glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, specularcolor0);
1129 glMaterialfv( GL_FRONT_AND_BACK, GL_SHININESS, shininess0);
1130 glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE,
1132 glColor4fv(paintcolor0);
1137 glTranslatef( dtea[0], dtea[1], dtea[2] );
1140 glutSolidTeapot(0.6);
1141 glFrontFace(GL_CCW);
1143 glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE,
1145 glColor4fv(paintcolor1);
1147 glTranslatef( -2*dtea[0], -2*dtea[1], -2*dtea[2] );
1149 glutSolidTeapot(0.3);
1150 glFrontFace(GL_CCW);
1151 glTranslatef( dtea[0], dtea[1], dtea[2] );
1155 glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, paintcolor2);
1156 glColor4fv(paintcolor2);
1158 glTranslatef(0,0,-2);
1159 glutSolidSphere(0.8, 30, 60);
1160 glTranslatef(0,0, 2);
1162 glTranslatef( 1,0,-3);
1163 glutSolidSphere(0.5, 50, 100);
1164 glTranslatef(-1,0, 3);
1167 glTranslatef(0,2,0);
1169 glTranslatef(0,-2,0);
1171 glTranslatef(0,-1,0);
1172 glutSolidIcosahedron();
1173 glTranslatef(0, 1,0);
1175 glTranslatef(0,-2.2,0);
1176 glutSolidTetrahedron();
1177 glTranslatef(0, 2.2,0);
1180 glColor4fv( paintcolor3 );
1181 glutSolidSphere(75.0, 50, 100);
1189 #endif // BIAS_HAVE_GLUT
1197 static int dplist = -1;
1205 if(glIsList(dplist) == GL_TRUE)
1210 const float cycletime=10.0;
1211 const float angleM = fmodf(
float(2.0*360.0/cycletime *curTime), 2.0*360.0);
1213 glRotatef( angleM, 0.0f, 1.0f, 0.0f );
1215 glRotatef( angleM-360.0f, 1.0f, 0.0f, 0.0f );
1228 DisplayCoordCross();
1231 BIASERR(
"invalid display list dplist="<<dplist);
1241 #define GLS(_flag) case _flag: {s=string(#_flag); break;}
1244 const bool withNumericDisplay,
1245 const bool numerixHexFormat )
1252 bool unknownFlag=
false;
1258 GLS(GL_FRONT_RIGHT);
1265 GLS(GL_FRONT_AND_BACK);
1274 GLS(GL_TEXTURE_INTERNAL_FORMAT);
1275 GLS(GL_TEXTURE_BORDER_COLOR);
1276 GLS(GL_TEXTURE_BORDER);
1281 GLS(GL_COMPILE_AND_EXECUTE);
1284 GLS(GL_AND_REVERSE);
1286 GLS(GL_AND_INVERTED);
1293 GLS(GL_COPY_INVERTED);
1294 GLS(GL_OR_INVERTED);
1299 #if defined(BIAS_HAVE_GLEW)
1301 GLS(GL_TEXTURE_CUBE_MAP_EXT);
1302 GLS(GL_TEXTURE_RECTANGLE_NV);
1306 GLS(GL_NEAREST_MIPMAP_NEAREST);
1307 GLS(GL_LINEAR_MIPMAP_NEAREST);
1308 GLS(GL_NEAREST_MIPMAP_LINEAR);
1309 GLS(GL_LINEAR_MIPMAP_LINEAR);
1322 GLS(GL_TEXTURE_ENV);
1323 GLS(GL_OBJECT_LINEAR);
1330 GLS(GL_LUMINANCE8 );
1331 GLS(GL_LUMINANCE12 );
1332 GLS(GL_LUMINANCE16 );
1333 GLS(GL_LUMINANCE4_ALPHA4 );
1334 GLS(GL_LUMINANCE6_ALPHA2 );
1335 GLS(GL_LUMINANCE8_ALPHA8 );
1336 GLS(GL_LUMINANCE12_ALPHA4 );
1337 GLS(GL_LUMINANCE12_ALPHA12 );
1338 GLS(GL_LUMINANCE16_ALPHA16 );
1340 GLS(GL_INTENSITY4 );
1341 GLS(GL_INTENSITY8 );
1342 GLS(GL_INTENSITY12 );
1343 GLS(GL_INTENSITY16 );
1365 if (withNumericDisplay || unknownFlag){
1367 if (numerixHexFormat){
1369 ss<<
"0x"<<setw(4)<<setfill(
'0')<<hex<<flag<<
" ";
1371 ss<<setw(8)<<setfill(
' ')<<dec<<flag<<
" ";
1380 #undef GLS // save the environemt
Vector3< double > GetRayWorldCoo(const HomgPoint2D &point)
returns vector from C to point, w of point determines ray length analytical inverse of K is used ...
void Print3D(const std::string &text, const float &xpos, const float &ypos, const float &zpos) const
static unsigned int PowerOfTwoSize(const unsigned int &val)
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
static void DisplayImgPlaneTextured(BIAS::PMatrix &P, const unsigned int &w, const unsigned int &h, const int &texID, const int &texTarget, const double &scale, const bool &flipY, const BIAS::Vector4< float > &vertexColor=BIAS::Vector4< float >(1.0, 0.0, 1.0, 0.0))
draws a pkane with attched texture coordinates
static BIAS::Vector3< double > GetImgCorner3d(BIAS::PMatrix &P, const unsigned int &width, const unsigned int &height, const unsigned int &corner, const double &scale)
compute 3D pos.
static void DisplayCoordCross(const float &size=1.0f, const float &linewidth=1.0f)
draw a coord cross as three lines in r,g,b
static void GetInfoGL(std::ostream &os)
print all GL state informatino to os including displaylist, texobj and matric info ...
static void DisplayRenderMode(const BIAS::RenderModeGL &m)
static void DisplaySimpleAnimation(const double &time)
time dependant scene for samples
bool IsRectangleTexture() const
GLenum cullface
glCullFace: GL_FRONT, GL_BACK, and GL_FRONT_AND_BACK
unsigned int heightBrutto
static void DisplayClear(const GLbitfield &mask=CLEAR_DEFAULT_MASK)
utility functions
data holder describing OpenGL texture objects in addition to its unique texID.
bool IsInitialized() const
GLenum polygonmodeBACK
glPoygonMode(GL_BACK...
GLenum shademodel
glShadeModel(...
virtual ~GeometryGL()
destructor
void Set(const T &scalar)
set all elements to a scalar value
static void DisplayQuadTexCoord2DFull(const BIAS::ImgObjGL &texobj, const bool &additionalFlipY)
static void CreateSampleDisplayListScene(int &dplistID)
creates a sample scene as one dispaly list returned in dplistID once the arg is kept as it is if init...
GLenum polygonmodeFRONT
glPoygonMode(GL_FRONT...
static void GetInfoGLenvironment(std::ostream &os)
print individual information to os
static void GetInfoGLTexObjects(std::ostream &os)
static BIAS::Matrix4x4< double > CreateTextureMatrix(BIAS::PMatrix &P, const unsigned int w, const unsigned int h, const bool &useRECTcoord=false)
compose an OpenGL 4x4 (projective) texture matrix
static void GetInfoGLmatrices(std::ostream &os)
static BIAS::Vector2< double > GetImgCorner2d(const unsigned int &w, const unsigned int &h, const unsigned int &corner, const int texMode, const bool flipY)
static void DisplayCameraExternalParams(BIAS::PMatrix &P)
static void FillCubemap(BIAS::ImgObjGL &im, const bool &mipmapColorChange=false)
fill
static void DisplayP(BIAS::PMatrix &P, const unsigned int &w, const unsigned int &h, const double &scale, const float &linewidth=1.0f)
static void GetInfoGLWriteMasks(std::ostream &os)
static void DisplayCallsSampleDisplayListScene(const double &curTime)
int GetC(Vector3< double > &C)
computes translation vector origin world coo -> origin camera coo (center), uses decomposition, which is cached
void SetIdentity()
set the elements of this matrix to the identity matrix (posisbly overriding the inherited method) ...
static void DisplayCameraInternalParams(const int &x0, const int &y0, const unsigned int &width, const unsigned int &height, const float &fovY, const float &zNear, const float &zFar)
static void DisplaySceneExampleSimple()
int GetA(Vector3< double > &A)
returns the unit vector A which is the normal vector to the image plane in world coordinates.
static void GetInfoGLTexID(const GLint id, int &foundTextures, std::ostream &os, const bool &noOutputIfInvalid=true)
static void DisplayCoordCrossAxesLabel(const float &size, const BIAS::DrawTextGL &font, const std::string &LabelX=std::string("x"), const std::string &LabelY=std::string("y"), const std::string &LabelZ=std::string("z"))
draw only the axes labels for a coord cross as text in r,g,b JW
GLRenderMode describes mode for rendering.
describes a projective 3D -> 2D mapping in homogenous coordinates
static void GetInfoGLDisplayLists(std::ostream &os)
void Set(const HOMGPOINT2D_TYPE &x, const HOMGPOINT2D_TYPE &y)
set elementwise with given 2 euclidean scalar values.
static void DisplayQuadTexCoord2D(const BIAS::ImgObjGL &texobj, const bool &additionalFlipY)
Vector3< T > & Normalize()
normalize this vector to length 1
int GetV(Vector3< double > &V)
This is not the cam.# standard CAHV, but the unit vector H0.
Draw text to OpenGL as 2D bitmap font.
void SetIdentity()
set the elements of this matrix to the identity matrix (possibly overriding the inherited method) ...
static std::string GetName(const GLint flag, const bool withNumericDisplay=true, const bool numerixHexFormat=true)
return a name for an OpenGL flags nr.
int GetK(KMatrix &K)
calibration matrix