void LineEditWidget::draw() const { RANGERS_D(const LineEditWidget); if (!prepareDraw()) return; if (d->background) d->background->draw(); d->label->draw(); if (isFocused() && d->cursorVisible && d->cursorBuffer) { glBindTexture(GL_TEXTURE_2D, 0); glColor3ub((d->style.color >> 24) & 0xff, (d->style.color >> 16) & 0xff, (d->style.color >> 8) & 0xff); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_ARRAY_BUFFER); glBindBuffer(GL_ARRAY_BUFFER, d->cursorBuffer); glVertexPointer(2, GL_FLOAT, sizeof(Vertex), 0); glLineWidth(1); glDrawArrays(GL_LINES, 0, 2); glDisableClientState(GL_ARRAY_BUFFER); glDisableClientState(GL_VERTEX_ARRAY); }
void SpriteGL::draw( int inFrame, Vector3D *inPosition, double inScale, char inLinearMagFilter, char inMipMapFilter, double inRotation, char inFlipH ) { prepareDraw( inFrame, inPosition, inScale, inLinearMagFilter, inMipMapFilter inRotation, inFlipH ); glVertexPointer( 2, GL_FLOAT, 0, squareVertices ); glEnableClientState( GL_VERTEX_ARRAY ); //glColorPointer( 4, GL_FLOAT, 0, squareColors ); //glEnableClientState( GL_COLOR_ARRAY ); glTexCoordPointer( 2, GL_FLOAT, 0, squareTextureCoords ); glEnableClientState( GL_TEXTURE_COORD_ARRAY ); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDisableClientState( GL_VERTEX_ARRAY ); glDisableClientState( GL_TEXTURE_COORD_ARRAY ); }
void Model3DS::Draw(GLuint tex) { prepareDraw(); assert(m_VertexVBO != NULL); bindTexture(tex); glBindBuffer(GL_ARRAY_BUFFER, m_VertexVBO); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Lib3dsVector), 0); glEnableVertexAttribArray (0); glBindBuffer(GL_ARRAY_BUFFER, m_NormalVBO); glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Lib3dsVector), 0); glEnableVertexAttribArray (1); glBindBuffer(GL_ARRAY_BUFFER, m_TexCoordVBO); glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Lib3dsTexel), 0); glEnableVertexAttribArray (2); glDrawArrays(GL_TRIANGLES, 0, m_TotalFaces * 3); glDisableVertexAttribArray (0); glDisableVertexAttribArray (1); glDisableVertexAttribArray (2); }
void Piece::draw(glm::mat4 viewMatrix, glm::mat4 projectionMatrix, glm::vec3 cameraEye) { prepareDraw(viewMatrix, projectionMatrix); sendModelMatrix(viewMatrix, createModelMatrix()); bindDraw(); postDraw(); }
/** * Draw spring event. * * @param ticks Time * @param change Time since last iteration */ void SpringJJ2Event::draw (unsigned int ticks, int change) { Anim* an; int drawX, drawY; if (prepareDraw(ticks, change)) return; drawX = getDrawX(change); drawY = getDrawY(change); switch (type) { case 60: // Frozen green spring an = jj2Level->getAnim(animSet, 5, flipped); break; case 62: // Spring crate an = jj2Level->getAnim(animSet, 0, flipped); break; case 85: // Red spring an = jj2Level->getAnim(animSet, 7, flipped); break; case 86: // Green spring an = jj2Level->getAnim(animSet, 5, flipped); break; case 87: // Blue spring an = jj2Level->getAnim(animSet, 0, flipped); break; default: return; } an->setFrame(0, true); an->draw(drawX + F16, drawY + F16); return; }
void SpriteGL::draw( int inFrame, Vector3D *inPosition, double inScale, char inLinearMagFilter, char inMipMapFilter, double inRotation, char inFlipH ) { // numPixelsDrawn += // ( mColoredRadiusRightX + mColoredRadiusLeftX ) * mWidth * // ( mColoredRadiusTopY + mColoredRadiusBottomY ) * mHeight; prepareDraw( inFrame, inPosition, inScale, inLinearMagFilter, inMipMapFilter, inRotation, inFlipH ); glVertexPointer( 2, GL_FLOAT, 0, squareVertices ); glTexCoordPointer( 2, GL_FLOAT, 0, squareTextureCoords ); if( !sStateSet ) { glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_TEXTURE_COORD_ARRAY ); sStateSet = true; } glDrawArrays( GL_TRIANGLE_STRIP, 0, 4 ); /* // for debugging // show red square around each sprite SingleTextureGL::disableTexturing(); FloatColor oldColor = getDrawColor(); setDrawColor( 1, 0, 0, 0.75 ); GLfloat temp = squareVertices[4]; squareVertices[4] = squareVertices[6]; squareVertices[6] = temp; temp = squareVertices[5]; squareVertices[5] = squareVertices[7]; squareVertices[7] = temp; //glVertexPointer( 2, GL_FLOAT, 0, squareVertices ); glDrawArrays( GL_LINE_LOOP, 0, 4 ); setDrawColor( oldColor ); */ }
void Node::draw() const { RANGERS_D(const Node); if (!prepareDraw()) return; std::list<Object*> children = d->children; for (std::list<Object*>::const_iterator i = children.begin(); i != children.end(); i++) (*i)->draw(); endDraw(); }
void ScriptWidget::draw() const { RANGERS_D(const ScriptWidget); if (!prepareDraw()) return; std::list<boost::shared_ptr<Object> > children = d->children; for (std::list<boost::shared_ptr<Object> >::const_iterator i = children.begin(); i != children.end(); ++i) (*i)->draw(); endDraw(); }
void SpriteGL::draw( int inFrame, Vector3D *inPosition, FloatColor inCornerColors[4], double inScale, char inLinearMagFilter, char inMipMapFilter, double inRotation, char inFlipH ) { prepareDraw( inFrame, inPosition, inScale, inLinearMagFilter, inMipMapFilter, inRotation, inFlipH ); glVertexPointer( 2, GL_FLOAT, 0, squareVertices ); glTexCoordPointer( 2, GL_FLOAT, 0, squareTextureCoords ); if( !sStateSet ) { glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_TEXTURE_COORD_ARRAY ); sStateSet = true; } for( int c=0; c<4; c++ ) { int cDest = c; if( c == 2 ) { cDest = 3; } else if( c == 3 ) { cDest = 2; } int start = cDest * 4; squareColors[ start ] = inCornerColors[c].r; squareColors[ start + 1 ] = inCornerColors[c].g; squareColors[ start + 2 ] = inCornerColors[c].b; squareColors[ start + 3 ] = inCornerColors[c].a; } glColorPointer( 4, GL_FLOAT, 0, squareColors ); glEnableClientState( GL_COLOR_ARRAY ); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDisableClientState( GL_COLOR_ARRAY ); }
void AnimatedSprite::draw() const { RANGERS_D(const AnimatedSprite); if (!d->region.texture) return; boost::shared_ptr<AnimatedTexture> texture = boost::static_pointer_cast<AnimatedTexture>(d->region.texture); if (!texture) return; if (!prepareDraw()) return; glBindTexture(GL_TEXTURE_2D, texture->openGLTexture(d->currentFrame)); if (d->scaling == TEXTURE_TILE_X) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); else glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); if (d->scaling == TEXTURE_TILE_Y) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); else glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); if (d->scaling == TEXTURE_TILE) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_ARRAY_BUFFER); glBindBuffer(GL_ARRAY_BUFFER, d->buffer); glVertexPointer(2, GL_FLOAT, sizeof(Vertex), 0); glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), OPENGL_BUFFER_OFFSET(sizeof(float) * 2)); glDrawArrays(GL_QUADS, 0, d->vertexCount); glDisableClientState(GL_ARRAY_BUFFER); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); endDraw(); }
/** * Draw ammo pickup event. * * @param ticks Time * @param change Time since last iteration */ void AmmoJJ2Event::draw (unsigned int ticks, int change) { Anim* an; int drawX, drawY; if (prepareDraw(ticks, change)) return; drawX = getDrawX(change); drawY = getDrawY(change); /// @todo Check if ammo is powered up if (!endTime) an = jj2Level->getAnim(0, ammoAnims[type - 33], flipped); else an = jj2Level->getAnim(animSet, 86, flipped); an->setFrame((int)ticks / 60, true); an->draw(drawX + F16, drawY + F16 + F32); return; }
/** * Draw food pickup event. * * @param ticks Time * @param change Time since last iteration */ void FoodJJ2Event::draw (unsigned int ticks, int change) { Anim* an; int drawX, drawY; if (prepareDraw(ticks, change)) return; drawX = getDrawX(change); drawY = getDrawY(change); // Use look-up table if (!endTime) an = jj2Level->getAnim(animSet, pickupAnims[type], flipped); else an = jj2Level->getAnim(animSet, 86, flipped); an->setFrame((int)ticks / 60, true); an->draw(drawX + F16, drawY + F16 + F32); return; }
/** * Draw placeholder event. * * @param ticks Time * @param change Time since last iteration */ void OtherJJ2Event::draw (unsigned int ticks, int change) { Anim* an; int drawX, drawY; if (prepareDraw(ticks, change)) return; drawX = getDrawX(change); drawY = getDrawY(change); switch (type) { default: if ((type <= 221) && pickupAnims[type]) { an = jj2Level->getAnim(animSet, pickupAnims[type], flipped); an->setFrame((int)ticks / 60, true); an->draw(drawX + F16, drawY + F16 + F32); } else if (!endTime) { drawRect(FTOI(drawX) + 8, FTOI(drawY) + 8, 16, 16, type); } panelBigFont->showNumber(type, FTOI(drawX) + 24, FTOI(drawY) + 12); return; } an->draw(drawX + F16, drawY + F16); return; }
/** * drawNumber * Zeichnen der übergebenen Zahl. Aufgeteilt in 1er, 10er, 100er Anteil. * @param num Zahl */ void World::drawNumber(int num) { CMatrix * modelviewmatrix = getModelView(); int hundred = num/100; int ten = (num-(hundred*100))/10; int one = num-(ten*10)-(hundred*100); if(hundred > 9) { hundred = 9; ten = 9; one = 9; } prepareDraw(); modelviewmatrix->Push(); modelviewmatrix->Rotate(DEG2RAD*-90,1,0,0); modelviewmatrix->Translate(0.3,0.0,0.0); drawNumberModel(one); modelviewmatrix->Translate(-0.15,0.0,0.0); drawNumberModel(ten); modelviewmatrix->Translate(-0.15,0.0,0.0); drawNumberModel(hundred); modelviewmatrix->Pop(); }
void WorldObjectEffect::draw(DrawInfo &di) { if (singleCbvBufferMode) assert(di.objectNum < maxObjects); int frameIndex = xapp().getCurrentBackBufferIndex(); Camera *cam = nullptr; CBV *cbv = nullptr; if (inThreadOperation) { // copy global camera to thread camera: TODO: should only be needed once threadLocal.camera = xapp().camera; cam = &threadLocal.camera; threadLocal.cbv = this->cbv; cbv = &threadLocal.cbv; } else { cam = &xapp().camera; cbv = &this->cbv; // update lights, for thread operations: must have been done earlier in divideBulk (same material for all objects) xapp().lights.lights.material = *di.material; xapp().lights.update(); } prepareDraw(&xapp().vr); if (!xapp().ovrRendering) { threadLocal.vr_eyesm[0] = vr_eyes; XMMATRIX vp = cam->worldViewProjection(); XMMATRIX toWorld = XMLoadFloat4x4(&di.world); XMMATRIX wvp = calcWVP(toWorld, vp); XMStoreFloat4x4(&cbv->wvp, wvp); cbv->world = di.world; cbv->cameraPos.x = cam->pos.x; cbv->cameraPos.y = cam->pos.y; cbv->cameraPos.z = cam->pos.z; cbv->alpha = di.alpha; if (inBulkOperation) { memcpy(getCBVUploadAddress(frameIndex, di.threadNum, di.objectNum, 0), cbv, sizeof(*cbv)); } else { memcpy(cbvGPUDest, cbv, sizeof(*cbv)); } //memcpy(getCBVUploadAddress(frameIndex, di.threadNum, di.objectNum), &cbv, sizeof(cbv)); //memcpy(cbvGPUDest + cbvAlignedSize, &cbv, sizeof(cbv)); //memcpy(getCBVUploadAddress(frameIndex, 0), &cbv, sizeof(cbv)); drawInternal(di); return; } // draw VR, iterate over both eyes //xapp().vr.prepareDraw(); for (int eyeNum = 0; eyeNum < 2; eyeNum++) { // adjust PVW matrix threadLocal.cameram[eyeNum] = xapp().camera; threadLocal.vr_eyesm[eyeNum] = vr_eyes; cam = &threadLocal.cameram[eyeNum]; cbv = &threadLocal.cbvm[eyeNum]; *cbv = this->cbv; di.eyeNum = eyeNum; XMMATRIX adjustedEyeMatrix; cam->eyeNumUse = true; cam->eyeNum = eyeNum; threadLocal.vr_eyesm[eyeNum].adjustEyeMatrix(adjustedEyeMatrix, cam, eyeNum, &xapp().vr); //xapp().vr.adjustEyeMatrix(adjustedEyeMatrix, cam); XMMATRIX toWorld = XMLoadFloat4x4(&di.world); XMMATRIX wvp = calcWVP(toWorld, adjustedEyeMatrix); XMStoreFloat4x4(&cbv->wvp, wvp); cbv->world = di.world; cbv->cameraPos.x = cam->pos.x; cbv->cameraPos.y = cam->pos.y; cbv->cameraPos.z = cam->pos.z; cbv->alpha = di.alpha; //if (eyeNum == 1) di.objectNum += 12;//10010; if (inBulkOperation) { UINT8 *mem = getCBVUploadAddress(frameIndex, di.threadNum, di.objectNum, eyeNum); //if (di.objectNum == 100) { // Log(" di100 " << mem << " " << frameIndex << " " << di.threadNum << endl); //} memcpy(mem, cbv, sizeof(*cbv)); } else { memcpy(cbvGPUDest, cbv, sizeof(*cbv)); } drawInternal(di); //if (di.objectNum == 100 /*&& eyeNum == 1 && frameIndex < 3*/) drawInternal(di); //if (eyeNum == 1) drawInternal(di); //if (eyeNum == 1) di.objectNum -= 12;//10010; if (!inThreadOperation) { //xapp().vr.nextEye(); } } di.eyeNum = 0; //xapp().vr.endDraw(); }
void SpriteGL::draw( int inFrame, doublePair inCornerPos[4], FloatColor inCornerColors[4], char inLinearMagFilter, char inMipMapFilter ) { prepareDraw( inFrame, &dummyPosition, 1, inLinearMagFilter, inMipMapFilter, 0, false, // don't compute corners in prepare false ); squareVertices[0] = inCornerPos[0].x; squareVertices[1] = inCornerPos[0].y; // swap order squareVertices[2] = inCornerPos[1].x; squareVertices[3] = inCornerPos[1].y; squareVertices[4] = inCornerPos[3].x; squareVertices[5] = inCornerPos[3].y; squareVertices[6] = inCornerPos[2].x; squareVertices[7] = inCornerPos[2].y; glVertexPointer( 2, GL_FLOAT, 0, squareVertices ); glTexCoordPointer( 2, GL_FLOAT, 0, squareTextureCoords ); if( !sStateSet ) { glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_TEXTURE_COORD_ARRAY ); sStateSet = true; } for( int c=0; c<4; c++ ) { int cDest = c; if( c == 2 ) { cDest = 3; } else if( c == 3 ) { cDest = 2; } int start = cDest * 4; squareColors[ start ] = inCornerColors[c].r; squareColors[ start + 1 ] = inCornerColors[c].g; squareColors[ start + 2 ] = inCornerColors[c].b; squareColors[ start + 3 ] = inCornerColors[c].a; } glColorPointer( 4, GL_FLOAT, 0, squareColors ); glEnableClientState( GL_COLOR_ARRAY ); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDisableClientState( GL_COLOR_ARRAY ); }
/** * Draw coin/gem pickup event. * * @param ticks Time * @param change Time since last iteration */ void CoinGemJJ2Event::draw (unsigned int ticks, int change) { Anim* an; int drawX, drawY; if (prepareDraw(ticks, change)) return; drawX = getDrawX(change); drawY = getDrawY(change); if (endTime) { an = jj2Level->getAnim(animSet, 86, flipped); an->setFrame((int)ticks / 60, true); an->draw(drawX + F16, drawY + F16 + F32); } if (type == 44) an = jj2Level->getAnim(animSet, 84, flipped); // Silver coin else if (type == 45) an = jj2Level->getAnim(animSet, 37, flipped); // Gold coin else an = jj2Level->getAnim(animSet, 35, flipped); // Gem an->setFrame((int)ticks / 60, true); switch (type) { case 63: // Red gem mapPalette(an, 48); break; case 64: // Green gem mapPalette(an, 80); break; case 65: // Blue gem mapPalette(an, 32); break; case 66: // Purple gem mapPalette(an, 88); break; } if (endTime) { drawX += (ticks + 500 - endTime) << 8; drawY += (ticks + 500 - endTime) << 10; } an->draw(drawX + F16, drawY + F16 + F32); return; }