Starting a project

This is how to start a project from scratch. Here are the basic parts and why they are needed.

Starting a project

Windows

OS X (Xcode)

Linux

Rubric

Running green/blue project 0 : Incomplete 10 : Complete

Here is the base code we will use:

#include <SFML/Window.hpp>

//TODO: Add include for GL3W here


int main(int argc, char const** argv)
{
    // Get OpenGL context
    sf::VideoMode mode(512, 512, 32);
    sf::ContextSettings settings(32, 0, 0, 3, 3, sf::ContextSettings::Core);

    // Create the main window
    sf::Window window(mode, "Project", sf::Style::Default, settings);

    // Init GL3W
    if (gl3wInit()) {
        fprintf(stderr, "failed to initialize OpenGL\n");
    }

    // If you want to do graphics setup, this is a good place to do it
    // Resolving resource paths and other system settings can be hard!

    bool toggle = true;

    // Start the game loop
    while (window.isOpen())
    {
        glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
        if(toggle)
            glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        toggle = !toggle;

        // Process events
        sf::Event event;
        while (window.pollEvent(event))
        {
            // Close window: exit
            if (event.type == sf::Event::Closed) {
                window.close();
            }
            if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) {
                window.close();
            }
        }

        // Update the window
        window.display();
    }

    return EXIT_SUCCESS;
}