void FreezeParticle::Render(float x, float y, float z, float theta, float thetaX, float thetaY, float thetaZ) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); cgGLEnableProfile(FreezeParticleProfile); cgGLBindProgram(FreezeParticleProgram); cgGLEnableTextureParameter(FreezeParticleText1); glPushMatrix(); glTranslatef(x,y,z); glTranslatef(mPos.GetX(), mPos.GetY(), mPos.GetZ()); glRotatef(mRotate, 0.2f, 0.5f, 1); glRotatef(theta, thetaX, thetaY, thetaZ); glScalef((30-mLife)/30,(30-mLife)/30,(30-mLife)/30); glBegin(GL_TRIANGLES); glTexCoord3f(0,0,0); glVertex3f(-3,0,0); glTexCoord3f(.5,1,0); glVertex3f(0, 3, 0); glTexCoord3f(0,0,0); glVertex3f(1, 0, 0); glEnd(); glPopMatrix(); cgGLDisableProfile(FreezeParticleProfile); }
void drawGround(void) { glPushMatrix(); //for plane static GLfloat plane_diffuse[] = {0.7, 0.7, 0.7, 1.0}; glMaterialfv(GL_FRONT,GL_DIFFUSE, plane_diffuse); static float step; glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,groundTex); step = 0.08; //gluSphere(sphere, 3.0, 20, 20); glBegin(GL_QUADS); for(float a=-PLANE;a<PLANE;a+=step) { for(float b=-PLANE;b<PLANE;b+=step) { glNormal3f(0,0,1); glTexCoord3f(a, b, 0.0); glVertex3f (a, b, 0.0); glNormal3f(0,0,1); glTexCoord3f(a, (b+step), 0.0);glVertex3f (a, (b+step), 0.0); glNormal3f(0,0,1); glTexCoord3f((a+step), (b+step), 0.0);glVertex3f ((a+step), (b+step), 0.0); glNormal3f(0,0,1); glTexCoord3f((a+step), b, 0.0); glVertex3f ((a+step), b, 0.0); } } glEnd(); glDisable(GL_TEXTURE_2D); glPopMatrix(); }
void CSkyBox::Draw() { //glTranslatef(camera->pos.x, camera->pos.y, camera->pos.z); //glCallList(displist); glDisable(GL_FOG); glColor3f(1,1,1); glDisable(GL_ALPHA_TEST); glDisable(GL_BLEND); glEnable(GL_TEXTURE_CUBE_MAP_ARB); glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, tex); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glDepthMask(0); glDisable(GL_DEPTH_TEST); float3 v1 = camera->CalcPixelDir(0,0); float3 v2 = camera->CalcPixelDir(gu->viewSizeX,0); float3 v3 = camera->CalcPixelDir(gu->viewSizeX,gu->viewSizeY); float3 v4 = camera->CalcPixelDir(0,gu->viewSizeY); glBegin(GL_QUADS); glTexCoord3f(-v1.x,-v1.y,-v1.z); //glNormal3f(0,1,0); glVertexf3(camera->pos + v1*(NEAR_PLANE+5)); glTexCoord3f(-v2.x,-v2.y,-v2.z); //glNormal3f(1,1,0); glVertexf3(camera->pos + v2*(NEAR_PLANE+5)); glTexCoord3f(-v3.x,-v3.y,-v3.z); //glNormal3f(0,1,1); glVertexf3(camera->pos + v3*(NEAR_PLANE+5)); glTexCoord3f(-v4.x,-v4.y,-v4.z); //glNormal3f(1,1,1); glVertexf3(camera->pos + v4*(NEAR_PLANE+5)); glEnd(); glDisable(GL_TEXTURE_CUBE_MAP_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glDepthMask(1); glDisable(GL_ALPHA_TEST); glEnable(GL_DEPTH_TEST); glDisable(GL_BLEND); if (gu->drawFog) { glFogfv(GL_FOG_COLOR,mapInfo->atmosphere.fogColor); glFogi(GL_FOG_MODE,GL_LINEAR); glFogf(GL_FOG_START,gu->viewRange*fogStart); glFogf(GL_FOG_END,gu->viewRange); glFogf(GL_FOG_DENSITY,1.00f); glEnable(GL_FOG); } }
static void Redisplay(void) { CheckError(__LINE__); glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); CheckError(__LINE__); glUseProgram(program); CheckError(__LINE__); glBegin(GL_POLYGON); #if USE_RECT /* scale coords by two to test projection */ glTexCoord4f( 0, 0, 0, 2.0); glVertex2f(-1, -1); glTexCoord4f(2*TEXSIZE, 0, 2*1, 2.0); glVertex2f( 1, -1); glTexCoord4f(2*TEXSIZE, 2*TEXSIZE, 2*1, 2.0); glVertex2f( 1, 1); glTexCoord4f( 0, 2*TEXSIZE, 0, 2.0); glVertex2f(-1, 1); #else glTexCoord3f(0, 0, 0); glVertex2f(-1, -1); glTexCoord3f(1, 0, 1); glVertex2f( 1, -1); glTexCoord3f(1, 1, 1); glVertex2f( 1, 1); glTexCoord3f(0, 1, 0); glVertex2f(-1, 1); #endif glEnd(); glPopMatrix(); glUseProgram(0); glWindowPos2iARB(80, 20); PrintString("white black white black"); glutSwapBuffers(); }
/* Setup display list with "frozen" 3D texture coordinates. */ void generateTexturedSurface(void) { static GLfloat data[8] = { 0, 1, 0, -1 }; int i, j; #define COLS 12 #define ROWS 12 #define TILE_TEX_W (1.0/COLS) #define TILE_TEX_H (1.0/ROWS) glNewList(1, GL_COMPILE); glTranslatef(-COLS / 2.0 + .5, -ROWS / 2.0 + .5, 0); for (j = 0; j < ROWS; j++) { glBegin(GL_QUAD_STRIP); for (i = 0; i < COLS; i++) { glTexCoord3f(i * TILE_TEX_W, j * TILE_TEX_H, data[(i + j) % 4]); glVertex2f(i - .5, j - .5); glTexCoord3f(i * TILE_TEX_W, (j + 1) * TILE_TEX_H, data[(i + j + 1) % 4]); glVertex2f(i - .5, j + .5); } glTexCoord3f((i + 1) * TILE_TEX_W, j * TILE_TEX_H, data[(i + j) % 4]); glVertex2f(i + .5, j - .5); glTexCoord3f((i + 1) * TILE_TEX_W, (j + 1) * TILE_TEX_H, data[(i + j + 1) % 4]); glVertex2f(i + .5, j + .5); glEnd(); } glEndList(); }
void GLWidget::drawSector() { glBindTexture(GL_TEXTURE_2D, texture[0]); Bundle& bundle = model->getBundle(); Vertex& angle = bundle.angle; glRotatef(angle.y, 1.0f, 0.0f, 0.0f); glRotatef(-1 * angle.x, 0.0f, 1.0f, 0.0f); Vertex& position = bundle.position; glTranslatef(position.x, position.y, position.z); Sector sector = bundle.sector; std::vector<Face>::iterator i; glPushMatrix(); glColor3f(1.0f, 1.0f, 1.0f); for (i = sector.faces.begin(); i != sector.faces.end(); ++i) { if (i->quad) { glBegin(GL_QUADS); glNormal3f(0.0f, 0.0f, 1.0f); for (int j = 0; j < 4; ++j) { glTexCoord3f(i->txt[j].x, i->txt[j].y, i->txt[j].z); glVertex3f(i->vertex[j].x, i->vertex[j].y, i->vertex[j].z); } glEnd(); } else { glBegin(GL_TRIANGLES); glNormal3f(0.0f, 0.0f, 1.0f); for (int j = 0; j < 3; ++j) { glTexCoord3f(i->txt[j].x, i->txt[j].y, i->txt[j].z); glVertex3f(i->vertex[j].x, i->vertex[j].y, i->vertex[j].z); } glEnd(); } } glPopMatrix(); }
void RenderTexture(double mdRotation[16], int lCount, EngineOCT &oct) { glMatrixMode(GL_TEXTURE); glLoadIdentity(); // Translate and make 0.5f as the center glTranslatef(0.5f, 0.5f, 0.5f); // A scaling applied to normalize the axis glScaled(((float)oct.NumAScans / (float)oct.NumAScans)*2.0f, (-1.0f*(float)oct.NumAScans / (float)(float)oct.OutputImageHeight)*2.0f, ((float)oct.OutputImageHeight / (float)lCount)*2.0f); glMultMatrixd(mdRotation); glTranslatef(-0.5f, -0.5f, -0.5f); //Texture Mapping glEnable(GL_TEXTURE_3D); glBindTexture(GL_TEXTURE_3D, 1); for (float TexIndex = -1.0f; TexIndex <= 1.0f; TexIndex += renderDensity) { glBegin(GL_QUADS); //Map texels to each Quad glTexCoord3f(0.0f, 0.0f, ((float)TexIndex + 1.0f) / 2.0f); glVertex3f(-dOrthoSize, -dOrthoSize, TexIndex); glTexCoord3f(1.0f, 0.0f, ((float)TexIndex + 1.0f) / 2.0f); glVertex3f(dOrthoSize, -dOrthoSize, TexIndex); glTexCoord3f(1.0f, 1.0f, ((float)TexIndex + 1.0f) / 2.0f); glVertex3f(dOrthoSize, dOrthoSize, TexIndex); glTexCoord3f(0.0f, 1.0f, ((float)TexIndex + 1.0f) / 2.0f); glVertex3f(-dOrthoSize, dOrthoSize, TexIndex); glEnd(); } }
void Floor::draw() const { glPushMatrix(); glTranslatef(x, 0, -static_cast<int>(y)); if (blood == 0) { glBindTexture(GL_TEXTURE_2D, tex1); } else if (blood == 1) { glBindTexture(GL_TEXTURE_2D, tex2); } else if (blood == 2) { glBindTexture(GL_TEXTURE_2D, tex3); } else if (blood == 3) { glBindTexture(GL_TEXTURE_2D, tex4); } else { glBindTexture(GL_TEXTURE_2D, tex5); } glColor4f(1, 1, 1, 1); glBegin(GL_QUADS); glTexCoord3f(0.0, 0.0, 0.0); glVertex3f(0.0, 0.0, 1.0); glTexCoord3f(1.0, 0.0, 0.0); glVertex3f(1.0, 0.0, 1.0); glTexCoord3f(1.0, 1.0, 0.0); glVertex3f(1.0, 0.0, 0.0); glTexCoord3f(0.0, 1.0, 0.0); glVertex3f(0.0, 0.0, 0.0); glEnd(); glPopMatrix(); }
/* Draw a textured quad, sampling only the given depth/slice of the * 3D texture. */ static void draw_depth(int x, int y, int depth) { float depth_coord = (float)depth / (pot_depth - 1); glViewport(0, 0, piglit_width, piglit_height); piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, piglit_winsys_fbo); glEnable(GL_TEXTURE_3D); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); glBegin(GL_QUADS); glTexCoord3f(0, 0, depth_coord); glVertex2f(x, y); glTexCoord3f(1, 0, depth_coord); glVertex2f(x + BUF_WIDTH, y); glTexCoord3f(1, 1, depth_coord); glVertex2f(x + BUF_WIDTH, y + BUF_HEIGHT); glTexCoord3f(0, 1, depth_coord); glVertex2f(x, y + BUF_HEIGHT); glEnd(); }
void PhGraphicTexturedRect::draw() { //PHDEBUG << "PhGraphicTexturedRect::draw()"; glColor3f(_color.redF(), _color.greenF(), _color.blueF()); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glBindTexture(GL_TEXTURE_2D, _texture); glEnable(GL_TEXTURE_2D); // (0,0) ------ (1,0) // | | // | | // (0,1) ------ (1,1) glBegin(GL_QUADS); //Begining the cube's drawing { glTexCoord3f(0, 0, 1); glVertex3f(_x, _y, _z); glTexCoord3f(_tu, 0, 1); glVertex3f(_x + _w, _y, _z); glTexCoord3f(_tu, _tv, 1); glVertex3f(_x + _w, _y + _h, _z); glTexCoord3f(0, _tv, 1); glVertex3f(_x, _y + _h, _z); } glEnd(); glDisable(GL_TEXTURE_2D); }
void emitStrip(Vector v[6], float s1, float s2, float dt, int count, int depth) { if(depth > 0){ emitStrip(v, s1, (s1+s2)/2, dt/2, count*2-1, depth-1); emitStrip(v, (s1+s2)/2, s2, dt/2, count*2-1, depth-1); }else{ glBegin(GL_TRIANGLE_STRIP); /* static Color colors[] = { Color(255,255,0), Color(0,255,255), Color(255,0,255), Color(255,255,255), Color(0,255,0) }; static int i = 0; glColor(colors[(i++)%5]); */ for(int i=0; i<count; i++){ Vector v1 = sampleStrip(v, s1, i*dt); Vector v2 = sampleStrip(v, s2, i*dt); v1 /= length(v1); v2 /= length(v2); glNormal(v1); glTexCoord3f(v1.x, v1.y, v1.z); glVertex(v1); glNormal(v2); glTexCoord3f(v2.x, v2.y, v2.z); glVertex(v2); } glEnd(); } }
void renderFloor(void){ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,grassTexture); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); glBegin(GL_QUADS); glColor3f(0,.5,0); glTexCoord3f(-floorSize,floorLevel,floorSize); glVertex3f(-floorSize, floorLevel, floorSize); // The bottom left corner glTexCoord3f(-floorSize, floorLevel, -floorSize); glVertex3f(-floorSize, floorLevel, -floorSize); // The top left corner glTexCoord3f(floorSize,floorLevel, -floorSize); glVertex3f(floorSize, floorLevel, -floorSize); // The top right corner glTexCoord3f(floorSize,floorLevel,floorSize); glVertex3f(floorSize, floorLevel, floorSize); // The bottom right corner glColor3f(1,1,1); glEnd(); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); glDisable(GL_TEXTURE_2D); }
void polygon::drawFlat(float id, float asp) { float xb = 0, yb = 0; float xd = 1, yd = 1; if (indices[3]>=0) { if (asp>1) { yb = 0.5 - 0.5/asp; yd = 1/asp; } else if (asp<1) { xb = 0.5 - 0.5*asp; xd = asp; } } glTexCoord3f(0,0,id); glVertex3f(xb,yb,0); glTexCoord3f(1,0,id); glVertex3f(xb+xd,yb,0); if (indices[3]<0) { glTexCoord3f(0,1,id); glVertex3f(0.5,0.866025404,0); return; } glTexCoord3f(1,1,id); glVertex3f(xb+xd,yb+yd,0); glTexCoord3f(0,1,id); glVertex3f(xb,yb+yd,0); }
void PhGraphicTexturedRect::draw() { PhGraphicRect::draw(); glBindTexture(GL_TEXTURE_2D, _currentTexture); glEnable(GL_TEXTURE_2D); // (0,0) ------ (1,0) // | | // | | // (0,1) ------ (1,1) glBegin(GL_QUADS); //Begining the cube's drawing { glTexCoord3f(0, 0, 1); glVertex3i(this->x(), this->y(), this->z()); glTexCoord3f(_tu, 0, 1); glVertex3i(this->x() + this->width(), this->y(), this->z()); glTexCoord3f(_tu, _tv, 1); glVertex3i(this->x() + this->width(), this->y() + this->height(), this->z()); glTexCoord3f(0, _tv, 1); glVertex3i(this->x(), this->y() + this->height(), this->z()); } glEnd(); glDisable(GL_TEXTURE_2D); }
//-------------------------------------------------------------- void ofApp::drawTexturedCylinder(){ // draw the texture-mapped cylinder. if ((ofGetWidth() > (playerScaleFactor*warpedW)) && (ofGetHeight() > unwarpedH)) { if (!bMousepressedInUnwarped){ // && !bMousePressedInPlayer){ float A = 0.90; float B = 1.0-A; blurredMouseX = A*blurredMouseX + B*mouseX; blurredMouseY = A*blurredMouseY + B*mouseY; } unwarpedTexture.bind(); glEnable(GL_DEPTH_TEST); glViewport(playerScaleFactor*warpedW, unwarpedH, ofGetWidth()-playerScaleFactor*warpedW, playerScaleFactor*warpedH); // magic numbers float cylz = (ofGetHeight()/768.0) * 300.0; float cylinderRadius = (ofGetHeight()/768.0) * 16*10.00; //175.0; float cylinderHeight = (ofGetHeight()/768.0) * 16*11.44/2.0; // 80.0; glPushMatrix(); glTranslatef(ofGetWidth()/2, ofGetHeight()/2,cylz); if (!bMousePressed){ glTranslatef(0,0,0); ofRotateX(RAD_TO_DEG * ofMap(blurredMouseY, 0, ofGetHeight(), -PI/2, PI/2)); ofRotateY(RAD_TO_DEG * ofMap(blurredMouseX, 0, ofGetWidth(), -PI, PI)); } else { float offsetForOpticalCenter = 0 - cylinderHeight*0.4; // the Bloggie optical center is not in the center of the image. glTranslatef(0, offsetForOpticalCenter,cylz); ofRotateX(RAD_TO_DEG * ofMap(blurredMouseY, 0, ofGetHeight(), -PI/4, PI/4)); ofRotateY(RAD_TO_DEG * ofMap(blurredMouseX, 0, ofGetWidth(), TWO_PI, -TWO_PI)); } ofSetColor(255,255,255); glBegin(GL_QUAD_STRIP); for (int i = 0; i < cylinderRes; i++) { float x = cylinderX[i] * cylinderRadius; float z = cylinderY[i] * cylinderRadius; float u = (float) unwarpedW / (cylinderRes-1) * i; glTexCoord3f(u, 0, 0); glVertex3f (x, 0-cylinderHeight, z); glTexCoord3f(u, unwarpedH, 0); glVertex3f (x, cylinderHeight, z); } glEnd(); glPopMatrix(); unwarpedTexture.unbind(); glDisable(GL_DEPTH_TEST); glViewport(0,0, ofGetWidth(), ofGetHeight()); } }
/* The main drawing function. */ void DrawGLScene (GstGLBuffer * gst_gl_buf) { GLuint texture = gst_gl_buf->texture; GLfloat width = (GLfloat) gst_gl_buf->width; GLfloat height = (GLfloat) gst_gl_buf->height; glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer glLoadIdentity (); // Reset The View glTranslatef (-1.5f, 0.0f, -6.0f); // Move Left 1.5 Units And Into The Screen 6.0 glRotatef (rtri, 0.0f, 1.0f, 0.0f); // Rotate The Triangle On The Y axis // draw a triangle (in smooth coloring mode) glBegin (GL_POLYGON); // start drawing a polygon glColor3f (1.0f, 0.0f, 0.0f); // Set The Color To Red glVertex3f (0.0f, 1.0f, 0.0f); // Top glColor3f (0.0f, 1.0f, 0.0f); // Set The Color To Green glVertex3f (1.0f, -1.0f, 0.0f); // Bottom Right glColor3f (0.0f, 0.0f, 1.0f); // Set The Color To Blue glVertex3f (-1.0f, -1.0f, 0.0f); // Bottom Left glEnd (); // we're done with the polygon (smooth color interpolation) glEnable (GL_TEXTURE_RECTANGLE_ARB); glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture); glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glLoadIdentity (); // make sure we're no longer rotated. glTranslatef (1.5f, 0.0f, -6.0f); // Move Right 3 Units, and back into the screen 6.0 glRotatef (rquad, 1.0f, 0.0f, 0.0f); // Rotate The Quad On The X axis // draw a square (quadrilateral) glColor3f (0.5f, 0.5f, 1.0f); // set color to a blue shade. glBegin (GL_QUADS); // start drawing a polygon (4 sided) glTexCoord3f (0.0f, height, 0.0f); glVertex3f (-1.0f, 1.0f, 0.0f); // Top Left glTexCoord3f (width, height, 0.0f); glVertex3f (1.0f, 1.0f, 0.0f); // Top Right glTexCoord3f (width, 0.0f, 0.0f); glVertex3f (1.0f, -1.0f, 0.0f); // Bottom Right glTexCoord3f (0.0f, 0.0f, 0.0f); glVertex3f (-1.0f, -1.0f, 0.0f); // Bottom Left glEnd (); // done with the polygon glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0); rtri += 1.0f; // Increase The Rotation Variable For The Triangle rquad -= 1.0f; // Decrease The Rotation Variable For The Quad // swap buffers to display, since we're double buffered. SDL_GL_SwapBuffers (); }
void CSkyBox::Draw() { glColor3f(1,1,1); glDisable(GL_FOG); glDisable(GL_BLEND); glDepthMask(0); glDisable(GL_DEPTH_TEST); glDisable(GL_ALPHA_TEST); glEnable(GL_TEXTURE_CUBE_MAP); glBindTexture(GL_TEXTURE_CUBE_MAP, tex); float3 v1 = -camera->CalcPixelDir(0,0); float3 v2 = -camera->CalcPixelDir(gu->viewSizeX,0); float3 v3 = -camera->CalcPixelDir(gu->viewSizeX,gu->viewSizeY); float3 v4 = -camera->CalcPixelDir(0,gu->viewSizeY); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluOrtho2D(0,1,0,1); glBegin(GL_QUADS); glTexCoord3f(v1.x,v1.y,v1.z); glVertex2f(0.0f,1.0f); glTexCoord3f(v2.x,v2.y,v2.z); glVertex2f(1.0f,1.0f); glTexCoord3f(v3.x,v3.y,v3.z); glVertex2f(1.0f,0.0f); glTexCoord3f(v4.x,v4.y,v4.z); glVertex2f(0.0f,0.0f); glEnd(); //glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glDisable(GL_TEXTURE_CUBE_MAP_ARB); glDepthMask(1); glEnable(GL_DEPTH_TEST); glDisable(GL_BLEND); glFogfv(GL_FOG_COLOR,mapInfo->atmosphere.fogColor); glFogi(GL_FOG_MODE,GL_LINEAR); glFogf(GL_FOG_START,gu->viewRange*fogStart); glFogf(GL_FOG_END,gu->viewRange); glFogf(GL_FOG_DENSITY,1.00f); if (gu->drawFog) { glEnable(GL_FOG); } }
void voxel_draw(void) { if(keys[KEY_R]) { keys[KEY_R] = 0; printf("Reloading shader.\n"); glDeleteShader(vert); glDeleteShader(frag); glDeleteProgram(prog); prepare_shader(); } // killme=1; // float3 pos, normal; // pos.x = 0.5 + sin(px)*pz; // pos.y = 0.5; // pos.z = 0.5 + cos(px)*pz; // pos.x = px; pos.y = py; pos.z = pz; // glUseProgram(0); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_3D, brick_tex); glBindBuffer(GL_ARRAY_BUFFER, node_pool); glUseProgram(prog); // glUniform1f(s_fovdepth, tan(radians(fov)*0.5)*0.5); // glUniform1f(s_width, sin(radians(fov)/(float)vid_width)); glUniform3f(s_angle, angle.x, angle.y, angle.z); glUniform3f(s_pos, pos.x, pos.y, pos.z); glUniformui64NV(s_nPool, nodepool_devptr); // glTranslatef(0, ((float)vid_height/(float)vid_width)*0.5-0.5 , 0); glBegin(GL_QUADS); glNormal3f(0,0,-1); // glColor3f(0,0,1); glTexCoord3f(0,0,0); glVertex3f(0,0,0); // glColor3f(1,0,1); glTexCoord3f(1,0,0); glVertex3f(1,0,0); // glColor3f(1,1,1); glTexCoord3f(1,1,0); glVertex3f(1,1,0); // glColor3f(0,1,1); glTexCoord3f(0,1,0); glVertex3f(0,1,0); glEnd(); glUseProgram(0); now ++; // everyone in /r/opengl is crying at this point. }
void polygon::drawFace(std::vector<Vec3f>& verts, float id) { glTexCoord3f(0,0,id); glVertex3fv(verts[indices[0]].getValue()); glTexCoord3f(1,0,id); glVertex3fv(verts[indices[1]].getValue()); if (indices[3]>=0) glTexCoord3f(1,1,id); else glTexCoord3f(0,1,id); glVertex3fv(verts[indices[2]].getValue()); if (indices[3]<0) return; glTexCoord3f(0,1,id); glVertex3fv(verts[indices[3]].getValue()); }
static void draw_quad() { glBegin(GL_QUADS); glTexCoord3f(-0.5, -0.5, 1); glVertex2f(0, 0); glTexCoord3f(0.5, -0.5, 1); glVertex2f(1, 0); glTexCoord3f(0.5, 0.5, 1); glVertex2f(1, 1); glTexCoord3f(-0.5, 0.5, 1); glVertex2f(0, 1); glEnd(); }
void MapElementPolygon::Draw() const { glColor4ub(vertex[0].color.red, vertex[0].color.green, vertex[0].color.blue, vertex[0].color.alpha); glTexCoord3f(vertex[0].tu, -vertex[0].tv, 1.0f / vertex[0].rhw); glVertex3f(vertex[0].x, vertex[0].y, vertex[0].z); glColor4ub(vertex[1].color.red, vertex[1].color.green, vertex[1].color.blue, vertex[1].color.alpha); glTexCoord3f(vertex[1].tu, -vertex[1].tv, 1.0f / vertex[1].rhw); glVertex3f(vertex[1].x, vertex[1].y, vertex[1].z); glColor4ub(vertex[2].color.red, vertex[2].color.green, vertex[2].color.blue, vertex[2].color.alpha); glTexCoord3f(vertex[2].tu, -vertex[2].tv, 1.0f / vertex[2].rhw); glVertex3f(vertex[2].x, vertex[2].y, vertex[2].z); }
void geDrawLineScreenFadeDepth(int x0, int y0, int z0, int x1, int y1, int z1, u32 color0, u32 color1){ if(abs(z0) > 2048 || abs(z1) > 2048){ return; } x0 += libge_context->draw_off_x; x1 += libge_context->draw_off_x; y0 += libge_context->draw_off_y; y1 += libge_context->draw_off_y; glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); if(!ge_current_shader){ geShaderUse(_ge_GetVideoContext()->shader2d); } if(ge_current_shader == _ge_GetVideoContext()->shader2d){ geShaderUniform1f(_ge_GetVideoContext()->loc_textured, 0.0); } glBegin(GL_LINES); glColor4ub(R(color0), G(color0), B(color0), A(color0)); glTexCoord3f(-1.0, -1.0, -1.0); glVertex3f(x0, y0, z0+libge_context->img_stack[z0+2048]); glColor4ub(R(color1), G(color1), B(color1), A(color1)); glVertex3f(x1, y1, z1+libge_context->img_stack[z1+2048]); glEnd(); libge_context->img_stack[z0+2048] += 0.001; libge_context->img_stack[z1+2048] += 0.001; glEnable(GL_TEXTURE_2D); }
static void WINE_GLAPI wine_glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r) { if(target != GL_TEXTURE0) { ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n"); return; } glTexCoord3f(s, t, r); }
void geFillRectScreenDepth(int x, int y, int z, int width, int height, u32 color){ if(abs(z) > 2048){ return; } x += libge_context->draw_off_x; y += libge_context->draw_off_y; glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); if(!ge_current_shader){ geShaderUse(_ge_GetVideoContext()->shader2d); } if(ge_current_shader == _ge_GetVideoContext()->shader2d){ geShaderUniform1f(_ge_GetVideoContext()->loc_textured, 0.0); } glBegin(GL_QUADS); glColor4ub(R(color), G(color), B(color), A(color)); glTexCoord3f(-1.0, -1.0, -1.0); glVertex3f(x, y, z+libge_context->img_stack[z+2048]); glVertex3f(x+width, y, z+libge_context->img_stack[z+2048]); glVertex3f(x+width, y+height, z+libge_context->img_stack[z+2048]); glVertex3f(x, y+height, z+libge_context->img_stack[z+2048]); glEnd(); libge_context->img_stack[z+2048] += 0.001; glEnable(GL_TEXTURE_2D); }
VoodooResult VOODOO_METHODTYPE FrostAdapter::DrawGeometry(_In_ const uint32_t offset, _In_ const uint32_t count, _In_ void * const pData, _In_ const VertexFlags flags) { UNREFERENCED_PARAMETER(flags); if (pData) { VertexDesc * pVerts = reinterpret_cast<VertexDesc*>(pData); glBegin(GL_QUADS); for (uint32_t v = offset; v < offset + count; ++v) { glTexCoord3f(pVerts[v].TexCoord[0].X, pVerts[v].TexCoord[0].Y, pVerts[v].TexCoord[0].Z); glVertex3f(pVerts[v].Position.X, pVerts[v].Position.Y, pVerts[v].Position.Z); } glEnd(); } else { glBegin(GL_QUADS); glTexCoord2f(0.0f, 1.0f); glVertex2d(0.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex2d(0.0f, 250.0f); glTexCoord2f(1.0f, 0.0f); glVertex2d(250.0f, 250.0f); glTexCoord2f(1.0f, 1.0f); glVertex2d(250.0f, 0.0f); glEnd(); } return VSF_OK; }
void debug_draw_func() { glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_QUADS); glTexCoord3f(0,0, textureDepth); glVertex2i(0, 0); glTexCoord3f(textureWidth,0, textureDepth); glVertex2i(screenWidth, 0); glTexCoord3f(textureWidth,textureHeight, textureDepth); glVertex2i(screenWidth, screenHeight); glTexCoord3f(0,textureHeight, textureDepth); glVertex2i(0, screenHeight); glEnd(); glFlush(); }
static void draw_quad(int x, int y, float s, float t, float r) { glBegin(GL_QUADS); glTexCoord3f(s, t, r); glVertex2i(x, y); glVertex2i(x, y+20); glVertex2i(x+20, y+20); glVertex2i(x+20, y); glEnd(); }
GLvoid glTexCoord2f(GLfloat s, GLfloat t) { if (vt_coordsize[0] > 2){ glTexCoord3f(s, t, 0); } else { vt_coordsize[0] = 2; vt_current->coord[0].s = s; vt_current->coord[0].t = t; } }
void gTexture::drawTextureToScreen() { GLboolean lighton, textureon; glGetBooleanv(GL_LIGHTING, &lighton); glGetBooleanv(GL_TEXTURE_2D, &textureon); glDisable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glColor4f(1.0, 1.0, 1.0, 1.0); glBegin(GL_QUADS); { glTexCoord3f(0.0, 0.0, -1.0); glVertex2f(-1.0, -1.0); glTexCoord3f(1.0, 0.0, -1.0); glVertex2f(1.0, -1.0); glTexCoord3f(1.0, 1.0, -1.0); glVertex2f(1.0, 1.0); glTexCoord3f(0.0, 1.0, -1.0); glVertex2f(-1.0, 1.0); } glEnd(); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); if (lighton) glEnable(GL_LIGHTING); if (!textureon) glDisable(GL_TEXTURE_2D); }
void BezierPatch::display(GLuint texture) { glPushMatrix(); glTranslatef(getOrigin().x,getOrigin().y,getOrigin().z); glBindTexture(GL_TEXTURE_2D,texture); //glColor4f(1,1,1,1); for(int i=0;i<levelOfDetail*levelOfDetail;i++) { glBegin(GL_POLYGON); glTexCoord3f(polyStripNormals[i][0][0],polyStripNormals[i][0][1],polyStripNormals[i][0][2]); glVertex3f(polyStripPoints[i][0][0],polyStripPoints[i][0][1],polyStripPoints[i][0][2]); glTexCoord3f(polyStripNormals[i][1][0],polyStripNormals[i][1][1],polyStripNormals[i][1][2]); glVertex3f(polyStripPoints[i][1][0],polyStripPoints[i][1][1],polyStripPoints[i][1][2]); glTexCoord3f(polyStripNormals[i][3][0],polyStripNormals[i][3][1],polyStripNormals[i][3][2]); glVertex3f(polyStripPoints[i][3][0],polyStripPoints[i][3][1],polyStripPoints[i][3][2]); glTexCoord3f(polyStripNormals[i][2][0],polyStripNormals[i][2][1],polyStripNormals[i][2][2]); glVertex3f(polyStripPoints[i][2][0],polyStripPoints[i][2][1],polyStripPoints[i][2][2]); glEnd(); } glPopMatrix(); }