32 #include "GL/freeglut.h"
51 static std::unique_ptr<GlobalState> s_global_state;
66 rect_spec.
size.Set(2.f, 2.f);
71 state_table->SetViewport(
72 ion::math::Range2i::BuildWithSize(ion::math::Point2i(0, 0),
73 ion::math::Vector2i(window_width,
75 state_table->SetClearColor(ion::math::Vector4f(0.3f, 0.3f, 0.5f, 1.0f));
76 state_table->SetClearDepthValue(1.f);
79 root->SetStateTable(state_table);
84 0.0f, 1.732f, 0.0f, 0.0f,
85 0.0f, 0.0f, -1.905f, -13.798f,
86 0.0f, 0.0f, -1.0f, 0.0f);
88 0.0f, 1.0f, 0.0f, 0.0f,
89 0.0f, 0.0f, 1.0f, -5.0f,
90 0.0f, 0.0f, 0.0f, 1.0f);
92 "uProjectionMatrix", proj));
94 "uModelviewMatrix", view));
96 "uBaseColor", ion::math::Vector4f(1.f, 1.f, 0.f, 1.f)));
109 static void Resize(
int w,
int h) {
110 s_global_state->window_width = w;
111 s_global_state->window_height = h;
115 static void Render() {
116 if (s_global_state.get())
117 s_global_state->renderer->DrawScene(s_global_state->scene_root);
121 static void Update() {
125 static void Keyboard(
unsigned char key,
int x,
int y) {
129 static void KeyboardUp(
unsigned char key,
int x,
int y) {
132 s_global_state.reset(NULL);
149 int main(
int argc,
char* argv[]) {
150 glutInit(&argc, argv);
152 s_global_state.reset(
new GlobalState);
153 s_global_state->window_width = s_global_state->window_height = 800;
154 s_global_state->scene_root = BuildGraph(s_global_state->window_width,
155 s_global_state->window_height);
157 glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE);
158 glutSetOption(GLUT_MULTISAMPLE, 16);
159 glutInitWindowSize(s_global_state->window_width,
160 s_global_state->window_height);
162 glutCreateWindow(
"Ion rectangle example");
163 glutDisplayFunc(Render);
164 glutReshapeFunc(Resize);
165 glutKeyboardFunc(Keyboard);
166 glutKeyboardUpFunc(KeyboardUp);
167 glutIdleFunc(Update);
GraphicsManager manages the graphics library for an application.
int main(int argc, char *argv[])
Mainline.
The Matrix class defines a square N-dimensional matrix.
A StateTable represents a collection of graphical state items that affect OpenGL rendering.
A Node instance represents a node in a scene graph.
A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting...
const gfx::ShapePtr BuildRectangleShape(const RectangleSpec &spec)
Builds and returns a Shape representing a rectangle in one of the principal Cartesian planes...
The Renderer class handles rendering ION scene graphs using OpenGL.