-
Notifications
You must be signed in to change notification settings - Fork 4
Home
Raphael Menges edited this page Mar 3, 2016
·
23 revisions
One need the compiled library and the header file with the interface for usage. Besides of this, GLEW and GLFW3 are used in the example below to load the OpenGL functions and to create a window.
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <iostream>
#include "eyeGUI.h"
// Callback to receive information from eyeGUI
void printCallback(std::string message)
{
std::cout << message << std::endl;
}
// Main function
int main()
{
// Window and OpenGL initialization
glfwInit();
GLFWwindow* window = glfwCreateWindow(1280, 720, "eyeGUI", NULL, NULL);
glfwMakeContextCurrent(window);
glewInit();
// Set callbacks
eyegui::setErrorCallback(&printCallback);
eyegui::setWarningCallback(&printCallback);
// Create GUI
eyegui::GUIBuilder guiBuilder;
guiBuilder.width = 1280;
guiBuilder.height = 720;
eyegui::GUI* pGUI = guiBuilder.construct();
// Add simple layout from harddisk
eyegui::Layout* pLayout = eyegui::addLayout(pGUI, "HelloLayout.xeyegui");
// Prepare delta time calculation
float lastTime, deltaTime;
lastTime = (float)glfwGetTime();
// Main loop
while (!glfwWindowShouldClose(window))
{
// Calculate delta time per frame
float currentTime = (float)glfwGetTime();
deltaTime = currentTime - lastTime;
lastTime = currentTime;
// Clearing of buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Get current mouse cursor position and give it to eyeGUI as gaze
double x, y;
glfwGetCursorPos(window, &x, &y);
eyegui::Input input;
input.gazeX = x;
input.gazeY = y;
// Update GUI
eyegui::Input usedInput = eyegui::updateGUI(pGUI, deltaTime, input);
// "usedInput" can be piped to content behind the user interface
// Draw GUI
eyegui::drawGUI(pGUI);
// Swap front and back buffers and poll events
glfwSwapBuffers(window);
glfwPollEvents();
}
// Delete GUI object
eyegui::terminateGUI(pGUI);
// Termination of program
glfwTerminate();
return 0;
}
The example layout in "HelloLayout.xeyegui" listed below.
<?xml version="1.0"?>
<layout>
<circlebutton></circlebutton>
</layout>
The program should compile if linked correctly and display a circular, window filling button with a red cross as icon.
- Layouts
- Elements
- Notifications
- Manipulation
- Configuration
- Styling
- Bricks
- Frames
- Localization
- Keyboard
- Tips
- Examples
All interface functions are documented in the header file itself.