Giter VIP home page Giter VIP logo

cpp-opengl-gui's Introduction

Cpp-OpenGL-GUI

Graphical user interface written in C++ using FreeGLUT.

Quick overview of the features:
youtube vid_0

Getting started

MainWindow

The main window wraps glutCreateWindow, handles the keyboard/mouse input events, and limits the fps of the gui.

To create the main window with the title "MainWindow" at (100, 100) point on screen with a width of 960 pixels and a height of 540 pixels:

GLUI::MainWindow* main_window = new GLUI::MainWindow("MainWindow", 100, 100, 960, 540);

For proper operation, you must forward the events of glut to the main window:

glutKeyboardFunc(on_keyboard_down);
glutKeyboardUpFunc(on_keyboard_up);
glutSpecialFunc(on_special_down);
glutSpecialUpFunc(on_special_up);
glutMouseFunc(on_mouse);
glutMotionFunc(on_mouse_motion);
glutPassiveMotionFunc(on_mouse_motion_passive);

void on_keyboard_down(unsigned char key, int x, int y) {
	main_window->on_keyboard_down(key, x, y);
}
void on_keyboard_up(unsigned char key, int x, int y) {
	main_window->on_keyboard_up(key, x, y);
}
void on_special_down(int key, int x, int y) {
	main_window->on_special_down(key, x, y);
}
void on_special_up(int key, int x, int y) {
	main_window->on_special_up(key, x, y);
}
void on_mouse(int button, int state, int x, int y) {
	main_window->on_mouse(button, state, x, y);
}
void on_mouse_motion(int x, int y) {
	main_window->on_mouse_motion(x, y);
}
void on_mouse_motion_passive(int x, int y) {
	main_window->on_mouse_motion_passive(x, y);
}

To render the gui components:

glutDisplayFunc(on_display);

void on_display() {
	glClearColor(0.1f, 0.2f, 0.3f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	main_window->render();
	glutSwapBuffers();
}

It does not matter how many times you call the render method, it will draw itself only as many times what it's configured fps defines.

Window

Windows are almost behave like windows in Windows (the OS), you can move/resize/collapse them.

To create a window at (10, 10) in the parent component, with a width of 800 pixels and a height of 500 pixels:

GLUI::Window* window = new GLUI::Window("Window 0", 10, 10, 800, 500);
main_window->add_component(window);

cpp-opengl-gui's People

Contributors

zoltan-hadur avatar

Stargazers

 avatar Konstantin Rebrov avatar Mrrebrik avatar  avatar Sheng-Hao Liao avatar Artem Golovin avatar Shujaat Ali Khan avatar  avatar  avatar Manmohan Bishnoi avatar  avatar

Watchers

James Cloos avatar GP Wang avatar  avatar Shujaat Ali Khan avatar

cpp-opengl-gui's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.