Integrating Visualization Modules

from ChangeList 20718 Due to updates in the overlay image
p4#: 20781
This commit is contained in:
Jacob Støren
2013-03-06 09:25:33 +01:00
parent 466eb906aa
commit 5247d6687d
3 changed files with 47 additions and 13 deletions

View File

@@ -153,6 +153,23 @@ void OverlayImage::render(OpenGLContext* oglContext, const Vec2i& position, cons
if (software)
{
// Create a POW2 texture for software rendering if needed
if (m_image.notNull() && m_pow2Image.isNull() && (!Math::isPow2(m_image->width()) || !Math::isPow2(m_image->height())))
{
m_pow2Image = new TextureImage;
m_pow2Image->allocate(Math::roundUpPow2(m_image->width()), Math::roundUpPow2(m_image->height()));
m_pow2Image->fill(Color4ub(Color3::BLACK));
for (uint y = 0; y < m_image->height(); ++y)
{
for (uint x = 0; x < m_image->width(); ++x)
{
m_pow2Image->setPixel(x, y, m_image->pixel(x, y));
}
}
}
if (ShaderProgram::supportedOpenGL(oglContext))
{
ShaderProgram::useNoProgram(oglContext);
@@ -166,19 +183,33 @@ void OverlayImage::render(OpenGLContext* oglContext, const Vec2i& position, cons
RenderStateLighting_FF light(false);
light.applyOpenGL(oglContext);
// Use fixed function texture setup
ref<Texture2D_FF> texture = new Texture2D_FF(m_image.p());
texture->setWrapMode(Texture2D_FF::CLAMP);
texture->setMinFilter(Texture2D_FF::NEAREST);
texture->setMagFilter(Texture2D_FF::NEAREST);
texture->setupTexture(oglContext);
texture->setupTextureParams(oglContext);
if (m_textureBindings.isNull())
{
// Use fixed function texture setup
ref<Texture2D_FF> texture = new Texture2D_FF(m_pow2Image.notNull() ? m_pow2Image.p() : m_image.p());
texture->setWrapMode(Texture2D_FF::CLAMP);
texture->setMinFilter(Texture2D_FF::NEAREST);
texture->setMagFilter(Texture2D_FF::NEAREST);
texture->setupTexture(oglContext);
texture->setupTextureParams(oglContext);
ref<RenderStateTextureMapping_FF> textureMapping = new RenderStateTextureMapping_FF(texture.p());
textureMapping->setTextureFunction(m_blendMode == TEXTURE_ALPHA ? RenderStateTextureMapping_FF::MODULATE : RenderStateTextureMapping_FF::DECAL);
ref<RenderStateTextureMapping_FF> textureMapping = new RenderStateTextureMapping_FF(texture.p());
textureMapping->setTextureFunction(m_blendMode == TEXTURE_ALPHA ? RenderStateTextureMapping_FF::MODULATE : RenderStateTextureMapping_FF::DECAL);
m_textureBindings = textureMapping;
m_textureBindings = textureMapping;
}
#endif
// Adjust texture coordinates
if (m_pow2Image.notNull())
{
float xMax = static_cast<float>(m_image->width())/static_cast<float>(m_pow2Image->width());
float yMax = static_cast<float>(m_image->height())/static_cast<float>(m_pow2Image->height());
textureCoords[2] = xMax;
textureCoords[4] = xMax;
textureCoords[5] = yMax;
textureCoords[7] = yMax;
}
projCam.applyOpenGL();
}
else
@@ -228,8 +259,9 @@ void OverlayImage::render(OpenGLContext* oglContext, const Vec2i& position, cons
}
}
Vec3f min(1.0f, 1.0f, 0.0f);
Vec3f max(static_cast<float>(size.x() - 1), static_cast<float>(size.y() - 1), 0.0f);
float offset = 0.0f;
Vec3f min(offset, offset, 0.0f);
Vec3f max(static_cast<float>(size.x()) + offset, static_cast<float>(size.y()) + offset, 0.0f);
// Setup the vertex array
float* v1 = &vertexArray[0];
@@ -308,6 +340,7 @@ void OverlayImage::render(OpenGLContext* oglContext, const Vec2i& position, cons
void OverlayImage::setImage(TextureImage* image)
{
m_image = image;
m_pow2Image = NULL;
m_texture = new Texture(image);

View File

@@ -68,6 +68,7 @@ private:
private:
Vec2ui m_size;
ref<TextureImage> m_image;
ref<TextureImage> m_pow2Image;
ref<Sampler> m_sampler;
ref<RenderState> m_textureBindings;
ref<Texture> m_texture;

View File

@@ -1115,7 +1115,7 @@ bool OverlayNavigationCube::pick(int winCoordX, int winCoordY, const Vec2i& posi
bool OverlayNavigationCube::updateHighlight(int winCoordX, int winCoordY, const Vec2i& position, const Vec2ui& size)
{
// Early out
if (winCoordX < position.x() || winCoordY > (position.x() + static_cast<int>(size.x())) ||
if (winCoordX < position.x() || winCoordX > (position.x() + static_cast<int>(size.x())) ||
winCoordY < position.y() || winCoordY > (position.y() + static_cast<int>(size.y())))
{
bool redraw = m_hightlightItem != NCI_NONE;