void main(int argc, char **argv) { GLfloat afPropertiesAmbient [] = {0.50, 0.50, 0.50, 1.00}; GLfloat afPropertiesDiffuse [] = {0.75, 0.75, 0.75, 1.00}; GLfloat afPropertiesSpecular[] = {1.00, 1.00, 1.00, 1.00}; GLsizei iWidth = 640.0; GLsizei iHeight = 480.0; glutInit(&argc, argv); glutInitWindowPosition( 0, 0); glutInitWindowSize(iWidth, iHeight); glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ); glutCreateWindow( "Marching Cubes" ); glutDisplayFunc( vDrawScene ); glutIdleFunc( vIdle ); glutReshapeFunc( vResize ); glutKeyboardFunc( vKeyboard ); glutSpecialFunc( vSpecial ); glClearColor( 0.0, 0.0, 0.0, 1.0 ); glClearDepth( 1.0 ); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glPolygonMode(GL_FRONT_AND_BACK, ePolygonMode); glLightfv( GL_LIGHT0, GL_AMBIENT, afPropertiesAmbient); glLightfv( GL_LIGHT0, GL_DIFFUSE, afPropertiesDiffuse); glLightfv( GL_LIGHT0, GL_SPECULAR, afPropertiesSpecular); glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, 1.0); glEnable( GL_LIGHT0 ); glMaterialfv(GL_BACK, GL_AMBIENT, afAmbientGreen); glMaterialfv(GL_BACK, GL_DIFFUSE, afDiffuseGreen); glMaterialfv(GL_FRONT, GL_AMBIENT, afAmbientBlue); glMaterialfv(GL_FRONT, GL_DIFFUSE, afDiffuseBlue); glMaterialfv(GL_FRONT, GL_SPECULAR, afSpecularWhite); glMaterialf( GL_FRONT, GL_SHININESS, 25.0); vResize(iWidth, iHeight); vPrintHelp(); glutMainLoop(); }
void vResize( GLsizei iWidth, GLsizei iHeight ) { //input= TheGlWindowSize global TheGlWindowSize=cv::Size(iWidth,iHeight); //not all sizes are allowed. OpenCv images have padding at the end of each line in these that are not aligned to 4 bytes if (iWidth*3%4!=0) { iWidth+=iWidth*3%4;//resize to avoid padding vResize(iWidth,TheGlWindowSize.height); } else { //resize the image to the size of the GL window if (TheInputImage_Undistorted.rows!=0) { cv::resize(TheInputImage_Undistorted,new_frame_image,TheGlWindowSize); } } }