void ParametricUndistortionFilter::undistortIntensityImage(unsigned char const * image, unsigned char * result) { _srcTex.overwriteWith(image, 1); _destBuffer.activate(); setupNormalizedProjection(); parametricShader->parameter("f", _fx, _fy, 1.0f/_fx, 1.0f/_fy); parametricShader->parameter("k", _k1, _k2); parametricShader->parameter("p", _p1, _p2); parametricShader->parameter("center", _center[0], _center[1]); parametricShader->parameter("wh", _width, _height, 1.0f/_width, 1.0f/_height); _srcTex.enable(GL_TEXTURE0); parametricShader->enable(); #if 0 renderNormalizedQuad(); #else glBegin(GL_TRIANGLES); glMultiTexCoord2f(GL_TEXTURE0_ARB, 0, 0); glVertex2f(0, 0); glMultiTexCoord2f(GL_TEXTURE0_ARB, 2*_width, 0); glVertex2f(2, 0); glMultiTexCoord2f(GL_TEXTURE0_ARB, 0, 2*_height); glVertex2f(0, 2); glEnd(); #endif parametricShader->disable(); _srcTex.disable(GL_TEXTURE0); glReadPixels(0, 0, _width, _height, GL_RED, GL_UNSIGNED_BYTE, result); }
void duck::drawAim () { glPushAttrib(GL_ALL_ATTRIB_BITS); textureSwitch(false, false, false, false, false); glActiveTexture (GL_TEXTURE4); glEnable(GL_TEXTURE_2D); glEnable (GL_ALPHA_TEST); glAlphaFunc (GL_GREATER, 0.0); glEnable (GL_POLYGON_OFFSET_FILL); glPolygonOffset (-3,-3); glPushMatrix(); glTranslatef(pos[0],pos[1],pos[2]); glRotatef(angle, 1,0,0); glBegin (GL_QUADS); glMultiTexCoord2f(GL_TEXTURE4, 0,0); glVertex2f (-.3,0); glMultiTexCoord2f(GL_TEXTURE4, 1,0); glVertex2f (+.3,0); glMultiTexCoord2f(GL_TEXTURE4, 1,1); glVertex2f (+.3, .6); glMultiTexCoord2f(GL_TEXTURE4, 0,1); glVertex2f (-.3, .6); glEnd(); glPopMatrix(); glPopAttrib(); }
void OpenGLRenderer::DrawTexturedRect(float x, float y, float w, float h, float uStart, float vStart, float uEnd, float vEnd, Color color) { applyTextureStages(); disableTransform(); x -= .5f; y -= .5f; glColor3ub(color.r, color.g, color.b); glBegin(GL_QUADS); glMultiTexCoord2f(GL_TEXTURE0, uStart, vStart); glVertex3f(x, y, 0); glMultiTexCoord2f(GL_TEXTURE0, uEnd, vStart); glVertex3f(x + w, y, 0); glMultiTexCoord2f(GL_TEXTURE0, uEnd, vEnd); glVertex3f(x + w, y + h, 0); glMultiTexCoord2f(GL_TEXTURE0, uStart, vEnd); glVertex3f(x, y + h, 0); glEnd(); CHECK_GL; }
/*! Will draw a flat surface that can be used for the heightmapped terrain. @param width Width of the surface @param depth Depth of the surface @param wRes Width resolution of the surface @param dRes Depth resolution of the surface */ void drawTerrainGrid( float width, float depth, unsigned int wRes, unsigned int dRes ) { float wStart = -width * 0.5f; float dStart = -depth * 0.5f; float dW = width / static_cast<float>( wRes ); float dD = depth / static_cast<float>( dRes ); for( unsigned int depthIndex = 0; depthIndex < dRes; ++depthIndex ) { float dPosLow = dStart + dD * static_cast<float>( depthIndex ); float dPosHigh = dStart + dD * static_cast<float>( depthIndex + 1 ); float dTexCoordLow = depthIndex / static_cast<float>( dRes ); float dTexCoordHigh = (depthIndex+1) / static_cast<float>( dRes ); glBegin( GL_TRIANGLE_STRIP ); glNormal3f(0.0f,1.0f,0.0); for( unsigned widthIndex = 0; widthIndex < wRes; ++widthIndex ) { float wPos = wStart + dW * static_cast<float>( widthIndex ); float wTexCoord = widthIndex / static_cast<float>( wRes ); glMultiTexCoord2f(GL_TEXTURE0, wTexCoord, dTexCoordLow); glMultiTexCoord2f(GL_TEXTURE1, wTexCoord, dTexCoordLow); glVertex3f( wPos, 0.0f, dPosLow ); glMultiTexCoord2f(GL_TEXTURE0, wTexCoord, dTexCoordHigh); glMultiTexCoord2f(GL_TEXTURE1, wTexCoord, dTexCoordHigh); glVertex3f( wPos, 0.0f, dPosHigh ); } glEnd(); } }
void DrawTorus(GLfloat innerRadius, GLfloat ringRadius, GLint rings, GLint slices, GLfloat xTexScale, GLfloat yTexScale) { GLfloat sliceAngleInc = (2.0f * 3.14159265f) / (GLfloat)slices; GLfloat ringAngleInc = (2.0f * 3.14159265f) / (GLfloat)rings; GLint i, j; for (i = 0; i <= rings; i++) { glBegin(GL_QUAD_STRIP); for (j = 0; j <= slices; j++) { glMultiTexCoord2f(GL_TEXTURE0, xTexScale * (i+1) / (GLfloat)rings, yTexScale * j / (GLfloat)slices); glMultiTexCoord3f(GL_TEXTURE1, cos((ringAngleInc * (i+1)) + (3.14159265f * 0.5f)), 0.0f, sin((ringAngleInc * (i+1)) + (3.14159265f * 0.5f))); // tangent glMultiTexCoord3f(GL_TEXTURE2, 0.0f, sin((sliceAngleInc * j) + (3.14159265f * 0.5f)), 0.0f); // binormal glMultiTexCoord3f(GL_TEXTURE3, cos(ringAngleInc * (i+1)), sin(sliceAngleInc * j), sin(ringAngleInc * (i+1))); // normal glVertex3f((innerRadius + ringRadius + (ringRadius * cos(sliceAngleInc * j))) * cos(ringAngleInc * (i+1)), (ringRadius * sin(sliceAngleInc * j)), (innerRadius + ringRadius + (ringRadius * cos(sliceAngleInc * j))) * sin(ringAngleInc * (i+1))); glMultiTexCoord2f(GL_TEXTURE0, xTexScale * i / (GLfloat)rings, yTexScale * j / (GLfloat)slices); glMultiTexCoord3f(GL_TEXTURE1, cos((ringAngleInc * i) + (3.14159265f * 0.5f)), 0.0f, sin((ringAngleInc * i) + (3.14159265f * 0.5f))); // tangent glMultiTexCoord3f(GL_TEXTURE2, 0.0f, sin((sliceAngleInc * j) + (3.14159265f * 0.5f)), 0.0f); // binormal glMultiTexCoord3f(GL_TEXTURE3, cos(ringAngleInc * i), sin(sliceAngleInc * j), sin(ringAngleInc * i)); // normal glVertex3f((innerRadius + ringRadius + (ringRadius * cos(sliceAngleInc * j))) * cos(ringAngleInc * i), (ringRadius * sin(sliceAngleInc * j)), (innerRadius + ringRadius + (ringRadius * cos(sliceAngleInc * j))) * sin(ringAngleInc * i)); } glEnd(); } }
static GLboolean test_multitex_combo(int bias1, int level1, int bias2, int level2) { float scale1 = scale_for_miplevel(bias1, level1); float scale2 = scale_for_miplevel(bias2, level2); GLfloat expected[3]; int i; for(i = 0; i < 3; ++i) expected[i] = TextureData[0][level1][i] + TextureData[1][level2][i]; glPushMatrix(); glScalef(SquareSize, SquareSize, 1.0); glTranslatef(level1, level2, 0.0); glBegin(GL_QUADS); glMultiTexCoord2f(GL_TEXTURE0, 0.0, 0.0); glMultiTexCoord2f(GL_TEXTURE1, 0.0, 0.0); glVertex2f(0, 0); glMultiTexCoord2f(GL_TEXTURE0, scale1, 0.0); glMultiTexCoord2f(GL_TEXTURE1, scale2, 0.0); glVertex2f(1, 0); glMultiTexCoord2f(GL_TEXTURE0, scale1, scale1); glMultiTexCoord2f(GL_TEXTURE1, scale2, scale2); glVertex2f(1, 1); glMultiTexCoord2f(GL_TEXTURE0, 0.0, scale1); glMultiTexCoord2f(GL_TEXTURE1, 0.0, scale2); glVertex2f(0, 1); glEnd(); glPopMatrix(); return probe_cell("multitex", level1, level2, expected); }
void wall() { glBegin (GL_QUADS); // same attributes for every vertex glVertexAttrib3f(tan_loc,1,0,0); glVertexAttrib3f(bitan_loc, 0,1,0); glNormal3f(0,0,1); glMultiTexCoord2f(GL_TEXTURE0, 0,0); glVertex3i(-2, 0, 0); glMultiTexCoord2f(GL_TEXTURE0, 1,0); glVertex3i(2,0,0); glMultiTexCoord2f(GL_TEXTURE0, 1,1); glVertex3i(2,4,0); glMultiTexCoord2f(GL_TEXTURE0, 0,1); glVertex3i(-2,4,0); glEnd(); }
void HaloRefImage::draw_scratch() { // set opengl state: glPushAttrib(GL_ENABLE_BIT | GL_TRANSFORM_BIT); glDisable(GL_LIGHTING); // GL_ENABLE_BIT // prevents depth testing AND writing: glDisable(GL_DEPTH_TEST); // GL_ENABLE_BIT // so it doesn't bleed stuff from the front buffer // through the low alpha areas: // load identity for model matrix glMatrixMode(GL_MODELVIEW); // GL_TRANSFORM_BIT glPushMatrix(); glLoadIdentity(); // set up to draw in XY coords: glMatrixMode(GL_PROJECTION); // GL_TRANSFORM_BIT glPushMatrix(); glLoadMatrixd(VIEW::peek()->xypt_proj().transpose().matrix()); // Draw a quad with our texture on it assert(_scratch_tex); _scratch_tex->apply_texture(); // GL_ENABLE_BIT GLfloat t = 1; glColor4f(1, 1, 1, 1); // GL_CURRENT_BIT glBegin(GL_QUADS); // draw vertices in CCW order starting at bottom left: GLenum unit = _scratch_tex->get_tex_unit(); glMultiTexCoord2f(unit, 0, 0); glVertex2f(-t, -t); glMultiTexCoord2f(unit, 1, 0); glVertex2f( t, -t); glMultiTexCoord2f(unit, 1, 1); glVertex2f( t, t); glMultiTexCoord2f(unit, 0, 1); glVertex2f(-t, t); glEnd(); // restore projection matrix glMatrixMode(GL_PROJECTION); glPopMatrix(); // restore modelview matrix glMatrixMode(GL_MODELVIEW); glPopMatrix(); // restore state: glPopAttrib(); }
void DrawFloorMirror() { FloorProg->EnableShader(); glActiveTexture(GL_TEXTURE0); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,textureID); glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE); glActiveTexture(GL_TEXTURE1); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,ReflectFloor->GetColorTextureID(0)); glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE); GLint texSamplerF; texSamplerF = glGetUniformLocation(FloorProg->GetProgramID(),"texF"); glUniform1i(texSamplerF,0); GLint texSamplerM; texSamplerM = glGetUniformLocation(FloorProg->GetProgramID(),"texM"); glUniform1i(texSamplerM,1); GLint dim; dim = glGetUniformLocation(FloorProg->GetProgramID(),"width"); glUniform1i(dim,width); dim = glGetUniformLocation(FloorProg->GetProgramID(),"height"); glUniform1i(dim,height); glBegin(GL_QUADS); glMultiTexCoord2f(GL_TEXTURE0,0,0); glVertex3f(-6,-2,-6); glMultiTexCoord2f(GL_TEXTURE0,5,0); glVertex3f(-6,-2,6); glMultiTexCoord2f(GL_TEXTURE0,5,5); glVertex3f(6,-2,6); glMultiTexCoord2f(GL_TEXTURE0,0,5); glVertex3f(6,-2,-6); glEnd(); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D,0); glDisable(GL_TEXTURE_2D); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D,0); glDisable(GL_TEXTURE_2D); FloorProg->DisableShader(); }
void TestOBJ::draw(){ glEnable(GL_TEXTURE_RECTANGLE_ARB); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, textureID); if (g_bShadersSupported && g_bUseShaders) { glUseProgram(shaderProgramID); glUniform1i(glGetUniformLocation(shaderProgramID, "my_texture"),0); } // draw float tSizeX = 4; float tSizeY = 5; float tStepX = 1/tSizeX; float tStepY = 1/tSizeY; float x,y,v; glBegin(GL_LINE_STRIP); for (int i=0; i<tSizeX*tSizeY; i++){ x = float(i%(int)tSizeX);///(tSizeX-1); y = i/(int)tSizeX;///(tSizeY-1); //v = data[int((y*(tSizeY-1))*tSizeX+x*(tSizeX-1))*4]; v = data[int(y*tSizeX+x)*3]; //printf("[X,Y]=[%f, %f] = %f\n",x,y, v ); glMultiTexCoord2f(GL_TEXTURE0, x+0.5,y+0.5); glVertex3f(0.f, i*0.1, 0.f); } glEnd(); // if (g_bShadersSupported && g_bUseShaders) { glUseProgram(NULL); } glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); };
void drawWithMultiTexture(GLuint texName1, GLuint texName2, float translate[2]) { // Initilize 2 textures for light mapping glEnable(GL_COLOR_MATERIAL); glColor3f(1.0,1.0,1.0); glActiveTexture(GL_TEXTURE0); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texName1); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glActiveTexture(GL_TEXTURE1); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texName2); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glMatrixMode(GL_TEXTURE); glPushMatrix(); glLoadIdentity(); glTranslatef(translate[1], translate[0], 0.0); glMatrixMode(GL_MODELVIEW); glBegin(GL_QUADS); glNormal3fv(this->n); glMultiTexCoord2fv(GL_TEXTURE0, t1); glMultiTexCoord2f(GL_TEXTURE1, 0, 0); glVertex3fv(this->v1); glNormal3fv(this->n); glMultiTexCoord2fv(GL_TEXTURE0, t2); glMultiTexCoord2f(GL_TEXTURE1, 0, 1); glVertex3fv(this->v2); glNormal3fv(this->n); glMultiTexCoord2fv(GL_TEXTURE0, t3); glMultiTexCoord2f(GL_TEXTURE1, 1, 1); glVertex3fv(this->v3); glNormal3fv(this->n); glMultiTexCoord2fv(GL_TEXTURE0, t4); glMultiTexCoord2f(GL_TEXTURE1, 1, 0); glVertex3fv(this->v4); glEnd(); glFlush(); //glDisable(GL_TEXTURE_2D); glActiveTexture(GL_TEXTURE0); glDisable(GL_TEXTURE_2D); glActiveTexture(GL_TEXTURE1); glDisable(GL_TEXTURE_2D); glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL_MODELVIEW); //glEnable(GL_COLOR_MATERIAL); }
void GLVertexGridDirect::setTexCoord(int i, int j) { Vec2 p; for (int k = 0; k < numLayers; k++) { getPoint(k, i, j, p); glMultiTexCoord2f(GL_TEXTURE0 + k, p.x*gridw[k], p.y*gridh[k]); } }
GLvoid glMultiTexCoord1f(GLenum tex, GLfloat s) { GLuint ind = tex - GL_TEXTURE0; if (vt_coordsize[ind] > 1){ glMultiTexCoord2f(tex, s, 0.0); } else { vt_coordsize[ind] = 1; vt_current->coord[ind].s = s; } }
void MeshCallbackTeamColor::execute(const Mesh *mesh){ //team color if(mesh->getCustomTexture() && teamTexture!=NULL){ //texture 0 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); //set color to interpolation glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE1); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA); //set alpha to 1 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); //texture 1 glActiveTexture(GL_TEXTURE1); glMultiTexCoord2f(GL_TEXTURE1, 0.f, 0.f); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, static_cast<const Texture2DGl*>(teamTexture)->getHandle()); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); //set alpha to 1 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); glActiveTexture(GL_TEXTURE0); } else{ glActiveTexture(GL_TEXTURE1); glDisable(GL_TEXTURE_2D); glActiveTexture(GL_TEXTURE0); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } }
/** * Zeichnet einen Vertex (glVertex) mit Texturkoordinaten und gegebenfalls Farbinformationen aber ohne Normale. */ void SGLVektor::DrawVertex() { /* Setzt wenn gegeben Texturkoordinaten für alle Texturrenderer vom der aktiven bis zu GL_TEXTURE0_ARB herunter. (Aber immer nur die Selben) */ std::stringstream buff; bool texOK=false; #ifndef WIN32 if(SGLTextur::TexLoaded) { short coord=texKoord.size(); if(coord<SGLTextur::TexLoaded) { buff << *this; SGLprintWarning("Die geladene Textur hat %d Dimensionen, die Texturkoordinaten des Vertex \"%s\" sind aber nur %d-Dimensional",SGLTextur::TexLoaded,buff.str().c_str(),coord); } int i=GL_TEXTURE0_ARB+SGLTextur::multitex_layer ;//@todo dirty Hack switch(SGLTextur::TexLoaded > coord ? coord:SGLTextur::TexLoaded ) { case 1: for(;i>=GL_TEXTURE0_ARB;i--) glMultiTexCoord1f(i,texKoord[0]); break; case 2: for(;i>=GL_TEXTURE0_ARB;i--) glMultiTexCoord2f(i,texKoord[0], texKoord[1]); break; case 3: for(;i>=GL_TEXTURE0_ARB;i--) glMultiTexCoord3f(i,texKoord[0], texKoord[1],texKoord[2]); break; default:{ buff << *this; SGLprintError("Texturtyp (%d) passt nicht zu den verfügbaren Texturkoordinaten beim Zeichnen des Vertex \"%s\"",SGLTextur::TexLoaded, coord,buff.str().c_str());}break; } texOK=true;//@todo naja nich immer } #else // "Texture loading is currently not supportet for Windows" #endif if(!SGLMaterial::MatLoaded && !texOK) { if(SGLV_R>=0 || SGLV_G>=0 || SGLV_B>=0)glColor3dv(Color); else{ buff << *this; SGLprintWarning("Keine Farbinformationen verfgbar beim Zeichnen des Vertex \"%s\"",buff.str().c_str()); } } DrawPureVertex(); }
void Lookup1D_UndistortionFilter::undistortIntensityImage(unsigned char const * image, unsigned char * result) { _srcTex.overwriteWith(image, 1); _destBuffer.activate(); setupNormalizedProjection(); float const lutScale = _pixelSize / _lutSize; radialLUTShader->parameter("lutScale", lutScale); radialLUTShader->parameter("center", _center[0], _center[1]); radialLUTShader->parameter("wh", _width, _height, 1.0f/_width, 1.0f/_height); _srcTex.enable(GL_TEXTURE0); glActiveTexture(GL_TEXTURE1_ARB); glBindTexture(GL_TEXTURE_1D, _lut1DTexID); glEnable(GL_TEXTURE_1D); radialLUTShader->enable(); glBegin(GL_TRIANGLES); glMultiTexCoord2f(GL_TEXTURE0_ARB, 0, 0); glVertex2f(0, 0); glMultiTexCoord2f(GL_TEXTURE0_ARB, 2*_width, 0); glVertex2f(2, 0); glMultiTexCoord2f(GL_TEXTURE0_ARB, 0, 2*_height); glVertex2f(0, 2); glEnd(); radialLUTShader->disable(); _srcTex.disable(GL_TEXTURE0); glActiveTexture(GL_TEXTURE1_ARB); glDisable(GL_TEXTURE_1D); glReadPixels(0, 0, _width, _height, GL_RED, GL_UNSIGNED_BYTE, result); } // end Lookup1D_UndistortionFilter::undistortIntensityImage()
inline void SetTexCoord (tUVL *uvlList, int nOrient, int bMulti, tTexCoord2f *texCoord, int bMask) { float u1, v1; if (nOrient == 1) { u1 = 1.0f - X2F (uvlList->v); v1 = X2F (uvlList->u); } else if (nOrient == 2) { u1 = 1.0f - X2F (uvlList->u); v1 = 1.0f - X2F (uvlList->v); } else if (nOrient == 3) { u1 = X2F (uvlList->v); v1 = 1.0f - X2F (uvlList->u); } else { u1 = X2F (uvlList->u); v1 = X2F (uvlList->v); } if (texCoord) { texCoord->v.u = u1; texCoord->v.v = v1; } else { #if OGL_MULTI_TEXTURING if (bMulti) { glMultiTexCoord2f (GL_TEXTURE1, u1, v1); if (bMask) glMultiTexCoord2f (GL_TEXTURE2, u1, v1); } else #endif glTexCoord2f (u1, v1); } }
void Vertex( float u, float v ) { float theta = (float) (u * 2.0 * M_PI); float rho = (float) (v * 2.0 * M_PI); float x = (float) (cos( theta ) * ( circleRadius + cos( rho ) * tubeRadius )); float y = (float) (sin( theta ) * ( circleRadius + cos( rho ) * tubeRadius )); float z = (float) (sin( rho ) * tubeRadius); float nx = (float) (cos( rho ) * cos(theta)); float ny = (float) (cos( rho ) * sin(theta)); float nz = (float) (sin( rho )); glNormal3f( nx, ny, nz ); glMultiTexCoord2f( texunit, u, v ); glVertex3f( x, y, z ); }
glue_static void glue2dquad2(void) { glBegin(GL_QUADS); glMultiTexCoord2f(GL_TEXTURE0_ARB, 0, 1); glMultiTexCoord2f(GL_TEXTURE1_ARB, 0, 1); glVertex2f(-1, -1); glMultiTexCoord2f(GL_TEXTURE0_ARB, 1, 1); glMultiTexCoord2f(GL_TEXTURE1_ARB, 1, 1); glVertex2f( 1, -1); glMultiTexCoord2f(GL_TEXTURE0_ARB, 1, 0); glMultiTexCoord2f(GL_TEXTURE1_ARB, 1, 0); glVertex2f( 1, 1); glMultiTexCoord2f(GL_TEXTURE0_ARB, 0, 0); glMultiTexCoord2f(GL_TEXTURE1_ARB, 0, 0); glVertex2f(-1, 1); glEnd(); }
void DrawCylinder(GLfloat radius, GLfloat height, GLint slices, GLfloat xTexScale, GLfloat yTexScale) { GLfloat angleInc = (2.0f * 3.14159265f) / (GLfloat)slices; GLint i; glBegin(GL_QUAD_STRIP); for (i = 0; i <= slices; i++) { glMultiTexCoord2f(GL_TEXTURE0, xTexScale * i / (GLfloat)slices, 0.0f); glMultiTexCoord3f(GL_TEXTURE1, cos((angleInc * i) + (3.14159265f * 0.5f)), 0.0f, sin((angleInc * i) + (3.14159265f * 0.5f))); // tangent glMultiTexCoord3f(GL_TEXTURE2, 0.0f, 1.0f, 0.0f); // binormal glMultiTexCoord3f(GL_TEXTURE3, cos(angleInc * i), 0.0f, sin(angleInc * i)); // normal glVertex3f(radius * cos(angleInc * i), -height*0.5f, radius * sin(angleInc * i)); glMultiTexCoord2f(GL_TEXTURE0, xTexScale * i / (GLfloat)slices, yTexScale); glVertex3f(radius * cos(angleInc * i), height*0.5f, radius * sin(angleInc * i)); } glEnd(); glBegin(GL_TRIANGLE_FAN); glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0.0f); glMultiTexCoord3f(GL_TEXTURE1, 1.0f, 0.0f, 0.0f); // tangent glMultiTexCoord3f(GL_TEXTURE2, 0.0f, 0.0f, 1.0f); // binormal glMultiTexCoord3f(GL_TEXTURE3, 0.0f, 1.0f, 0.0f); // normal glVertex3f(0.0f, height*0.5f, 0.0f); for (i = 0; i <= slices; i++) { glMultiTexCoord2f(GL_TEXTURE0, xTexScale * cos(angleInc * i) * 0.159155f, xTexScale * sin(angleInc * i) * 0.159155f); glVertex3f(radius * cos(angleInc * -i), height*0.5f, radius * sin(angleInc * -i)); } glEnd(); glBegin(GL_TRIANGLE_FAN); glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0.0f); glMultiTexCoord3f(GL_TEXTURE1, -1.0f, 0.0f, 0.0f); // tangent glMultiTexCoord3f(GL_TEXTURE2, 0.0f, 0.0f, -1.0f); // binormal glMultiTexCoord3f(GL_TEXTURE3, 0.0f, -1.0f, 0.0f); // normal glVertex3f(0.0f, -height*0.5f, 0.0f); for (i = 0; i <= slices; i++) { glMultiTexCoord2f(GL_TEXTURE0, xTexScale * cos(angleInc * i) * 0.159155f, xTexScale * sin(angleInc * i) * 0.159155f); glVertex3f(radius * cos(angleInc * i), -height*0.5f, radius * sin(angleInc * i)); } glEnd(); }
void Renderer::DrawFullScreenQuad(float min_x, float max_x, float min_y, float max_y) { //draw fullscreen quad to trigger fragment processing glBegin(GL_TRIANGLE_STRIP); glMultiTexCoord2f(GL_TEXTURE0, min_x, min_y); glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 0.0f); glVertex2f(0.0f, 0.0f); glMultiTexCoord2f(GL_TEXTURE0, max_x, min_y); glMultiTexCoord2f(GL_TEXTURE1, 1.0f, 0.0f); glVertex2f(1.0f, 0.0f); glMultiTexCoord2f(GL_TEXTURE0, min_x, max_y); glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 1.0f); glVertex2f(0.0f, 1.0f); glMultiTexCoord2f(GL_TEXTURE0, max_x, max_y); glMultiTexCoord2f(GL_TEXTURE1, 1.0f, 1.0f); glVertex2f(1.0f, 1.0f); glEnd(); }
void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); #if USE_VERSION_1_1 glBindTexture(GL_TEXTURE_2D, texName); #endif glBegin(GL_QUADS); #ifdef USE_UNIT glMultiTexCoord2f(USE_UNIT, 0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); glMultiTexCoord2f(USE_UNIT, 0.0, 1.0); glVertex3f(-2.0, 1.0, 0.0); glMultiTexCoord2f(USE_UNIT, 1.0, 1.0); glVertex3f(0.0, 1.0, 0.0); glMultiTexCoord2f(USE_UNIT, 1.0, 0.0); glVertex3f(0.0, -1.0, 0.0); glMultiTexCoord2f(USE_UNIT, 0.0, 0.0); glVertex3f(1.0, -1.0, 0.0); glMultiTexCoord2f(USE_UNIT, 0.0, 1.0); glVertex3f(1.0, 1.0, 0.0); glMultiTexCoord2f(USE_UNIT, 1.0, 1.0); glVertex3f(2.41421, 1.0, -1.41421); glMultiTexCoord2f(USE_UNIT, 1.0, 0.0); glVertex3f(2.41421, -1.0, -1.41421); #else glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); glTexCoord2f(0.0, 1.0); glVertex3f(-2.0, 1.0, 0.0); glTexCoord2f(1.0, 1.0); glVertex3f(0.0, 1.0, 0.0); glTexCoord2f(1.0, 0.0); glVertex3f(0.0, -1.0, 0.0); glTexCoord2f(0.0, 0.0); glVertex3f(1.0, -1.0, 0.0); glTexCoord2f(0.0, 1.0); glVertex3f(1.0, 1.0, 0.0); glTexCoord2f(1.0, 1.0); glVertex3f(2.41421, 1.0, -1.41421); glTexCoord2f(1.0, 0.0); glVertex3f(2.41421, -1.0, -1.41421); #endif glEnd(); glFlush(); glDisable(GL_TEXTURE_2D); }
void duck::useBonus() { switch(bonus) { case 1: // no bonus textureSwitch(true, false, false, false, false); glActiveTexture(GL_TEXTURE0); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex2i(-1,0); glTexCoord2f(flip,0); glVertex2i(1,0); glTexCoord2f(flip,1); glVertex2i(1,2); glTexCoord2f(0,1); glVertex2i(-1,2); glEnd(); break; case 2: // 2x textureSwitch(true, true, false, false, false); glBegin(GL_QUADS); glMultiTexCoord2f(GL_TEXTURE0, 0,0); glMultiTexCoord2f(GL_TEXTURE1, 0,0); glVertex2i(-1,0); glMultiTexCoord2f(GL_TEXTURE0, flip,0); glMultiTexCoord2f(GL_TEXTURE1, 1,0); glVertex2i(1,0); glMultiTexCoord2f(GL_TEXTURE0, flip,1); glMultiTexCoord2f(GL_TEXTURE1, 1,1); glVertex2i(1,2); glMultiTexCoord2f(GL_TEXTURE0, 0,1); glMultiTexCoord2f(GL_TEXTURE1, 0,1); glVertex2i(-1,2); glEnd(); break; case -2: // -2x textureSwitch(true, false, true, false, false); glBegin(GL_QUADS); glMultiTexCoord2f(GL_TEXTURE0, 0,0); glMultiTexCoord2f(GL_TEXTURE2, 0,0); glVertex2i(-1,0); glMultiTexCoord2f(GL_TEXTURE0, flip,0); glMultiTexCoord2f(GL_TEXTURE2, 1,0); glVertex2i(1,0); glMultiTexCoord2f(GL_TEXTURE0, flip,1); glMultiTexCoord2f(GL_TEXTURE2, 1,1); glVertex2i(1,2); glMultiTexCoord2f(GL_TEXTURE0, 0,1); glMultiTexCoord2f(GL_TEXTURE2, 0,1); glVertex2i(-1,2); glEnd(); break; case 4: // 4x textureSwitch(true, false, false, true, false); glBegin(GL_QUADS); glMultiTexCoord2f(GL_TEXTURE0, 0,0); glMultiTexCoord2f(GL_TEXTURE3, 0,0); glVertex2i(-1,0); glMultiTexCoord2f(GL_TEXTURE0, flip,0); glMultiTexCoord2f(GL_TEXTURE3, 1,0); glVertex2i(1,0); glMultiTexCoord2f(GL_TEXTURE0, flip,1); glMultiTexCoord2f(GL_TEXTURE3, 1,1); glVertex2i(1,2); glMultiTexCoord2f(GL_TEXTURE0, 0,1); glMultiTexCoord2f(GL_TEXTURE3, 0,1); glVertex2i(-1,2); glEnd(); break; default: // force other situations to be bonus = 1. bonus = 1; textureSwitch(true, false, false, false, false); glActiveTexture(GL_TEXTURE0); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex2i(-1,0); glTexCoord2f(flip,0); glVertex2i(1,0); glTexCoord2f(flip,1); glVertex2i(1,2); glTexCoord2f(0,1); glVertex2i(-1,2); glEnd(); break; } }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL13_nglMultiTexCoord2f(JNIEnv *env, jclass clazz, jint target, jfloat s, jfloat t, jlong function_pointer) { glMultiTexCoord2fPROC glMultiTexCoord2f = (glMultiTexCoord2fPROC)((intptr_t)function_pointer); glMultiTexCoord2f(target, s, t); }
/////////////////////////////////////////////////////////////////////////////// /// private static dessinerGrilleDeQuads \n /// Fonction privée utilitaire appelée à l'interne pour générer la grille de quads /// de la carte d'identité. /// /// @param [in] largeur float /// @param [in] hauteur float /// @param [in] nbRangees int /// @param [in] nbColonnes in /// @param [in] normaleVersExt bool décrit si les normales seront vers nous ou pas. /// /// @return Aucune /// /// @author Frédéric Plourde /// @date 2008-02-20 /// /////////////////////////////////////////////////////////////////////////////// void CCarte::dessinerGrilleDeQuads(float largeur, float hauteur, int nbRangees, int nbColonnes, bool normaleVersExt) { int normFact = normaleVersExt ? 1 : -1; float startX = -largeur/2.0f; float startZ = hauteur/2.0f; float s1, t1, s2, t2; float incrementX = largeur / (float)nbColonnes; float incrementZ = hauteur / (float)nbRangees; glBegin(GL_QUADS); glNormal3f(0.0, normFact, 0.0); glVertexAttrib3f(CCst::indexTangente, 1.0, 0.0, 0.0); for (int i=0;i<nbColonnes;i++) { for (int k=0;k<nbRangees;k++) { s1 = (i*incrementX)/largeur; s2 = ((i+1)*incrementX)/largeur; t1 = (k*incrementZ)/hauteur; t2 = ((k+1)*incrementZ)/hauteur; glMultiTexCoord2f(GL_TEXTURE0, s1, t1); glMultiTexCoord2f(GL_TEXTURE1, s1, t1); glMultiTexCoord2f(GL_TEXTURE2, s1, t1); glVertex3f(startX + i*incrementX, 0.0f, startZ - k*incrementZ); glMultiTexCoord2f(GL_TEXTURE0, s2, t1); glMultiTexCoord2f(GL_TEXTURE1, s2, t1); glMultiTexCoord2f(GL_TEXTURE2, s2, t1); glVertex3f((startX + i*incrementX) + incrementX, 0.0f, startZ - k*incrementZ); glMultiTexCoord2f(GL_TEXTURE0, s2, t2); glMultiTexCoord2f(GL_TEXTURE1, s2, t2); glMultiTexCoord2f(GL_TEXTURE2, s2, t2); glVertex3f((startX + i*incrementX) + incrementX, 0.0f, (startZ - k*incrementZ) - incrementZ); glMultiTexCoord2f(GL_TEXTURE0, s1, t2); glMultiTexCoord2f(GL_TEXTURE1, s1, t2); glMultiTexCoord2f(GL_TEXTURE2, s1, t2); glVertex3f(startX + i*incrementX, 0.0f, (startZ - k*incrementZ) - incrementZ); } } glEnd(); }
static void Init( void ) { const char * const ver_string = (const char * const) glGetString( GL_VERSION ); float ver = strtof( ver_string, NULL ); GLint tex_units; GLint temp[ 256 ]; printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); printf("GL_VERSION = %s\n", ver_string); if ( (!glutExtensionSupported("GL_ARB_multitexture") && (ver < 1.3)) || (!glutExtensionSupported("GL_ARB_texture_env_combine") && !glutExtensionSupported("GL_EXT_texture_env_combine") && (ver < 1.3)) || (!glutExtensionSupported("GL_ARB_texture_env_crossbar") && !glutExtensionSupported("GL_NV_texture_env_combine4") && (ver < 1.4)) ) { printf("\nSorry, this program requires GL_ARB_multitexture and either\n" "GL_ARB_texture_env_combine or GL_EXT_texture_env_combine (or OpenGL 1.3).\n" "Either GL_ARB_texture_env_crossbar or GL_NV_texture_env_combine4 (or\n" "OpenGL 1.4) are also required.\n"); if (!Interactive) printf("PIGLIT: {'result': 'fail' }\n"); exit(1); } glGetIntegerv( GL_MAX_TEXTURE_UNITS, & tex_units ); if ( tex_units < 2 ) { printf("\nSorry, this program requires at least 2 texture units.\n"); if (!Interactive) printf("PIGLIT: {'result': 'fail' }\n"); exit(1); } if (Interactive) printf("\nAll %lu squares should be the same color.\n", (unsigned long) NUM_TESTS + 1); (void) memset( temp, 0x00, sizeof( temp ) ); glBindTexture( GL_TEXTURE_2D, 1 ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, temp ); (void) memset( temp, 0x7f, sizeof( temp ) ); glBindTexture( GL_TEXTURE_2D, 2 ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, temp ); (void) memset( temp, 0xff, sizeof( temp ) ); glBindTexture( GL_TEXTURE_2D, 3 ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, temp ); (void) memset( temp, 0x3f, sizeof( temp ) ); glBindTexture( GL_TEXTURE_2D, 4 ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, temp ); glNewList( 1, GL_COMPILE ); glTranslatef(3.0, 0, 0); glBegin(GL_QUADS); glColor3f( 0.9, 0.0, 0.0 ); glMultiTexCoord2f( GL_TEXTURE0, 0.5, 0.5 ); glMultiTexCoord2f( GL_TEXTURE1, 0.5, 0.5 ); glVertex2f(-1, -1); glVertex2f( 1, -1); glVertex2f( 1, 1); glVertex2f(-1, 1); glEnd(); glEndList(); Reshape(Width, Height); }
void Sum::reduce(GLuint texture, int w, int h, int W, int H) { reshape( W, H ); float eps = 0.5; float tap4X, tap4Y, tap5X, tap5Y, tap6X, tap6Y, tap7X, tap7Y; if( w/W == 2 && h/H == 2 ) { cgGLBindProgram(fragmentProgram4tap); glBindTexture(GL_TEXTURE_RECTANGLE_NV, texture ); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); glBegin(GL_QUADS); glMultiTexCoord2f( GL_TEXTURE0_ARB, 0.0+eps , 0.0+eps ); glMultiTexCoord2f( GL_TEXTURE1_ARB, 0.0-1+eps , 0.0 +eps ); glMultiTexCoord2f( GL_TEXTURE2_ARB, 0.0 +eps , -1.0 +eps ); glMultiTexCoord2f( GL_TEXTURE3_ARB, 0.0-1 +eps , -1.0 +eps ); glVertex2f( 0, 0); glMultiTexCoord2f( GL_TEXTURE0_ARB, (float)w +eps , 0.0+eps ); glMultiTexCoord2f( GL_TEXTURE1_ARB, (float)w-1 +eps , 0.0+eps ); glMultiTexCoord2f( GL_TEXTURE2_ARB, (float)w +eps , -1.0+eps ); glMultiTexCoord2f( GL_TEXTURE3_ARB, (float)w-1 +eps , -1.0+eps ); glVertex2f( W, 0); glMultiTexCoord2f( GL_TEXTURE0_ARB, (float)w+eps , (float)h+eps ); glMultiTexCoord2f( GL_TEXTURE1_ARB, (float)w-1+eps , (float)h+eps ); glMultiTexCoord2f( GL_TEXTURE2_ARB, (float)w+eps , (float)h-1.0+eps ); glMultiTexCoord2f( GL_TEXTURE3_ARB, (float)w-1+eps , (float)h-1.0+eps ); glVertex2f(W,H); glMultiTexCoord2f( GL_TEXTURE0_ARB, 0.0+eps, (float)h+eps ); glMultiTexCoord2f( GL_TEXTURE1_ARB, 0.0-1+eps, (float)h+eps ); glMultiTexCoord2f( GL_TEXTURE2_ARB, 0.0+eps, (float)h-1.0+eps ); glMultiTexCoord2f( GL_TEXTURE3_ARB, 0.0-1+eps, (float)h-1.0 +eps ); glVertex2f( 0, H); glEnd(); errcheck(); return; } else if ( w/W == 4 && h/H == 2) { tap4X = -2.0 + eps; tap4Y = -1.0 + eps; tap5X = +1.0 + eps; tap5Y = -1.0 + eps; tap6X = -2.0 + eps; tap6Y = 0.0 + eps; tap7X = +1.0 + eps; tap7Y = 0.0 + eps; cgGLBindProgram(fragmentProgram8tap); } else if ( w/W == 2 && h/H == 4 ) { tap4X = -1.0 + eps; tap4Y = +1.0 + eps; tap5X = 0.0 + eps; tap5Y = +1.0 + eps; tap6X = -1.0 + eps; tap6Y = -2.0 + eps; tap7X = 0.0 + eps; tap7Y = -2.0 + eps; cgGLBindProgram(fragmentProgram8tapY); } else { assert(0); } //cerr<<"Red from "<<w<<"x"<<h<<" to "<<W<<"x"<<H<<endl; glBindTexture(GL_TEXTURE_RECTANGLE_NV, texture ); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); glBegin(GL_QUADS); glMultiTexCoord2f( GL_TEXTURE0_ARB, 0.0+eps , 0.0+eps ); glMultiTexCoord2f( GL_TEXTURE1_ARB, 0.0-1+eps , 0.0 +eps ); glMultiTexCoord2f( GL_TEXTURE2_ARB, 0.0 +eps , -1.0 +eps ); glMultiTexCoord2f( GL_TEXTURE3_ARB, 0.0-1 +eps , -1.0 +eps ); glMultiTexCoord2f( GL_TEXTURE4_ARB, tap4X, tap4Y); glMultiTexCoord2f( GL_TEXTURE5_ARB, tap5X, tap5Y ); glMultiTexCoord2f( GL_TEXTURE6_ARB, tap6X, tap6Y ); glMultiTexCoord2f( GL_TEXTURE7_ARB, tap7X, tap7Y ); glVertex2f( 0, 0); glMultiTexCoord2f( GL_TEXTURE0_ARB, (float)w +eps , 0.0+eps ); glMultiTexCoord2f( GL_TEXTURE1_ARB, (float)w-1 +eps , 0.0+eps ); glMultiTexCoord2f( GL_TEXTURE2_ARB, (float)w +eps , -1.0+eps ); glMultiTexCoord2f( GL_TEXTURE3_ARB, (float)w-1 +eps , -1.0+eps ); glMultiTexCoord2f( GL_TEXTURE4_ARB, (float)w +tap4X , tap4Y); glMultiTexCoord2f( GL_TEXTURE5_ARB, (float)w +tap5X , tap5Y); glMultiTexCoord2f( GL_TEXTURE6_ARB, (float)w +tap6X , tap6Y); glMultiTexCoord2f( GL_TEXTURE7_ARB, (float)w +tap7X , tap7Y); glVertex2f( W, 0); glMultiTexCoord2f( GL_TEXTURE0_ARB, (float)w+eps , (float)h+eps ); glMultiTexCoord2f( GL_TEXTURE1_ARB, (float)w-1+eps , (float)h+eps ); glMultiTexCoord2f( GL_TEXTURE2_ARB, (float)w+eps , (float)h-1.0+eps ); glMultiTexCoord2f( GL_TEXTURE3_ARB, (float)w-1+eps , (float)h-1.0+eps ); glMultiTexCoord2f( GL_TEXTURE4_ARB, (float)w+tap4X, (float)h+tap4Y ); glMultiTexCoord2f( GL_TEXTURE5_ARB, (float)w+tap5X, (float)h+tap5Y ); glMultiTexCoord2f( GL_TEXTURE6_ARB, (float)w+tap6X, (float)h+tap6Y ); glMultiTexCoord2f( GL_TEXTURE7_ARB, (float)w+tap7X, (float)h+tap7Y ); glVertex2f(W,H); glMultiTexCoord2f( GL_TEXTURE0_ARB, 0.0+eps, (float)h+eps ); glMultiTexCoord2f( GL_TEXTURE1_ARB, 0.0-1+eps, (float)h+eps ); glMultiTexCoord2f( GL_TEXTURE2_ARB, 0.0+eps, (float)h-1.0+eps ); glMultiTexCoord2f( GL_TEXTURE3_ARB, 0.0-1+eps, (float)h-1.0 +eps ); glMultiTexCoord2f( GL_TEXTURE4_ARB, 0.0+tap4X, (float)h+tap4Y ); glMultiTexCoord2f( GL_TEXTURE5_ARB, 0.0+tap5X, (float)h+tap5Y ); glMultiTexCoord2f( GL_TEXTURE6_ARB, 0.0+tap6X, (float)h+tap6Y ); glMultiTexCoord2f( GL_TEXTURE7_ARB, 0.0+tap7X, (float)h+tap7Y ); glVertex2f( 0, H); glEnd(); /* float r[4]; glReadPixels(0,0,1,1,GL_RGBA,GL_FLOAT,r); cerr<<"r=["<<r[0]<<","<<r[1]<<","<<r[2]<<","<<r[3]<<"]"<<endl; */ errcheck(); }
void DrawBox(GLfloat size, GLfloat texScale) { size *= 0.5f; glBegin(GL_QUADS); glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0.0f); glMultiTexCoord3f(GL_TEXTURE1, 1.0f, 0.0f, 0.0f); // tangent glMultiTexCoord3f(GL_TEXTURE2, 0.0f, 1.0f, 0.0f); // binormal glMultiTexCoord3f(GL_TEXTURE3, 0.0f, 0.0f, -1.0f); // normal glVertex3f(-size, -size, -size); glMultiTexCoord2f(GL_TEXTURE0, 0.0f, texScale); glVertex3f(-size, size, -size); glMultiTexCoord2f(GL_TEXTURE0, texScale, texScale); glVertex3f(size, size, -size); glMultiTexCoord2f(GL_TEXTURE0, texScale, 0.0f); glVertex3f(size, -size, -size); glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0.0f); glMultiTexCoord3f(GL_TEXTURE1, -1.0f, 0.0f, 0.0f);// tangent glMultiTexCoord3f(GL_TEXTURE2, 0.0f, 1.0f, 0.0f); // binormal glMultiTexCoord3f(GL_TEXTURE3, 0.0f, 0.0f, 1.0f); // normal glVertex3f(size, -size, size); glMultiTexCoord2f(GL_TEXTURE0, 0.0f, texScale); glVertex3f(size, size, size); glMultiTexCoord2f(GL_TEXTURE0, texScale, texScale); glVertex3f(-size, size, size); glMultiTexCoord2f(GL_TEXTURE0, texScale, 0.0f); glVertex3f(-size, -size, size); glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0.0f); glMultiTexCoord3f(GL_TEXTURE1, 0.0f, 0.0f, 1.0f); // tangent glMultiTexCoord3f(GL_TEXTURE2, 0.0f, 1.0f, 0.0f); // binormal glMultiTexCoord3f(GL_TEXTURE3, 1.0f, 0.0f, 0.0f); // normal glVertex3f(size, -size, -size); glMultiTexCoord2f(GL_TEXTURE0, 0.0f, texScale); glVertex3f(size, size, -size); glMultiTexCoord2f(GL_TEXTURE0, texScale, texScale); glVertex3f(size, size, size); glMultiTexCoord2f(GL_TEXTURE0, texScale, 0.0f); glVertex3f(size, -size, size); glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0.0f); glMultiTexCoord3f(GL_TEXTURE1, 0.0f, 0.0f, -1.0f); // tangent glMultiTexCoord3f(GL_TEXTURE2, 0.0f, 1.0f, 0.0f); // binormal glMultiTexCoord3f(GL_TEXTURE3, -1.0f, 0.0f, 0.0f); // normal glVertex3f(-size, -size, size); glMultiTexCoord2f(GL_TEXTURE0, 0.0f, texScale); glVertex3f(-size, size, size); glMultiTexCoord2f(GL_TEXTURE0, texScale, texScale); glVertex3f(-size, size, -size); glMultiTexCoord2f(GL_TEXTURE0, texScale, 0.0f); glVertex3f(-size, -size, -size); glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0.0f); glMultiTexCoord3f(GL_TEXTURE1, 1.0f, 0.0f, 0.0f); // tangent glMultiTexCoord3f(GL_TEXTURE2, 0.0f, 0.0f, 1.0f); // binormal glMultiTexCoord3f(GL_TEXTURE3, 0.0f, 1.0f, 0.0f); // normal glVertex3f(-size, size, -size); glMultiTexCoord2f(GL_TEXTURE0, 0.0f, texScale); glVertex3f(-size, size, size); glMultiTexCoord2f(GL_TEXTURE0, texScale, texScale); glVertex3f(size, size, size); glMultiTexCoord2f(GL_TEXTURE0, texScale, 0.0f); glVertex3f(size, size, -size); glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0.0f); glMultiTexCoord3f(GL_TEXTURE1, 1.0f, 0.0f, 0.0f); // tangent glMultiTexCoord3f(GL_TEXTURE2, 0.0f, 0.0f, -1.0f); // binormal glMultiTexCoord3f(GL_TEXTURE3, 0.0f, -1.0f, 0.0f); // normal glVertex3f(-size, -size, size); glMultiTexCoord2f(GL_TEXTURE0, 0.0f, texScale); glVertex3f(-size, -size, -size); glMultiTexCoord2f(GL_TEXTURE0, texScale, texScale); glVertex3f(size, -size, -size); glMultiTexCoord2f(GL_TEXTURE0, texScale, 0.0f); glVertex3f(size, -size, size); glEnd(); }
void glMultiTexCoord(const vec2& v, const GLint u) { glMultiTexCoord2f(u, v.x, v.y); }
// wyietla ekran adowania z danym procentem int HEngineCore::LoadingScreenUpdate ( float percent ) { /* DONE (#1#): Implement HEngineCore::LoadingScreenUpdate() */ glClear ( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT );//GL_COLOR_BUFFER_BIT| glActiveTexture ( GL_TEXTURE0_ARB ); glEnable ( GL_TEXTURE_2D ); glTexEnvi ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); glEnable ( GL_BLEND ); glColor4f ( 1,1,1,1 ); glPushAttrib ( GL_COLOR_BUFFER_BIT|GL_ENABLE_BIT|GL_TEXTURE_BIT ); glMatrixMode ( GL_PROJECTION ); glPushMatrix(); glLoadIdentity(); gluOrtho2D ( 0, HRendererWindow::GetSingleton().GetWidth(), HRendererWindow::GetSingleton().GetHeight(), 0 ); glMatrixMode ( GL_MODELVIEW ); glPushMatrix(); glLoadIdentity(); glDisable ( GL_DEPTH_TEST ); glDisable ( GL_LIGHTING ); glDisable ( GL_CULL_FACE ); glEnable ( GL_BLEND ); // glBlendFunc( GL_ONE, GL_ONE ); // eleminate black src color glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); int leftpos; int rightpos; leftpos=HRendererWindow::GetSingleton().GetWidth() /2-256+30; rightpos= ( int ) ( leftpos+ ( 512-60 ) *percent ); if ( m_iLoadingSlider==0 ) m_iLoadingSlider=HTextureManager::GetSingleton().Load ( "loading_slider" ); HTextureManager::GetSingleton().Bind ( m_iLoadingSlider );// HTextureManager::GetSingleton().Load("loading_slider")); glBegin ( GL_TRIANGLE_FAN ); glMultiTexCoord2f ( GL_TEXTURE0_ARB, 0,0 ); glVertex2i ( leftpos,HRendererWindow::GetSingleton().GetHeight() /2+4 ); glMultiTexCoord2f ( GL_TEXTURE0_ARB, 1,0 ); glVertex2i ( rightpos,HRendererWindow::GetSingleton().GetHeight() /2+4 ); glMultiTexCoord2f ( GL_TEXTURE0_ARB, 1,1 ); glVertex2i ( rightpos,HRendererWindow::GetSingleton().GetHeight() /2+40 ); glMultiTexCoord2f ( GL_TEXTURE0_ARB, 0,1 ); glVertex2i ( leftpos,HRendererWindow::GetSingleton().GetHeight() /2+40 ); glEnd(); if ( m_iLoadingBackground==0 ) m_iLoadingBackground=HTextureManager::GetSingleton().Load ( "loading" ); HTextureManager::GetSingleton().Bind ( m_iLoadingBackground ); glBegin ( GL_TRIANGLE_FAN ); glMultiTexCoord2f ( GL_TEXTURE0_ARB, 0,0 ); glVertex2i ( HRendererWindow::GetSingleton().GetWidth() /2-256,HRendererWindow::GetSingleton().GetHeight() /2-64 ); glMultiTexCoord2f ( GL_TEXTURE0_ARB, 1,0 ); glVertex2i ( HRendererWindow::GetSingleton().GetWidth() /2+256,HRendererWindow::GetSingleton().GetHeight() /2-64 ); glMultiTexCoord2f ( GL_TEXTURE0_ARB, 1,1 ); glVertex2i ( HRendererWindow::GetSingleton().GetWidth() /2+256,HRendererWindow::GetSingleton().GetHeight() /2+64 ); glMultiTexCoord2f ( GL_TEXTURE0_ARB, 0,1 ); glVertex2i ( HRendererWindow::GetSingleton().GetWidth() /2-256,HRendererWindow::GetSingleton().GetHeight() /2+64 ); glEnd(); glMatrixMode ( GL_PROJECTION ); glPopMatrix(); glMatrixMode ( GL_MODELVIEW ); glPopMatrix(); glBindTexture ( GL_TEXTURE_2D, 0 ); glPopAttrib(); m_pFont->DrawText ( ( HRendererWindow::GetSingleton().GetWidth() /2 )- ( strlen ( LoadingScreenTile.c_str() ) *8 ) *0.9,HRendererWindow::GetSingleton().GetHeight() /2+60,16,LoadingScreenTile.c_str() ); m_pFont->DrawText ( 0,0,14,HINFO ); SDL_GL_SwapBuffers(); HRendererWindow::GetSingleton().Update(); }