Add keyboard input and model info keybind
Pressing 'i' will show a dialog box with the model info
This commit is contained in:
parent
972a0cc9b9
commit
fe75856701
|
@ -70,6 +70,7 @@ add_executable( fc2d
|
||||||
src/error.cpp
|
src/error.cpp
|
||||||
src/eye.cpp
|
src/eye.cpp
|
||||||
src/configfile.cpp
|
src/configfile.cpp
|
||||||
|
src/input.cpp
|
||||||
packaging/fc2d.rc
|
packaging/fc2d.rc
|
||||||
)
|
)
|
||||||
target_link_libraries( fc2d ${OpenCV_LIBS} ${OPENGL_LIBRARIES} ${WEBP_LIBRARIES}
|
target_link_libraries( fc2d ${OpenCV_LIBS} ${OPENGL_LIBRARIES} ${WEBP_LIBRARIES}
|
||||||
|
|
|
@ -23,6 +23,12 @@
|
||||||
#include <cv.hpp>
|
#include <cv.hpp>
|
||||||
#include <args.hpp>
|
#include <args.hpp>
|
||||||
#include <error.hpp>
|
#include <error.hpp>
|
||||||
|
#include <input.hpp>
|
||||||
|
|
||||||
|
#ifndef NO_GRAPHICAL_DIALOG
|
||||||
|
#include <boxer/boxer.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
GLuint shader; //standard shader program used for all elements
|
GLuint shader; //standard shader program used for all elements
|
||||||
GLuint transUniform; //location of the "transMatrix" transformation matrix uniform in the shader
|
GLuint transUniform; //location of the "transMatrix" transformation matrix uniform in the shader
|
||||||
|
@ -98,6 +104,9 @@ void initGraphics () {
|
||||||
glutInitWindowSize(512, 512);
|
glutInitWindowSize(512, 512);
|
||||||
glutCreateWindow(PROJECT_NAME);
|
glutCreateWindow(PROJECT_NAME);
|
||||||
|
|
||||||
|
// input callback
|
||||||
|
glutKeyboardFunc(keyInput);
|
||||||
|
|
||||||
glewExperimental = GL_TRUE;
|
glewExperimental = GL_TRUE;
|
||||||
glewInit();
|
glewInit();
|
||||||
|
|
||||||
|
@ -237,3 +246,7 @@ void updateModel(struct FaceData faceData) {
|
||||||
//tell FreeGLUT to schedule a screen update
|
//tell FreeGLUT to schedule a screen update
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showModelInfo() {
|
||||||
|
boxer::show(model->getInfoString().c_str(), "Model info", boxer::Style::Info);
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#include <glm/vec2.hpp>
|
#include <glm/vec2.hpp>
|
||||||
|
|
||||||
#include <cv.hpp>
|
#include <cv.hpp>
|
||||||
|
#include <model.hpp>
|
||||||
|
#include <modelpart.hpp>
|
||||||
|
|
||||||
extern GLuint transUniform;
|
extern GLuint transUniform;
|
||||||
extern float windowAspectRatio;
|
extern float windowAspectRatio;
|
||||||
|
@ -28,4 +30,6 @@ void printShaderCompileLog(GLuint shader);
|
||||||
|
|
||||||
void updateModel(struct FaceData faceData);
|
void updateModel(struct FaceData faceData);
|
||||||
|
|
||||||
|
void showModelInfo();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
12
src/input.cpp
Normal file
12
src/input.cpp
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#include <input.hpp>
|
||||||
|
#include <graphics.hpp>
|
||||||
|
|
||||||
|
void keyInput(unsigned char key, int x, int y) {
|
||||||
|
switch(key) {
|
||||||
|
case 'i': // model info
|
||||||
|
showModelInfo();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
6
src/input.hpp
Normal file
6
src/input.hpp
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef INPUT_HPP
|
||||||
|
#define INPUT_HPP
|
||||||
|
|
||||||
|
void keyInput(unsigned char key, int x, int y);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue