Implement transparancy for textures.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "ImageInteractionAnimation.hpp"
|
||||
#include "glutils.hpp"
|
||||
#include "MultiImageVisualisation.hpp"
|
||||
#include "RenderingState.hpp"
|
||||
#include <caffe/util/math_functions.hpp>
|
||||
|
||||
using namespace fmri;
|
||||
@@ -10,7 +11,9 @@ void ImageInteractionAnimation::draw(float step)
|
||||
{
|
||||
auto &vertexBuffer = animate(startingPositions, deltas, step);
|
||||
|
||||
drawImageTiles(vertexBuffer.size() / 3, vertexBuffer.data(), textureCoordinates.data(), texture);
|
||||
float alpha = RenderingState::instance().interactionAlpha();
|
||||
|
||||
drawImageTiles(vertexBuffer.size() / 3, vertexBuffer.data(), textureCoordinates.data(), texture, alpha);
|
||||
}
|
||||
|
||||
ImageInteractionAnimation::ImageInteractionAnimation(const DType *data, const std::vector<int> &shape, const std::vector<float> &prevPositions,
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <opencv2/core.hpp>
|
||||
#include "InputLayerVisualisation.hpp"
|
||||
#include "Range.hpp"
|
||||
#include "RenderingState.hpp"
|
||||
#include "glutils.hpp"
|
||||
|
||||
using namespace fmri;
|
||||
using namespace std;
|
||||
@@ -81,15 +83,7 @@ void InputLayerVisualisation::render()
|
||||
0, 0,
|
||||
};
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, 0, vertices);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
texture.bind(GL_TEXTURE_2D);
|
||||
glDrawArrays(GL_QUADS, 0, 4);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
float alpha = RenderingState::instance().layerAlpha();
|
||||
|
||||
drawImageTiles(4, vertices, texCoords, texture, alpha);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "MultiImageVisualisation.hpp"
|
||||
#include "glutils.hpp"
|
||||
#include "Range.hpp"
|
||||
#include "RenderingState.hpp"
|
||||
|
||||
using namespace fmri;
|
||||
using namespace std;
|
||||
@@ -26,7 +27,8 @@ MultiImageVisualisation::MultiImageVisualisation(const fmri::LayerData &layer)
|
||||
|
||||
void MultiImageVisualisation::render()
|
||||
{
|
||||
drawImageTiles(vertexBuffer.size() / 3, vertexBuffer.data(), texCoordBuffer.data(), texture);
|
||||
float alpha = RenderingState::instance().layerAlpha();
|
||||
drawImageTiles(vertexBuffer.size() / 3, vertexBuffer.data(), texCoordBuffer.data(), texture, alpha);
|
||||
}
|
||||
|
||||
vector<float> MultiImageVisualisation::getVertices(const std::vector<float> &nodePositions, float scaling)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "PoolingLayerAnimation.hpp"
|
||||
#include "glutils.hpp"
|
||||
#include "MultiImageVisualisation.hpp"
|
||||
#include "RenderingState.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace fmri;
|
||||
@@ -32,7 +33,9 @@ void PoolingLayerAnimation::draw(float timeStep)
|
||||
{
|
||||
auto& vertexBuffer = animate(startingPositions, deltas, timeStep);
|
||||
|
||||
drawImageTiles(vertexBuffer.size() / 3, vertexBuffer.data(), textureCoordinates.data(), original);
|
||||
float alpha = RenderingState::instance().interactionAlpha();
|
||||
|
||||
drawImageTiles(vertexBuffer.size() / 3, vertexBuffer.data(), textureCoordinates.data(), original, alpha);
|
||||
}
|
||||
|
||||
Texture PoolingLayerAnimation::loadTextureForData(const LayerData &data)
|
||||
|
||||
@@ -138,12 +138,13 @@ void fmri::setOrthographicProjection() {
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
void fmri::drawImageTiles(int n, const float *vertexBuffer, const float *textureCoords, const Texture &texture)
|
||||
void fmri::drawImageTiles(int n, const float *vertexBuffer, const float *textureCoords, const Texture &texture, float alpha)
|
||||
{
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
glColor4f(1, 1, 1, alpha);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
texture.bind(GL_TEXTURE_2D);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, textureCoords);
|
||||
glVertexPointer(3, GL_FLOAT, 0, vertexBuffer);
|
||||
|
||||
@@ -63,5 +63,6 @@ namespace fmri {
|
||||
* @param textureCoords
|
||||
* @param texture
|
||||
*/
|
||||
void drawImageTiles(int n, const float* vertexBuffer, const float* textureCoords, const Texture& texture);
|
||||
void
|
||||
drawImageTiles(int n, const float *vertexBuffer, const float *textureCoords, const Texture &texture, float alpha);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user