void init() { // glOrtho( -SIZE, SIZE, -SIZE, SIZE, 1, 1000 ); // Создать модель for (int x = 0; x < SIZE; x++) { for (int y = 0; y < SIZE; y++) { mesh[x][y][0] = (float) (SIZE / 2) - x; // Центр модели в начале координат mesh[x][y][1] = (float) (SIZE / 2) - y; // Центр модели в начале координат mesh[x][y][2] = 0.0f; // Задать все значение Y для всех точек равным 0 } } program1 = new WShaderProgram(); WShader *shader1 = new WShader( GL_VERTEX_SHADER_ARB ); if( !shader1->compileSourceFile("../../files/light.vsh") || !program1->addShader( shader1 ) ) { std::cout << shader1->log() << std::endl; std::cout << program1->log() << std::endl; delete shader1; } WShader *shader2 = new WShader( GL_FRAGMENT_SHADER_ARB ); if( !shader2->compileSourceFile("../../files/light.fsh") || !program1->addShader( shader2 ) ) { std::cout << shader2->log() << std::endl; std::cout << program1->log() << std::endl; delete shader1; } if( !program1->link() ) std::cout << program1->log() << std::endl; glEnable( GL_LIGHTING ); glEnable( GL_LIGHT0 ); GLfloat pos0[] = { 3, 3, -4, 1 }; glLightfv( GL_LIGHT0, GL_POSITION, pos0 ); GLfloat dif0[] = { 0.9, 0.9, 0.9, 1 }; glLightfv( GL_LIGHT0, GL_DIFFUSE, dif0 ); GLfloat spe0[] = { 0.0, 0.0, 0.0, 1 }; glLightfv( GL_LIGHT0, GL_SPECULAR, spe0 ); glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glTexGenf( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); glTexGenf( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); // BitmapBits bits; bits.load( "1-bot.bmp" ); glGenTextures(8, tex ); glBindTexture( GL_TEXTURE_2D, tex[ 0 ] ); gluBuild2DMipmaps( GL_TEXTURE_2D, 3, bits.getWidth(), bits.getHeight(), GL_BGR_EXT, GL_UNSIGNED_BYTE, bits.getBits() ); }
void SoTextureCoordinateEnvironment::doTexgen(void *) // //////////////////////////////////////////////////////////////////////// { glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); }
BOOL Tadapt::Bind(Htex& tex, DWORD objFlags) { if(!_enabled) return 0; REG BOOL force = 0; if(tex.glTarget>4)tex.glTarget=0; DWORD tgt = Targets[TGET_TARGET(tex.glTarget)]; DWORD gen = TGET_GENST(objFlags); if(tgt != _glTarget) { if(_glTarget) glDisable(_glTarget); _glTarget = tgt; force = 1; } if(gen != _glGen || force) { _glGen = gen; switch(gen) { case GEN_TEX_GEN_NA: // 0 glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); glDisable(GL_TEXTURE_GEN_R); break; case GEN_TEX_GEN_ST_CUBE: glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT); glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT); glTexGenf(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glEnable(GL_TEXTURE_GEN_R); break; case GEN_TEX_GEN_ST_SPH: glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); break; } } // apply envmodes glEnable(tgt); if(0==(int)tex.hTex) { glBindTexture(tgt, _dumptex.hTex); return FALSE; } glBindTexture(tgt, tex.hTex); return TRUE; }
u_bool32 Tadapt::Bind(Htex& tex, u_int32_t objFlags) { if(!_enabled) return 0; REG u_bool32 force = 0; if(tex.glTarget>4)tex.glTarget=0; u_int32_t tgt = Targets[TGET_TARGET(tex.glTarget)]; u_int32_t gen = TGET_GENST(objFlags); if(tgt != _glTarget) { if(_glTarget) glDisable(_glTarget); _glTarget = tgt; force = 1; } if(gen != _glGen || force) { _glGen = gen; switch(gen) { case GEN_TEX_GEN_NA: // 0 glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); glDisable(GL_TEXTURE_GEN_R); break; case GEN_TEX_GEN_ST_CUBE: glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT); glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT); glTexGenf(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glEnable(GL_TEXTURE_GEN_R); break; case GEN_TEX_GEN_ST_SPH: glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); break; } } // apply envmodes glEnable(tgt);//GL_TEXTURE_2D if(0==(int32_t)tex.hTex) { glBindTexture(tgt, _dumptex); return false; } glBindTexture(tgt, tex.hTex); return true; }
void __glXDisp_TexGenf(GLbyte *pc) { glTexGenf( *(GLenum *)(pc + 0), *(GLenum *)(pc + 4), *(GLfloat *)(pc + 8) ); }
void drawchild(void) { glPushMatrix(); glTranslatef(0.0f, 0.0f, -4.0f); glRotatef(child_time*2.0f, 0.0f, 0.0f, 1.0f); glScalef(4.0f, 4.0f, 1.0f); use_energy_texture(); glBegin(GL_QUADS); glColor3f(0.75f, 0.65f, 0.55f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -0.5f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 0.5f); glTexCoord2f(1.0f, 0.0f); glVertex3f(1.0f, 1.0f, 0.5f); glTexCoord2f(1.0f, 1.0f); glVertex3f(1.0f, -1.0f, -0.5f); glEnd(); glTranslatef(0.0f, 0.0f, 1.6f); glScalef(0.25f, 0.25f, 1.0f); glRotatef(child_time*2, 1.f, 0.0f, 0.0f); glRotatef(child_time*5, 0.0f, 1.0f ,0.0f); glRotatef(child_time*2, 0.0f, 0.0f, 1.0f); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glTexGenf(GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP); glTexGenf(GL_T,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); use_child_texture(); glColor3f(0.45f, 0.45f, 0.25f); glDepthMask(GL_FALSE); glScalef(0.75f, 0.75f, 0.75f); glCallList(childdl); glDepthMask(GL_TRUE); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); glPopMatrix(); }
/** * This function is called once before the first call to paintGL() or resizeGL(). */ void GLWidget3D::initializeGL() { // init glew GLenum err = glewInit(); if (err != GLEW_OK) { std::cout << "Error: " << glewGetErrorString(err) << std::endl; } if (glewIsSupported("GL_VERSION_4_2")) printf("Ready for OpenGL 4.2\n"); else { printf("OpenGL 4.2 not supported\n"); exit(1); } const GLubyte* text = glGetString(GL_VERSION); printf("VERSION: %s\n", text); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glEnable(GL_TEXTURE_2D); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glDisable(GL_TEXTURE_2D); //////////////////////////////// renderManager.init("", "", "", true, 8192); renderManager.resize(this->width(), this->height()); camera.xrot = 0.0f; camera.yrot = 0.0f; camera.zrot = 0.0f; camera.pos = glm::vec3(0, 6, 15.0f); }
void render_spheremap(void) { GLfloat p[4]; int i; glColor4f(1, 1, 1, 1); #if 1 glEnable(GL_TEXTURE_2D); #endif glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); p[0] = 2.0; p[1] = p[2] = p[3] = 0.0; /* 2zx */ glTexGenfv(GL_S, GL_OBJECT_PLANE, p); glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); p[0] = 0.0; p[1] = 2.0; p[2] = p[3] = 0.0; /* 2zy */ glTexGenfv(GL_T, GL_OBJECT_PLANE, p); glTexGenf(GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); p[0] = p[1] = 0.0; p[2] = 0.0; p[3] = 2.0; /* 2z */ glTexGenfv(GL_R, GL_OBJECT_PLANE, p); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glEnable(GL_TEXTURE_GEN_R); glMatrixMode(GL_PROJECTION); glPushMatrix(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glMatrixMode(GL_TEXTURE); glPushMatrix(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-.98, .98, -.98, .98, 1.0, 100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0, 0, 6, 0, 0, 0, 0, 1, 0); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); #if 1 glClearColor(0.25, 0.25, 0.5, 1.0); glClear( /* GL_COLOR_BUFFER_BIT | */ GL_DEPTH_BUFFER_BIT); #endif for (i = 0; i < 6; i++) { glTexImage2D(GL_TEXTURE_2D, 0, 4, faceW, faceW, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *) faceMap[i]); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glScalef(0.5, 0.5, 1.0); glTranslatef(1.0, 1.0, 0.0); glFrustum(-1.01, 1.01, -1.01, 1.01, 1.0, 100.0); if (angle2[i]) { glRotatef(angle2[i], axis2[i][0], axis2[i][1], axis2[i][2]); } glRotatef(angle1[i], axis1[i][0], axis1[i][1], axis1[i][2]); /* XXX atul does another angle thing here... */ /* XXX atul does a third angle thing here... */ glTranslatef(0.0, 0.0, -1.00); glMatrixMode(GL_MODELVIEW); glClear(GL_DEPTH_BUFFER_BIT); draw_special_sphere(20); } glDisable(GL_BLEND); glDisable(GL_CULL_FACE); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glMatrixMode(GL_TEXTURE); glPopMatrix(); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); glDisable(GL_TEXTURE_GEN_R); glDisable(GL_TEXTURE_2D); }
// for low end hardware void LLDrawPoolWater::renderOpaqueLegacyWater() { LLVOSky *voskyp = gSky.mVOSkyp; stop_glerror(); // Depth sorting and write to depth buffer // since this is opaque, we should see nothing // behind the water. No blending because // of no transparency. And no face culling so // that the underside of the water is also opaque. LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE); LLGLDisable no_cull(GL_CULL_FACE); LLGLDisable no_blend(GL_BLEND); gPipeline.disableLights(); mOpaqueWaterImagep->addTextureStats(1024.f*1024.f); // Activate the texture binding and bind one // texture since all images will have the same texture gGL.getTexUnit(0)->activate(); gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(0)->bind(mOpaqueWaterImagep); // Automatically generate texture coords for water texture glEnable(GL_TEXTURE_GEN_S); //texture unit 0 glEnable(GL_TEXTURE_GEN_T); //texture unit 0 glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); // Use the fact that we know all water faces are the same size // to save some computation // Slowly move texture coordinates over time so the watter appears // to be moving. F32 movement_period_secs = 50.f; F32 offset = fmod(gFrameTimeSeconds, movement_period_secs); if (movement_period_secs != 0) { offset /= movement_period_secs; } else { offset = 0; } F32 tp0[4] = { 16.f / 256.f, 0.0f, 0.0f, offset }; F32 tp1[4] = { 0.0f, 16.f / 256.f, 0.0f, offset }; glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0); glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1); glColor3f(1.f, 1.f, 1.f); for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); iter != mDrawFace.end(); iter++) { LLFace *face = *iter; if (voskyp->isReflFace(face)) { continue; } face->renderIndexed(); } stop_glerror(); // Reset the settings back to expected values glDisable(GL_TEXTURE_GEN_S); //texture unit 0 glDisable(GL_TEXTURE_GEN_T); //texture unit 0 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); }
M(void, glTexGenf, jint coord, jint pname, jfloat param) { glTexGenf(coord, pname, param); }
void gl4es_glMultiTexGenf(GLenum texunit, GLenum coord, GLenum pname, GLfloat param) { text(glTexGenf(coord, pname, param)); }