KINECT STATS GENERATOR FOR SPORTS VISUALISATION
1.0
|
this is taken from Jon's demo More...
#include <ScreenQuad.h>
Public Member Functions | |
ScreenQuad (int _textureWidth, int _textureHeight, const std::string &_shader) | |
ctor, note this will scale to any screen size so the width and height are for the texture image passed in | |
~ScreenQuad () | |
void | draw (cv::Mat *_data) |
void | setTextureMode (GLenum _mode) |
Private Attributes | |
GLuint | m_vao |
GLuint | m_texture |
std::string | m_shader |
int | m_textureWidth |
int | m_textureHeight |
GLenum | m_textureMode |
this is taken from Jon's demo
Definition at line 18 of file ScreenQuad.h.
ScreenQuad::ScreenQuad | ( | int | _textureWidth, |
int | _textureHeight, | ||
const std::string & | _shader | ||
) |
ctor, note this will scale to any screen size so the width and height are for the texture image passed in
Definition at line 5 of file ScreenQuad.cpp.
References m_shader, m_texture, m_textureHeight, m_textureMode, m_textureWidth, and m_vao.
{ //static ngl::Vec3 verts[]= // { // ngl::Vec3(-1,-1,0), // ngl::Vec3(1,-1,0), // ngl::Vec3(1,1,0), // ngl::Vec3(1,1,0), // ngl::Vec3(-1,-1,0), // ngl::Vec3(-1,1,0) // }; static ngl::Vec3 verts[]= { ngl::Vec3(-1,-1,0), ngl::Vec3(-1,1,0), ngl::Vec3(1,1,0), ngl::Vec3(1,1,0), ngl::Vec3(-1,-1,0), ngl::Vec3(1,-1,0) }; //static ngl::Vec2 uv[]= // { // ngl::Vec2(1,1), // ngl::Vec2(0,1), // ngl::Vec2(0,0), // ngl::Vec2(0,0), // ngl::Vec2(1,1), // ngl::Vec2(1,0) // }; static ngl::Vec2 uv[]= { ngl::Vec2(0,1), ngl::Vec2(0,0), ngl::Vec2(1,0), ngl::Vec2(1,0), ngl::Vec2(0,1), ngl::Vec2(1,1) }; m_shader=_shader; m_textureWidth=_width; m_textureHeight=_height; glGenVertexArrays(1,&m_vao); glBindVertexArray(m_vao); GLuint vbo[2]; glGenBuffers(2,vbo); glBindBuffer(GL_ARRAY_BUFFER,vbo[0]); glBufferData(GL_ARRAY_BUFFER,6*sizeof(ngl::Vec3),&verts[0].m_x,GL_STATIC_DRAW); glVertexAttribPointer(0, // atrib 0 3, // with x,y,z GL_FLOAT, // what type GL_FALSE, // normalize? 0, // stride 0 // start ptr ); glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER,vbo[1]); glBufferData(GL_ARRAY_BUFFER,6*sizeof(ngl::Vec2),&uv[0].m_x,GL_STATIC_DRAW); glVertexAttribPointer(1, // atrib 1 2, // with u,v GL_FLOAT, // what type GL_FALSE, // normalize? 0, // stride 0 // start ptr ); glEnableVertexAttribArray(1); glBindVertexArray(0); glGenTextures(1, &m_texture); glActiveTextureARB(GL_TEXTURE0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); m_textureMode=GL_RGB; }
void ScreenQuad::draw | ( | cv::Mat * | _data | ) |
Definition at line 104 of file ScreenQuad.cpp.
References m_shader, m_texture, m_textureHeight, m_textureMode, m_textureWidth, and m_vao.
{ ngl::ShaderLib *shader = ngl::ShaderLib::instance(); shader->use(m_shader); shader->setUniform("textureFlag",false); //glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glBindVertexArray(m_vao); glBindTexture(GL_TEXTURE_2D, m_texture); glTexImage2D(GL_TEXTURE_2D, 0, m_textureMode, m_textureWidth, m_textureHeight, 0, m_textureMode, GL_UNSIGNED_BYTE, &_data->data[0]); glGenerateMipmap(GL_TEXTURE_2D); glDrawArrays(GL_TRIANGLES,0,6); glBindVertexArray(0); }
void ScreenQuad::setTextureMode | ( | GLenum | _mode | ) | [inline] |
Definition at line 31 of file ScreenQuad.h.
References m_textureMode.
{m_textureMode=_mode;}
std::string ScreenQuad::m_shader [private] |
Definition at line 36 of file ScreenQuad.h.
GLuint ScreenQuad::m_texture [private] |
Definition at line 35 of file ScreenQuad.h.
int ScreenQuad::m_textureHeight [private] |
Definition at line 38 of file ScreenQuad.h.
GLenum ScreenQuad::m_textureMode [private] |
Definition at line 39 of file ScreenQuad.h.
int ScreenQuad::m_textureWidth [private] |
Definition at line 37 of file ScreenQuad.h.
GLuint ScreenQuad::m_vao [private] |
Definition at line 34 of file ScreenQuad.h.