TEST_F(SRGBTest, GLRenderFromSRGBTexture) { ASSERT_NO_FATAL_FAILURE(initShaders()); // The RGB texture is displayed in the top half ASSERT_NO_FATAL_FAILURE(drawTexture(false, 0, DISPLAY_HEIGHT / 2, DISPLAY_WIDTH, DISPLAY_HEIGHT / 2)); // The SRGB texture is displayed in the bottom half ASSERT_NO_FATAL_FAILURE(drawTexture(true, 0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT / 2)); eglSwapBuffers(mEglDisplay, mEglSurface); ASSERT_EQ(EGL_SUCCESS, eglGetError()); // Lock ASSERT_EQ(NO_ERROR, mCpuConsumer->lockNextBuffer(&mLockedBuffer)); ASSERT_NO_FATAL_FAILURE( checkLockedBuffer(PIXEL_FORMAT_RGBA_8888, HAL_DATASPACE_UNKNOWN)); // Compare a pixel in the middle of each texture int midSRGBOffset = (DISPLAY_HEIGHT / 4) * mLockedBuffer.stride * PIXEL_SIZE; int midRGBOffset = midSRGBOffset * 3; midRGBOffset += (DISPLAY_WIDTH / 2) * PIXEL_SIZE; midSRGBOffset += (DISPLAY_WIDTH / 2) * PIXEL_SIZE; for (int c = 0; c < PIXEL_SIZE; ++c) { int expectedValue = mLockedBuffer.data[midRGBOffset + c]; int actualValue = mLockedBuffer.data[midSRGBOffset + c]; ASSERT_PRED2(withinTolerance, expectedValue, actualValue); } // mLockedBuffer is unlocked in TearDown so we can copy data from it to // the debug surface if necessary }
void DepthOfField::debugDraw() { glBindFramebuffer(GL_FRAMEBUFFER, 0); glDrawBuffer(GL_BACK_LEFT); drawTexture(image_prog, scene_tex, 0,384,512,384); drawTexture(depth_prog, depth_tex, 0,0,512,384); drawTexture(image_prog, linear_depth_tex, 512, 0, 512, 384); drawTexture(image_prog, blur0_tex, 512, 384, 512, 384); }
void MTexturePixmapPrivate::renderTexture(const QTransform& transform) { if (item->propertyCache()->hasAlphaAndIsNotOpaque() || item->opacity() < 1.0f) { glEnable(GL_BLEND); glBlendFunc(GL_ONE, // Correct for premultiplied-alpha textures GL_ONE_MINUS_SRC_ALPHA); } glBindTexture(GL_TEXTURE_2D, TFP.textureId); const QRegion &shape = item->propertyCache()->shapeRegion(); // FIXME: not optimal. probably would be better to replace with // eglSwapBuffersRegionNOK() bool shape_on = !QRegion(item->boundingRect().toRect()).subtracted(shape).isEmpty(); bool scissor_on = damageRegion.numRects() > 1 || shape_on; if (scissor_on) glEnable(GL_SCISSOR_TEST); // Damage regions taking precedence over shape rects if (damageRegion.numRects() > 1) { for (int i = 0; i < damageRegion.numRects(); ++i) { glScissor(damageRegion.rects().at(i).x(), brect.height() - (damageRegion.rects().at(i).y() + damageRegion.rects().at(i).height()), damageRegion.rects().at(i).width(), damageRegion.rects().at(i).height()); drawTexture(transform, item->boundingRect(), item->opacity()); } } else if (shape_on) { // draw a shaped window using glScissor for (int i = 0; i < shape.numRects(); ++i) { glScissor(shape.rects().at(i).x(), brect.height() - (shape.rects().at(i).y() + shape.rects().at(i).height()), shape.rects().at(i).width(), shape.rects().at(i).height()); drawTexture(transform, item->boundingRect(), item->opacity()); } } else drawTexture(transform, item->boundingRect(), item->opacity()); if (scissor_on) glDisable(GL_SCISSOR_TEST); // qDebug() << __func__ << item->window() << item->pos(); // Explicitly disable blending. for some reason, the latest drivers // still has blending left-over even if we call glDisable(GL_BLEND) glBlendFunc(GL_ONE, GL_ZERO); glDisable(GL_BLEND); #ifdef WINDOW_DEBUG ++item_painted; #endif }
void SSAO::debugDraw() { glDepthMask(GL_TRUE); glBindFramebuffer(GL_FRAMEBUFFER, 0); glDrawBuffer(GL_BACK_LEFT); drawTexture(image_prog, position_tex, 0,384,512,384); drawTexture(depth_prog, depth_tex, 0,0,512,384); drawTexture(image_prog, linear_depth_tex, 512, 0, 512, 384); drawTexture(image_prog, scene_tex, 512, 384, 512, 384); glViewport(0,0,fbo_w, fbo_h); }
void MenuTask::render() { drawBackground(); copyTexture(menu, *menu_with_selection); const int selection_y[MENU_ITEM_MAX] = { 14, 36, 63, 88, 112, 136 }; drawTexture(selection, *menu_with_selection, 0, 0, selection.width, selection.height, 23, selection_y[menu_selected_item], selection.width, selection.height); drawTexture(*menu_with_selection, *screen, 0, 0, menu_width_visible, menu_with_selection->height, SCREEN_WIDTH - menu_width_visible, 0, menu_width_visible, menu_with_selection->height); }
void SurfaceSdlGraphicsManager::drawSideTexturesOpenGL() { if (_fullscreen && _lockAspectRatio) { const Math::Vector2d nudge(1.0 / float(_screen->w), 0); if (_sideTextures[0] != nullptr) { float left = _gameRect.getBottomLeft().getX() - (float(_screen->h) / float(_sideTextures[0]->getHeight())) * _sideTextures[0]->getWidth() / float(_screen->w); drawTexture(*_sideTextures[0], Math::Vector2d(left, 0.0), _gameRect.getBottomLeft() + nudge, true); } if (_sideTextures[1] != nullptr) { float right = _gameRect.getTopRight().getX() + (float(_screen->h) / float(_sideTextures[1]->getHeight())) * _sideTextures[1]->getWidth() / float(_screen->w); drawTexture(*_sideTextures[1], _gameRect.getTopRight() - nudge, Math::Vector2d(right, 1.0), true); } } }
/* SectorInfoOverlay::draw * Draws the overlay at [bottom] from 0 to [right] *******************************************************************/ void SectorInfoOverlay::draw(int bottom, int right, float alpha) { // Don't bother if invisible if (alpha <= 0.0f) return; // Init GL stuff glLineWidth(1.0f); glDisable(GL_LINE_SMOOTH); // Determine overlay height double scale = (gl_font_size / 12.0); text_box->setLineHeight(16 * scale); if (last_size != right) { last_size = right; text_box->setSize(right - 88 - 92); } int height = text_box->getHeight() + 4; // Slide in/out animation float alpha_inv = 1.0f - alpha; bottom += height*alpha_inv*alpha_inv; // Get colours rgba_t col_bg = ColourConfiguration::getColour("map_overlay_background"); rgba_t col_fg = ColourConfiguration::getColour("map_overlay_foreground"); col_fg.a = col_fg.a*alpha; col_bg.a = col_bg.a*alpha; rgba_t col_border(0, 0, 0, 140); // Draw overlay background int tex_box_size = 80 * scale; glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); Drawing::drawBorderedRect(0, bottom - height - 4, right - (tex_box_size * 2) - 30, bottom+2, col_bg, col_border); Drawing::drawBorderedRect(right - (tex_box_size * 2) - 28, bottom - height - 4, right, bottom+2, col_bg, col_border); // Draw info text lines text_box->draw(2, bottom - height, col_fg); // Ceiling texture drawTexture(alpha, right - tex_box_size - 8, bottom - 4, ctex, "C"); // Floor texture drawTexture(alpha, right - (tex_box_size * 2) - 20, bottom - 4, ftex, "F"); // Done glEnable(GL_LINE_SMOOTH); }
static void blitTexture(QGLContext *ctx, GLuint texture, const QSize &viewport, const QSize &texSize, const QRect &targetRect, const QRect &sourceRect) { glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); glDisable(GL_BLEND); glViewport(0, 0, viewport.width(), viewport.height()); QGLShaderProgram *blitProgram = QGLEngineSharedShaders::shadersForContext(ctx)->blitProgram(); blitProgram->bind(); blitProgram->setUniformValue("imageTexture", 0 /*QT_IMAGE_TEXTURE_UNIT*/); // The shader manager's blit program does not multiply the // vertices by the pmv matrix, so we need to do the effect // of the orthographic projection here ourselves. QRectF r; qreal w = viewport.width(); qreal h = viewport.height(); r.setLeft((targetRect.left() / w) * 2.0f - 1.0f); if (targetRect.right() == (viewport.width() - 1)) r.setRight(1.0f); else r.setRight((targetRect.right() / w) * 2.0f - 1.0f); r.setBottom((targetRect.top() / h) * 2.0f - 1.0f); if (targetRect.bottom() == (viewport.height() - 1)) r.setTop(1.0f); else r.setTop((targetRect.bottom() / w) * 2.0f - 1.0f); drawTexture(r, texture, texSize, sourceRect); }
void drawEntity(Game* game, Entity* entity) { if(entity->texture) { Pointf location = createPointf( entity->position.x - entity->origin.x, entity->position.y - entity->origin.y); drawTexture(game, entity->texture, location, entity->depth); } if(entity->drawRectangle) { Rectanglei rectangle = createRectanglei( (int)entity->position.x - entity->origin.x + entity->offset.x, (int)entity->position.y - entity->origin.y + entity->offset.y, entity->size.x, entity->size.y ); drawRectangle(game, rectangle, entity->color); } if(entity->sprite.alive) { drawSprite(game, &entity->sprite); } }
void ClockCircle :: draw () { if( false ) { ofxBox2dCircle :: draw(); return; } if ( tex != NULL ) { drawTexture(); if( texAnim != NULL ) { drawTextureAnim(); } } else { drawCircles(); } // drawTriangles(); }
void OpenGLRenderer::drawTexture(OpenGLTexture* aTexture, float aX, float aY, float aAngle) { if(aTexture != NULL) { drawTexture(aTexture, aX, aY, aTexture->getSourceWidth(), aTexture->getSourceHeight(), aAngle); } }
void Asteroid::draw() { // drawLines(GL_LINE_LOOP,vboIds[0],nvertices,color(), 5.0); drawTexture(); if (_bonus) _bonus->draw(); }
/* CTextureCanvas::draw * Draws the canvas contents *******************************************************************/ void CTextureCanvas::draw() { // Setup the viewport glViewport(0, 0, GetSize().x, GetSize().y); // Setup the screen projection glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, GetSize().x, GetSize().y, 0, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Clear glClearColor(1.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); // Translate to inside of pixel (otherwise inaccuracies can occur on certain gl implementations) if (OpenGL::accuracyTweak()) glTranslatef(0.375f, 0.375f, 0); // Draw background drawCheckeredBackground(); // Pan by view offset glTranslated(offset.x, offset.y, 0); // Draw texture if (texture) drawTexture(); // Swap buffers (ie show what was drawn) SwapBuffers(); }
void UIModel::render() const { if (!model) return; drawFBO(); drawTexture(); }
void Playground::renderBubble(int x, int y, GLuint color) { QRectF rect; rect.setX(x); rect.setY(y); rect.setHeight(bubbleSize); rect.setWidth(bubbleSize); drawTexture(rect, color); /*glBindTexture( GL_TEXTURE_2D, color); glBegin( GL_QUADS ); glTexCoord2i( 0, 0 ); glVertex3f( x, y, 0); glTexCoord2i( 1, 0 ); glVertex3f( x + bubbleSize, y, 0); glTexCoord2i( 1, 1 ); glVertex3f( x + bubbleSize, y + bubbleSize, 0); glTexCoord2i( 0, 1 ); glVertex3f( x, y + bubbleSize, 0); glEnd();*/ }
//-------------------------------------------------------------- void DrawerBase::drawSpeed(float x, float y, float renderWidth, float renderHeight, bool withAlpha) const { if(enabled == false) return; ofPushStyle(); if(useAdditiveBlending) ofEnableBlendMode(OF_BLENDMODE_ADD); else ofDisableAlphaBlending(); int fw = _fluidSolver->getWidth(); int fh = _fluidSolver->getHeight(); Vec2f vel; int index = 0; for(int j=1; j < fh-1; j++) { for(int i=1; i < fw-1; i++) { _fluidSolver->getInfoAtCell(i, j, &vel, NULL); float speed2 = fabs(vel.x) * fw + fabs(vel.y) * fh; int speed = (int)min(speed2 * 255 * brightness, 255.0f); _pixels[index++] = (unsigned char)speed; _pixels[index++] = (unsigned char)speed; _pixels[index++] = (unsigned char)speed; if(_alphaEnabled) _pixels[index++] = withAlpha ? speed : 255; } } updateTexture(); drawTexture(x, y, renderWidth, renderHeight); ofPopStyle(); }
void FluidDrawerBase::drawSpeed(float x, float y, float renderWidth, float renderHeight, bool withAlpha) { if(enabled == false) return; if(useAdditiveBlending) { glBlendFunc(GL_ONE, GL_ONE); glEnable(GL_BLEND); } else { glDisable(GL_BLEND); } int fw = _fluidSolver->getWidth(); int fh = _fluidSolver->getHeight(); ofVec2f vel; int index = 0; for(int j=1; j < fh-1; j++) { for(int i=1; i < fw-1; i++) { _fluidSolver->getInfoAtCell(i, j, &vel, NULL); float speed2 = fabs(vel.x) * fw + fabs(vel.y) * fh; int speed = (int)min(speed2 * 255 * brightness, 255.0f); _pixels[index++] = (unsigned char)speed; _pixels[index++] = (unsigned char)speed; _pixels[index++] = (unsigned char)speed; if(_alphaEnabled) _pixels[index++] = withAlpha ? speed : 255; } } updateTexture(); drawTexture(x, y, renderWidth, renderHeight); }
/* QuickTextureOverlay3d::draw * Draws the overlay to [width],[height] *******************************************************************/ void QuickTextureOverlay3d::draw(int width, int height, float fade) { // Don't draw if invisible if (fade < 0.001f) return; // Draw background glColor4f(0.0f, 0.0f, 0.0f, fade * 0.6f); glDisable(GL_TEXTURE_2D); Drawing::drawFilledRect(0, height - 120, width, height); // Draw current tex name glEnable(GL_TEXTURE_2D); // Draw textures double x = ((double)width * 0.5) - (anim_offset * 136.0); glColor4f(1.0f, 1.0f, 1.0f, fade); for (unsigned a = 0; a < textures.size(); a++) { // Skip until first texture to show on left if (x < -96) { x += 136; continue; } // Draw texture drawTexture(a, x, height - 18, determineSize(x, width), fade); x += 136; // Stop when we get to the right edge of the screen if (x > width + 96) break; } }
int main(int argc, char **argv) { ChickpeaWindow window; systemInit(&window, "Hello Chickpea", X_RES, Y_RES, 0, 0, 0); TexturedShader shader; loadShaderTextured(&shader, "textured_vertex.glsl", "textured_fragment.glsl"); int emojiTexture = loadTexture("emoji.png", 0, 0); MVPMatrices mvp; initMVP(&mvp); float aspect = (float)X_RES/(float)Y_RES; matrixSetOrthoProjection(mvp.projectionMatrix, -aspect, aspect, -1.0, 1.0, -1.0, 1.0); setShaderMVP(&mvp, shader.programID, shader.modelMatrixUniform, shader.viewMatrixUniform, shader.projectionMatrixUniform); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); int done = 0; SystemEvent event; while (!done) { while (systemPollEvent(&window, &event)) { if (event.type == EVENT_QUIT) { done = 1; } } glClear(GL_COLOR_BUFFER_BIT); drawTexture(emojiTexture, 0.8, 0.8, 0.0, 0.0, shader.positionAttribute, shader.texCoordAttribute); systemShowFrame(&window); } systemShutdown(); }
TEST_F(SurfaceTextureGLToGLTest, TexturingFromPreRotatedGLFilledBuffer) { enum { texWidth = 64 }; enum { texHeight = 16 }; // This test requires 3 buffers to complete run on a single thread. mST->setDefaultMaxBufferCount(3); // Set the transform hint. mST->setTransformHint(NATIVE_WINDOW_TRANSFORM_ROT_90); // Set the default buffer size. mST->setDefaultBufferSize(texWidth, texHeight); // Do the producer side of things EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface, mProducerEglSurface, mProducerEglContext)); ASSERT_EQ(EGL_SUCCESS, eglGetError()); // This is needed to ensure we pick up a buffer of the correct size and the // new rotation hint. eglSwapBuffers(mEglDisplay, mProducerEglSurface); glClearColor(0.6, 0.6, 0.6, 0.6); glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_SCISSOR_TEST); glScissor(24, 4, 1, 1); glClearColor(1.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); eglSwapBuffers(mEglDisplay, mProducerEglSurface); // Do the consumer side of things EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext)); ASSERT_EQ(EGL_SUCCESS, eglGetError()); glDisable(GL_SCISSOR_TEST); // Skip the first frame, which was empty ASSERT_EQ(NO_ERROR, mST->updateTexImage()); ASSERT_EQ(NO_ERROR, mST->updateTexImage()); glClearColor(0.2, 0.2, 0.2, 0.2); glClear(GL_COLOR_BUFFER_BIT); glViewport(0, 0, texWidth, texHeight); drawTexture(); EXPECT_TRUE(checkPixel( 0, 0, 153, 153, 153, 153)); EXPECT_TRUE(checkPixel(63, 0, 153, 153, 153, 153)); EXPECT_TRUE(checkPixel(63, 15, 153, 153, 153, 153)); EXPECT_TRUE(checkPixel( 0, 15, 153, 153, 153, 153)); EXPECT_TRUE(checkPixel(24, 4, 255, 0, 0, 255)); EXPECT_TRUE(checkPixel(25, 5, 153, 153, 153, 153)); EXPECT_TRUE(checkPixel(23, 3, 153, 153, 153, 153)); EXPECT_TRUE(checkPixel(45, 13, 153, 153, 153, 153)); EXPECT_TRUE(checkPixel(12, 8, 153, 153, 153, 153)); }
void MengMeiEye::onDraw() { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, m_texture); drawTexture(std::string("./res/MengMeiEye.jpg"), m_texture); drawSphere(0.15f); glDisable(GL_TEXTURE_2D); }
void Cube::draw(){ switch(drawType){ case TEXTURE: drawTexture(); break; case NOCOLOR: drawNoColor(); break; default: drawNormal(); break; } }
void WelcomeScreen::drawRulesScreen() { if (buttons.size() == 0) buttons.push_back(Button("", 144, 55, 39, 674, 0.0, 0.0, 0.0, 0.0, 0.25, 0.3)); drawTexture(loadTexture("images/backgrounds/pam/rulesscreen.pam"), 0, 0, WIDTH, HEIGHT); }
void GLRenderWidget::showPauseTexture() { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); QRectF r(- width() / 2 , - height() / 2, width(), height()); drawTexture(r, mPauseTexture); }
static bool displayOneVideoFrameGLX(int32_t fd, int32_t index) { ASSERT(glxContext && textureIds.size()); ASSERT(index>=0 && index<textureIds.size()); DEBUG("textureIds[%d] = 0x%x", index, textureIds[index]); int ret = drawTexture(glxContext, textureIds[index]); return ret == 0; }
/* LineInfoOverlay::drawSide * Draws side/texture info for [side] *******************************************************************/ void LineInfoOverlay::drawSide(int bottom, int right, float alpha, side_t& side, int xstart) { // Get colours rgba_t col_fg = ColourConfiguration::getColour("map_overlay_foreground"); col_fg.a = col_fg.a*alpha; // Index and sector index Drawing::drawText(side.info, xstart + 4, bottom - (32 * scale), col_fg, Drawing::FONT_CONDENSED); // Texture offsets Drawing::drawText(side.offsets, xstart + 4, bottom - (16 * scale), col_fg, Drawing::FONT_CONDENSED); // Textures int tex_box_size = 80 * scale; drawTexture(alpha, xstart + 4, bottom - (32 * scale), side.tex_upper, side.needs_upper); drawTexture(alpha, xstart + tex_box_size + 8, bottom - (32 * scale), side.tex_middle, side.needs_middle, "M"); drawTexture(alpha, xstart + tex_box_size + 12 + tex_box_size, bottom - (32 * scale), side.tex_lower, side.needs_lower, "L"); }
TEST_F(SurfaceTextureGLToGLTest, TexturingFromUserSizedGLFilledBuffer) { enum { texWidth = 64 }; enum { texHeight = 64 }; // This test requires 3 buffers to complete run on a single thread. mST->setDefaultMaxBufferCount(3); // Set the user buffer size. native_window_set_buffers_user_dimensions(mANW.get(), texWidth, texHeight); // Do the producer side of things EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface, mProducerEglSurface, mProducerEglContext)); ASSERT_EQ(EGL_SUCCESS, eglGetError()); // This is needed to ensure we pick up a buffer of the correct size. eglSwapBuffers(mEglDisplay, mProducerEglSurface); glClearColor(0.6, 0.6, 0.6, 0.6); glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_SCISSOR_TEST); glScissor(4, 4, 1, 1); glClearColor(1.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); eglSwapBuffers(mEglDisplay, mProducerEglSurface); // Do the consumer side of things EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext)); ASSERT_EQ(EGL_SUCCESS, eglGetError()); glDisable(GL_SCISSOR_TEST); // Skip the first frame, which was empty ASSERT_EQ(NO_ERROR, mST->updateTexImage()); ASSERT_EQ(NO_ERROR, mST->updateTexImage()); glClearColor(0.2, 0.2, 0.2, 0.2); glClear(GL_COLOR_BUFFER_BIT); glViewport(0, 0, texWidth, texHeight); drawTexture(); EXPECT_TRUE(checkPixel( 0, 0, 153, 153, 153, 153)); EXPECT_TRUE(checkPixel(63, 0, 153, 153, 153, 153)); EXPECT_TRUE(checkPixel(63, 63, 153, 153, 153, 153)); EXPECT_TRUE(checkPixel( 0, 63, 153, 153, 153, 153)); EXPECT_TRUE(checkPixel( 4, 4, 255, 0, 0, 255)); EXPECT_TRUE(checkPixel( 5, 5, 153, 153, 153, 153)); EXPECT_TRUE(checkPixel( 3, 3, 153, 153, 153, 153)); EXPECT_TRUE(checkPixel(45, 52, 153, 153, 153, 153)); EXPECT_TRUE(checkPixel(12, 36, 153, 153, 153, 153)); }
void PGE_QuestionBox::render() { if(_page==2) { if(_textureUsed) { drawTexture(_sizeRect); } else { GlRenderer::renderRect(_sizeRect.left(), _sizeRect.top(), _sizeRect.width(), _sizeRect.height(), bg_color.red()/255.0f, bg_color.green()/255.0f, bg_color.blue()/255.0f, fader_opacity); } FontManager::printText(title, _sizeRect.center().x()-title_size.w()/2, _sizeRect.top()+padding, fontID, fontRgba.Red(), fontRgba.Green(), fontRgba.Blue(), fontRgba.Alpha()); _menu.render(); // FontManager::SDL_string_render2D(_sizeRect.left()+padding, // _sizeRect.top()+padding, // &textTexture); } else { if(_textureUsed) { drawTexture(_sizeRect.center().x()-(width + padding)*fader_opacity, _sizeRect.center().y()-(height + padding)*fader_opacity, _sizeRect.center().x()+(width + padding)*fader_opacity, _sizeRect.center().y()+(height + padding)*fader_opacity); } else { GlRenderer::renderRectBR(_sizeRect.center().x() - (width+padding)*fader_opacity , _sizeRect.center().y() - (height+padding)*fader_opacity, _sizeRect.center().x() + (width+padding)*fader_opacity, _sizeRect.center().y() + (height+padding)*fader_opacity, bg_color.red()/255.0f, bg_color.green()/255.0f, bg_color.blue()/255.0f, fader_opacity); } } }
/** @param texture The texture to draw. @param rect The rect to draw. @param rotation Rotation of the rect. @note The rotation is measured in radians. */ void Graphics::drawTexture(IDirect3DTexture9 *texture, Rect rect, float rotation) { // Transform to x, y, width and height representation. float width = rect.right - rect.left; float height = rect.bottom - rect.top; float x = rect.left + width/2; float y = rect.top + height/2; // Call the other drawTexture() function. drawTexture(texture, x, y, width, height, rotation); }
void drawBackground(Game* game) { Background* background = &game->background; if(background->repeatY) { int from, to; from = ((int)background->position.y % game->internalResolution.y) - background->texture->height; for(int i = from; i < game->internalResolution.y; i += background->texture->height) { drawTexture(game, background->texture, createPointf(background->position.x, i), background->depth); } } else drawTexture(game, background->texture, background->position, background->depth); }