本文整理汇总了C++中TexturePtr::width方法的典型用法代码示例。如果您正苦于以下问题:C++ TexturePtr::width方法的具体用法?C++ TexturePtr::width怎么用?C++ TexturePtr::width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TexturePtr
的用法示例。
在下文中一共展示了TexturePtr::width方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doBlitTexture
// XXX Need a way to deal with blits with Camera/Lighting.
void DisplayDeviceOpenGL::doBlitTexture(const TexturePtr& tex, int dstx, int dsty, int dstw, int dsth, float rotation, int srcx, int srcy, int srcw, int srch)
{
ASSERT_LOG(false, "DisplayDevice::doBlitTexture deprecated");
ASSERT_LOG(!tex, "Texture passed in was not of expected type.");
const float tx1 = float(srcx) / tex->width();
const float ty1 = float(srcy) / tex->height();
const float tx2 = srcw == 0 ? 1.0f : float(srcx + srcw) / tex->width();
const float ty2 = srch == 0 ? 1.0f : float(srcy + srch) / tex->height();
const float uv_coords[] = {
tx1, ty1,
tx2, ty1,
tx1, ty2,
tx2, ty2,
};
const float vx1 = float(dstx);
const float vy1 = float(dsty);
const float vx2 = float(dstx + dstw);
const float vy2 = float(dsty + dsth);
const float vtx_coords[] = {
vx1, vy1,
vx2, vy1,
vx1, vy2,
vx2, vy2,
};
// Apply blend mode from texture if there is any.
BlendEquationScopeOGL be_scope(*tex);
BlendModeScopeOGL bm_scope(*tex);
glm::mat4 model = glm::translate(glm::mat4(1.0f), glm::vec3((vx1+vx2)/2.0f,(vy1+vy2)/2.0f,0.0f)) * glm::rotate(glm::mat4(1.0f), rotation, glm::vec3(0.0f,0.0f,1.0f)) * glm::translate(glm::mat4(1.0f), glm::vec3(-(vx1+vy1)/2.0f,-(vy1+vy1)/2.0f,0.0f));
glm::mat4 mvp = glm::ortho(0.0f, 800.0f, 600.0f, 0.0f) * model;
auto shader = OpenGL::ShaderProgram::defaultSystemShader();
shader->makeActive();
getDefaultShader()->setUniformsForTexture(tex);
shader->setUniformValue(shader->getMvpUniform(), glm::value_ptr(mvp));
shader->setUniformValue(shader->getColorUniform(), glm::value_ptr(glm::vec4(1.0f,1.0f,1.0f,1.0f)));
// XXX the following line are only temporary, obviously.
//shader->setUniformValue(shader->getUniform("discard"), 0);
glEnableVertexAttribArray(shader->getVertexAttribute());
glVertexAttribPointer(shader->getVertexAttribute(), 2, GL_FLOAT, GL_FALSE, 0, vtx_coords);
glEnableVertexAttribArray(shader->getTexcoordAttribute());
glVertexAttribPointer(shader->getTexcoordAttribute(), 2, GL_FLOAT, GL_FALSE, 0, uv_coords);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glDisableVertexAttribArray(shader->getTexcoordAttribute());
glDisableVertexAttribArray(shader->getVertexAttribute());
}
示例2: texture
// テクスチャ設定
void Sprite::texture(
TexturePtr tex
) {
texture_ = tex;
T3_NULL_ASSERT( texture_ );
float tex_width = static_cast<float>(tex->width());
float tex_height = static_cast<float>(tex->height());
size(Vec2(tex_width, tex_height));
adjustPivotByCenter();
}