void init (void){ glClearColor (0.2, 0.52, 1.0, 1.0); glEnable(GL_DEPTH_TEST); //glEnable(GL_CULL_FACE); glEnable(GL_TEXTURE_2D); head=gluNewQuadric(); body=gluNewQuadric(); arm=gluNewQuadric(); palm=gluNewQuadric(); thigh=gluNewQuadric(); shank=gluNewQuadric(); ball=gluNewQuadric(); body2=gluNewQuadric(); sun=gluNewQuadric(); gluQuadricTexture(head,GL_TRUE); gluQuadricTexture(body,GL_TRUE); gluQuadricTexture(arm,GL_TRUE); gluQuadricTexture(palm,GL_TRUE); gluQuadricTexture(thigh,GL_TRUE); gluQuadricTexture(shank,GL_TRUE); gluQuadricTexture(ball,GL_TRUE); gluQuadricTexture(body2,GL_TRUE); loadGLTextures(sky_texture, "sky.bmp"); //load the texture loadGLTextures(grass_texture, "grass.bmp"); loadGLTextures(bodyTexture, "metal.bmp"); loadGLTextures(headTexture, "head.bmp"); loadGLTextures(armTexture, "metal.bmp"); //loadGLTextures(palmTexture, "metal.bmp"); loadGLTextures(thighTexture, "metal.bmp"); //loadGLTextures(shankTexture, "metal.bmp"); loadGLTextures(footTexture, "metal.bmp"); loadGLTextures(ballTexture, "football.bmp"); loadGLTextures(body2Texture, "metal.bmp"); }
/* general OpenGL initialization function */ int initGL() { if (!loadGLTextures()) { return False; } glEnable(GL_TEXTURE_2D); /* Enable Texture Mapping */ glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); /* set up our lighting */ glLightfv(GL_LIGHT1, GL_AMBIENT, lightAmbient); glLightfv(GL_LIGHT1, GL_DIFFUSE, lightDiffuse); glLightfv(GL_LIGHT1, GL_POSITION, lightPosition); glEnable(GL_LIGHT1); /* we use resizeGLScene once to set up our initial perspective */ resizeGLScene(GLWin.width, GLWin.height); if (light) glEnable(GL_LIGHTING); glFlush(); return True; }
void nehewidget::initializeGL() { loadGLTextures(); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glClearColor(0,0,0,0); glClearDepth(1.0); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST); glLightfv(GL_LIGHT1,GL_AMBIENT,lightAmbient); glLightfv(GL_LIGHT1,GL_DIFFUSE,lightDiffuse); glLightfv(GL_LIGHT1,GL_POSITION,lightPosition); glEnable(GL_LIGHT1); quadratic = gluNewQuadric(); gluQuadricNormals(quadratic,GLU_SMOOTH); gluQuadricTexture(quadratic,GL_TRUE); glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); // 设置s方向的纹理自动生成 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); // 设置t方向的纹理自动生成 }
void nehewidget::initializeGL() { loadGLTextures(); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glClearColor(0,0,0,0); glClearDepth(1.0); glEnable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST); for (loop=0;loop<MAX_PARTICLES;loop++) { /* particle[loop].x=0.0f; particle[loop].y=0.0f; particle[loop].z=0.0f;*/ particle[loop].active=true; // 使所有的粒子为激活状态 particle[loop].life=1.0f; // 所有的粒子生命值为最大 particle[loop].fade=float(rand()%100)/1000.0f +0.003f; // 随机生成衰减速率 particle[loop].r=colors[loop*(12/MAX_PARTICLES)][0]; // 粒子的红色颜色 particle[loop].g=colors[loop*(12/MAX_PARTICLES)][1]; // 粒子的绿色颜色 particle[loop].b=colors[loop*(12/MAX_PARTICLES)][2]; // 粒子的蓝色颜色 particle[loop].xi=float((rand()%50)-26.0f)*10.0f; // 随机生成X轴方向速度 particle[loop].yi=float((rand()%50)-25.0f)*10.0f; // 随机生成Y轴方向速度 particle[loop].zi=float((rand()%50)-25.0f)*10.0f; // 随机生成Z轴方向速度 particle[loop].xg=0.0f; // 设置X轴方向加速度为0 particle[loop].yg=-0.8f; // 设置Y轴方向加速度为-0.8 particle[loop].zg=0.0f; // 设置Z轴方向加速度为0 } glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST); }
/* general OpenGL initialization function */ int initGL(GLvoid) { if (!loadGLTextures()) { return False; } glEnable(GL_TEXTURE_2D); /* enable texture mapping */ glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glColor4f(1.0f, 1.0f, 1.0f, 0.5f); /* full brightness, 50% Alpha */ glBlendFunc(GL_SRC_ALPHA, GL_ONE); /* blending function */ /* set up our lighting */ glLightfv(GL_LIGHT1, GL_AMBIENT, lightAmbient); glLightfv(GL_LIGHT1, GL_DIFFUSE, lightDiffuse); glLightfv(GL_LIGHT1, GL_POSITION, lightPosition); glEnable(GL_LIGHT1); /* we use resizeGLScene once to set up our initial perspective */ resizeGLScene(GLWin.width, GLWin.height); /* test the state of blending and lighting, so keep it when switching * between fullscreen and window mode */ if (blend) { glEnable(GL_BLEND); glDisable(GL_DEPTH_TEST); } if (light) glEnable(GL_LIGHTING); glFlush(); return True; }
void NeHeWidget::initializeGL() { loadGLTextures(); glEnable( GL_TEXTURE_2D ); glShadeModel( GL_SMOOTH ); glClearColor( 0.5, 0.5, 0.5, 1.0 ); // 设置背景的颜色为雾气的颜色 glClearDepth( 1.0 ); glEnable( GL_DEPTH_TEST ); glDepthFunc( GL_LEQUAL ); glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); glLightfv( GL_LIGHT1, GL_AMBIENT, lightAmbient ); glLightfv( GL_LIGHT1, GL_DIFFUSE, lightDiffuse ); glLightfv( GL_LIGHT1, GL_POSITION, lightPosition ); glEnable( GL_LIGHT1 ); glFogi( GL_FOG_MODE, fogMode[fogFilter] ); // 设置雾气的模式 glFogfv( GL_FOG_COLOR, fogColor ); // 设置雾的颜色 glFogf( GL_FOG_DENSITY, 0.35 ); // 设置雾的密度 glHint( GL_FOG_HINT, GL_DONT_CARE ); // 设置系统如何计算雾气 glFogf( GL_FOG_START, 1.0 ); // 雾气的开始位置 glFogf( GL_FOG_END, 5.0 ); // 雾气的结束位置 glEnable( GL_FOG ); // 使用雾气 }
void Sample_22::initGL() { glPushAttrib(GL_ALL_ATTRIB_BITS); // set here server attributes (states) loadGLTextures(); // Jump To Texture Loading Routine glEnable(GL_TEXTURE_2D); // Enable Texture Mapping glShadeModel(GL_SMOOTH); // Enable Smooth Shading glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background glClearDepth(1.0f); // Depth Buffer Setup glEnable(GL_DEPTH_TEST); // Enables Depth Testing glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations initLights(); // Initialize OpenGL Light glPushClientAttrib(GL_ALL_CLIENT_ATTRIB_BITS); // set here client attributes (states) #ifdef EXT_INFO if (m_useMultitexture) printf("The GL_ARB_multitexture extension will be used.\n"); else printf("The GL_ARB_multitexture extension won't be used.\n"); #endif }
void Virtual3dCharacterViewer::initializeGL() { loadGLTextures(); ENABLE_GL_TEXTURE_2D = true ; if ( ENABLE_GL_TEXTURE_2D ) glEnable( GL_TEXTURE_2D ); glShadeModel( GL_SMOOTH ); glClearColor( 0.0, 0.0, 0.0, 0.5 ); glClearDepth( 1.0 ); glEnable( GL_DEPTH_TEST ); glDepthFunc( GL_LEQUAL ); glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); glLightfv( GL_LIGHT1, GL_AMBIENT, lightAmbient ); glLightfv( GL_LIGHT1, GL_DIFFUSE, lightDiffuse ); glLightfv( GL_LIGHT1, GL_POSITION, lightPosition ); glEnable( GL_LIGHT1 ); glColorMaterial(GL_FRONT,GL_DIFFUSE); glEnable(GL_COLOR_MATERIAL); // glEnable( GL_LIGHTING ); // light = true ; }
/* * These functions will closely mimic those which we've seen already * w.r.t. the GLUT functions. In fact, Qt actually implements GLUT, * so the coding is frighteningly similar. */ void GLWidget::initializeGL() { // The background color is set here. //qglClearColor( qtPurple.dark() ); qglClearColor( qtDark.light() ); /* // Make a QtLogo (this has been provided to us), (make it green!) logo = new QtLogo( this, 64 ); logo->setColor( qtPurple.dark() ); */ glEnable( GL_DEPTH_TEST ); glEnable( GL_CULL_FACE ); glShadeModel( GL_SMOOTH ); // Need these options to enable light sources // (can do GL_LIGHT0, 1, ..., n sources) glEnable( GL_LIGHTING ); glEnable( GL_LIGHT0 ); // The stationary "room" light glEnable( GL_LIGHT1 ); // The recoloarable light glEnable( GL_LIGHT2 ); // Another light (why not?) glEnable( GL_MULTISAMPLE ); // Use hardware to smooth edges! // (may not work on all platforms) // Old light setting (in case we want it back) //static GLfloat lightPosition[4] = { 0.5, 5.0, 7.0, 7.0 }; // Setup the room's light position. This will be a constant. //static GLfloat lightPosition[4] = { 0.0, 0.9, 0.5, 1.0 }; static GLfloat lightPosition[4] = { 0.0, 0.0, 1000.0, 1.0 }; glLightfv( GL_LIGHT0, GL_POSITION, lightPosition ); // Initialize the side lights static GLfloat flPos[4] = { 1000.0, 0.0, 0.1, 0.0 }; glLightfv( GL_LIGHT1, GL_POSITION, flPos ); static GLfloat llPos[4] = { -1000.0, 0.0, 0.1, 0.0 }; glLightfv( GL_LIGHT2, GL_POSITION, llPos ); // Create the vertex buffer array with the object! // NOTE: This fails unless you have the proper context first. asset->CreateVBO(); #if TEXTURE_MODE_ON // The texture loading interface is very wonky still and // needs more debugging time. We've removed all calls and // interaction with the outside files that deal with them ... for now. loadGLTextures(); glBindTexture(GL_TEXTURE_2D, *(asset->GetTexCoordVBO())); #endif }
void NeHeWidget::initializeGL() { loadGLTextures(); glEnable( GL_TEXTURE_2D ); glShadeModel( GL_SMOOTH ); glClearColor( 0.0, 0.0, 0.0, 0.5 ); glClearDepth( 1.0 ); glEnable( GL_DEPTH_TEST ); glDepthFunc( GL_LEQUAL ); glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); }
bool initGL() { bool success = true; GLenum error = GL_NO_ERROR; if(!loadGLTextures()){ return false; } BuildLists(); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.5f); glClearDepth(1.0f); //glEnable(GL_DEPTH_TEST); //glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); //glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); //glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); //glLightfv(GL_LIGHT1, GL_POSITION, LightPosition); //glEnable(GL_LIGHT1); // //glColor4f(1.0f, 1.0f, 1.0f, 0.5f); glBlendFunc(GL_SRC_ALPHA,GL_ONE); glEnable(GL_BLEND); for(int i = 0; i < num; i++){ stars[i].dist = (float(i)/num)*5.0f; stars[i].r = rand()%256; stars[i].g = rand()%256; stars[i].b = rand()%256; } glPolygonMode(GL_BACK, GL_FILL); glPolygonMode(GL_FRONT, GL_LINE); for(int x=0; x < lenx; x++){ for(int y=0; y < leny; y++){ points[x][y][0] = float((x/(lenx/9.0f))-4.5f); points[x][y][1] = float((y/(leny/9.0f))-4.5f); points[x][y][2] = float(sin((((x/(lenx/9.0f))*40.0f)/360.0f)*3.14*2.0f)); } } return success; }
void TableGL::init() { loadGLTextures("table.bmp"); glNewList(list,GL_COMPILE); glColor3f(1.0f,1.0f,1.0f); glBindTexture(GL_TEXTURE_2D,texture[0]); glBegin(GL_QUADS); glNormal3f(0.0f,0.0f,1.0f); glTexCoord2f(1.0f,1.0f);glVertex3f(x,y,0.0f); glTexCoord2f(1.0f,0.0f);glVertex3f(x,-y,0.0f); glTexCoord2f(0.0f,0.0f);glVertex3f(-x,-y,0.0f); glTexCoord2f(0.0f,1.0f);glVertex3f(-x,y,0.0f); glEnd(); glEndList(); }
void nehewidget::initializeGL() { loadGLTextures(); buildlists(); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glClearColor(0,0,0,0); glClearDepth(1.0); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST); }
int main(int argc, char **argv) { glutInit(&argc, argv); /* need both double buffering and z buffer */ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(500, 500); glutCreateWindow("colorcube"); glutReshapeFunc(myReshape); glutDisplayFunc(display); glutIdleFunc(spinCube); glutMouseFunc(mouse); glEnable(GL_DEPTH_TEST); /* Enable hidden--surface--removal */ loadGLTextures(); glutMainLoop(); }
GLvoid Engine::initGL(GLsizei width, GLsizei height) { loadGLTextures(); glEnable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0); glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); glShadeModel(GL_SMOOTH); glutWarpPointer(Engine::windowWidth/2, Engine::windowHeight/2); glutSetCursor (GLUT_CURSOR_NONE); clearScreen(width, height); }
int OpenGLGame::initGL( GLvoid ) /* 此处开始对OpenGL进行所有设置 */ { if ( !loadGLTextures() ) // Jump To Texture Loading Routine ( NEW ) { return FALSE; // If Texture Didn't Load Return FALSE ( NEW ) } glEnable( GL_TEXTURE_2D ); // Enable Texture Mapping ( NEW ) glShadeModel( GL_SMOOTH ); // Enable Smooth Shading glClearColor( 0.0f, 0.0f, 0.0f, 0.5f ); // Black Background glClearDepth( 1.0f ); // Depth Buffer Setup glEnable( GL_DEPTH_TEST ); // Enables Depth Testing glDepthFunc( GL_LEQUAL ); // The Type Of Depth Testing To Do // Really Nice Perspective Calculations glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); return TRUE; // Initialization Went OK }
void GLViewer::paintGL(){ rot += 0.5; if(update_model){ update_model = false; zoom = -1.0f; rot = 0.0f; //vertical_pan = 0.0f; loadGLTextures(); buildlists(); } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0, -zoom * model_size, -zoom * model_size / 2.0 , 0, 0, 0.0, 0, 0, 1); glRotatef(rot, 0, 0, 1); //glRotatef(-xRot / 16.0, 1.0, 0.0, 0.0); //glRotatef(-yRot / 16.0, 0.0, 1.0, 0.0); //glRotatef(-zRot / 16.0, 0.0, 0.0, 1.0); glTranslatef(0, 0, vertical_pan * model_size); glCallList(model_list); }
void nehewidget::initializeGL() { loadGLTextures(); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glClearColor(0,0,0,0); glClearDepth(1.0); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST); // glBlendFunc(GL_SRC_ALPHA,GL_ONE); // glEnable(GL_BLEND); for(loop=0;loop<num;loop++) { star[loop].angle=0.0; star[loop].dist=((float)loop)/num*1.5; star[loop].r=rand()%256; star[loop].g=rand()%256; star[loop].b=rand()%256; } }
/* general OpenGL initialization function */ int initGL(GLvoid) { if (!loadGLTextures()) { return False; } glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture[0]); /* initializing our particles */ for (loop = 0; loop < MAX_PARTICLES; loop++) { particle[loop].active = True; particle[loop].life = 1.0f; particle[loop].fade = (float) (rand() % 100) / 1000 + 0.003f; particle[loop].red = colors[loop / (MAX_PARTICLES / 12)][0]; particle[loop].green = colors[loop / (MAX_PARTICLES / 12)][0]; particle[loop].blue = colors[loop / (MAX_PARTICLES / 12)][0]; particle[loop].xSpeed = (float) ((rand() % 50) - 26.0f) * 10.0f; particle[loop].ySpeed = (float) ((rand() % 50) - 25.0f) * 10.0f; particle[loop].zSpeed = (float) ((rand() % 50) - 25.0f) * 10.0f; particle[loop].xGrav = 0.0f; particle[loop].yGrav = -0.8f; particle[loop].zGrav = 0.0f; } /* we use resizeGLScene once to set up our initial perspective */ resizeGLScene(GLWin.width, GLWin.height); glFlush(); return True; }
void Skybox::SkyBox_CreateTexture(void) { int i=1; QString skyboxName = "data\\hw_arctic\\arctic_"; QString ext = ".tga"; Texture* tex[6]; int k = 0; tex[k] = new Texture(); LoadTGA(tex[k], QString(skyboxName + "back" + ext).toStdString().data()); TexIDSkyBox[0] = loadGLTextures(tex[k]); ++k; tex[k] = new Texture(); LoadTGA(tex[k], QString(skyboxName + "front" + ext).toStdString().data()); TexIDSkyBox[1] = loadGLTextures(tex[k]); ++k; tex[k] = new Texture(); LoadTGA(tex[k], QString(skyboxName + "bottom" + ext).toStdString().data()); TexIDSkyBox[2] = loadGLTextures(tex[k]); ++k; tex[k] = new Texture(); LoadTGA(tex[k], QString(skyboxName + "top" + ext).toStdString().data()); TexIDSkyBox[3] = loadGLTextures(tex[k]); ++k; tex[k] = new Texture(); LoadTGA(tex[k], QString(skyboxName + "left" + ext).toStdString().data()); TexIDSkyBox[5] = loadGLTextures(tex[k]); ++k; tex[k] = new Texture(); LoadTGA(tex[k], QString(skyboxName + "right" + ext).toStdString().data()); TexIDSkyBox[4] = loadGLTextures(tex[k]); ++k; // TexIDSkyBox[1] = loadTexture(skyboxName + "front" + ext); // TexIDSkyBox[2] = loadTexture(skyboxName + "bottom" + ext); // TexIDSkyBox[3] = loadTexture(skyboxName + "top" + ext); // TexIDSkyBox[4] = loadTexture(skyboxName + "left" + ext); // TexIDSkyBox[5] = loadTexture(skyboxName + "right" + ext); for(i=0;i<=5;++i) { glBindTexture(GL_TEXTURE_2D, TexIDSkyBox[i]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0x812F); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, 0x812F); } }