Ion: doc/usersguide/examples/rectangle.cc Source File
51 static std::unique_ptr<GlobalState> s_global_state;
61 static const ion::gfx::NodePtr BuildGraph(int window_width, int window_height) {
66 rect_spec.size.Set(2.f, 2.f);
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);
85 0.0f, 0.0f, -1.905f, -13.798f,
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;
117 s_global_state->renderer->DrawScene(s_global_state->scene_root);
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[]) {
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");
165 glutKeyboardFunc(Keyboard);
166 glutKeyboardUpFunc(KeyboardUp);
171 s_global_state->renderer.Reset(new ion::gfx::Renderer(graphics_manager));
GraphicsManager manages the graphics library for an application.
static const ShaderInputRegistryPtr & GetGlobalRegistry()
Returns the ShaderInputRegistry instance representing all supported global uniforms and attributes...
int main(int argc, char *argv[])
Mainline.
A Uniform instance represents a uniform shader argument.
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.
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.