Exemplo n.º 1
0
void BaseGame::limitFrameRate(int limit, bool vsync)
{
	auto window = Locator::locate<RenderService>()->getWindow();

	window->setFramerateLimit(limit);
	window->setVerticalSyncEnabled(vsync);
}
Exemplo n.º 2
0
void Window::initialize()
{
    // Setup default behaviours (to get a consistent behaviour across different implementations)
    setVisible(true);
    setMouseCursorVisible(true);
    setVerticalSyncEnabled(false);
    setKeyRepeatEnabled(true);

    // Get and cache the initial size of the window
    m_size = m_impl->getSize();

	glewExperimental = GL_TRUE;

	GLenum res = glewInit();
	if (res != GLEW_OK)
	{
		std::cout << glewGetErrorString(res) << std::endl;
	}

    // Reset frame time
    m_clock.restart();

    // Activate the window
    setActive();

    // Notify the derived class
    onCreate();
}
Exemplo n.º 3
0
Window::Window()
    : m_running(true),
      m_zoneModel(nullptr)
{
    sf::ContextSettings settings;
    settings.depthBits          = 24;
    settings.stencilBits        = 8;
    settings.antialiasingLevel  = gConfig.getInt(Config::AntiAliasLevel, 0);
    settings.majorVersion       = 3;
    settings.minorVersion       = 0;
    
    int style = 0;
    
    if (!gConfig.getBool(Config::HideTitleBar, false))
    {
        style = sf::Style::Titlebar | sf::Style::Close;
    }
    
    if (gConfig.getBool(Config::Fullscreen, false))
    {
        style |= sf::Style::Fullscreen;
    }
    
    sf::VideoMode videoMode;
    
    if (gConfig.getBool(Config::UseNativeAspectRatio, false))
    {
        videoMode = sf::VideoMode::getDesktopMode();
    }
    else
    {
        videoMode.width     = gConfig.getInt(Config::ScreenWidth, 800);
        videoMode.height    = gConfig.getInt(Config::ScreenHeight, 600);
    }
    
    create(videoMode, "ZEQ", style, settings);
    
    setKeyRepeatEnabled(false);
    setVerticalSyncEnabled(gConfig.getBool(Config::Vsync, false));
    
    settings = getSettings();
    
    gLog.printf("OpenGL %u.%u\n", settings.majorVersion, settings.minorVersion);
    
    OpenGL::loadExtensions();
    
    m_input.getCamera().applyView();
    m_prevTime = m_deltaTimer.seconds();
    
    
    
    
    
    m_animModel = nullptr;
    m_skele = nullptr;
}
Exemplo n.º 4
0
GraphicsEngine::GraphicsEngine(std::string title, GLint width, GLint height) :
    sf::RenderWindow(sf::VideoMode(width, height),
                     title,
                     sf::Style::Default,
                     sf::ContextSettings(24, 8, 4, 3, 3))
{
    // Turn on GLEW
    if (glewInit())
    {
        std::cerr << "Unable to initialize GLEW ... exiting" << std::endl;
        exit(EXIT_FAILURE);
    }

    std::string vert_shader =
        "#version 330 core\n"
        "layout(location = 0) in vec4 position;\n"
        "layout(location = 1) in vec4 icolor;\n"
        "out vec4 color;\n"
        "void main(){ color = icolor; gl_Position = position; }\n";

    std::string frag_shader =
        "#version 330 core\n"
        "in  vec4 color;\n"
        "out vec4 fColor;\n"
        "void main(){ fColor = color; }\n";

    //  Load the shaders
    GLuint program = LoadShadersFromMemory(vert_shader, frag_shader);

    if (!program)
    {
        std::cerr << "Could not load Shader programs." << std::endl;
        exit(EXIT_FAILURE);
    }

    mode = GL_FILL;
    sscount = 1;
    screenBounds[0] = -1;
    screenBounds[1] = 1;
    screenBounds[2] = -1;
    screenBounds[3] = 1;

    if (SetVS)
        setVerticalSyncEnabled(true);
    else
        setFramerateLimit(0);

    // Make it the active window for OpenGL calls
    setActive();

    // Turn on the shader.
    glUseProgram(program);
}
Exemplo n.º 5
0
CAppWindow::CAppWindow()
    : sf::RenderWindow(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), "Prima Roads - RGR Sample", WINDOW_STYLE)
{
    m_menu = std::make_unique<CAppMenu>("File");
    m_menu->SetFrame(sf::FloatRect(0, 0, float(WINDOW_WIDTH), float(MENU_BAR_HEIGHT)));
    m_openActionId = m_menu->AddAction("Open...", std::bind(&CAppWindow::AskOpenInput, this));
    m_saveActionId = m_menu->AddAction("Save...", std::bind(&CAppWindow::AskSaveOutput, this));

    setFramerateLimit(60);
    setVerticalSyncEnabled(true);
    SetState(State::WaitingInput);

    m_font.loadFromFile("res/Ubuntu-R.ttf");
}
Exemplo n.º 6
0
int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdLine, int cmdShow)
{
	auto window = new sf::RenderWindow(sf::VideoMode(1000u, 1000u), "Sanduhr");
	auto pos = window->getPosition();
	pos.y = 5;
	window->setPosition(pos);
	window->setVerticalSyncEnabled(false);

	World world(window);
	world.Run();

	delete window;

	return 0;
}
Exemplo n.º 7
0
void Window::initialize()
{
    // Setup default behaviours (to get a consistent behaviour across different implementations)
    setVisible(true);
    setVerticalSyncEnabled(false);

    // Reset frame time
    m_clock.restart();

    // Activate the window
    setActive();

    // Notify the derived class
    onCreate();
}
Exemplo n.º 8
0
Window::Window()
{
    mTitle = "";
    setVerticalSyncEnabled(false);
    mVisible = false;
    setKeyRepeatEnabled(true);
    mCursor = MouseCursor::Default;
    mScreenshotPath = "";
    mDebugInfoVisible = false;
    mDebugInfoColor = sf::Color::White;
    mDebugInfoCharsize = 15;
    mBackground.setFillColor(sf::Color::Black);

    mVideoMode = sf::VideoMode(800,600);
    mStyle = sf::Style::Close;
}
Exemplo n.º 9
0
zeq_window_t::zeq_window_t(zeq_t* Z, const char* title, uint32_t width, uint32_t height, int options)
: m_zeq(Z)
{
    sf::ContextSettings settings;
    settings.depthBits          = 24;
    settings.stencilBits        = 8;
    settings.antialiasingLevel  = 0;
    settings.majorVersion       = 3;
    settings.minorVersion       = 0;
    
    int style = 0;
    
    if (!(options & ZEQ_WINDOW_HIDE_TITLEBAR))
    {
        style = sf::Style::Titlebar | sf::Style::Close;
    }
    
    if (options & ZEQ_WINDOW_RESIZABLE)
    {
        style |= sf::Style::Resize;
    }
    
    if (options & ZEQ_WINDOW_FULLSCREEN)
    {
        style |= sf::Style::Fullscreen;
    }
    
    sf::VideoMode videoMode;
    
    if (options & ZEQ_WINDOW_USE_NATIVE_ASPECT_RATIO)
    {
        videoMode = sf::VideoMode::getDesktopMode();
    }
    else
    {
        videoMode.width     = width ? width : 800;
        videoMode.height    = height ? height : 600;
    }
    
    create(videoMode, title ? title : "ZEQ", style, settings);
    
    setKeyRepeatEnabled(false);
    setVerticalSyncEnabled((options & ZEQ_WINDOW_VSYNC) != 0);
    
    zeq_opengl_context_created(Z);
}
Exemplo n.º 10
0
bool Window::load(std::string const& filename)
{
    pugi::xml_document doc;
    if (!doc.load_file(filename.c_str()))
    {
        return false;
    }
    pugi::xml_node window = doc.child("Window");
    if (window)
    {
        setVerticalSyncEnabled(window.child("VerticalSync").attribute("value").as_bool());
        setFullscreen(window.child("Fullscreen").attribute("value").as_bool(),sf::Style::Close);
        std::string v = window.child("Resolution").attribute("value").value();
        mVideoMode.width = static_cast<unsigned int>(std::stoi(v.substr(0,v.find(","))));
        mVideoMode.height = static_cast<unsigned int>(std::stoi(v.substr(v.find(",")+1)));
        return true;
    }
    return false;
}
Exemplo n.º 11
0
void Window::initialize()
{
    // Setup default behaviours (to get a consistent behaviour across different implementations)
    setVisible(true);
    setMouseCursorVisible(true);
    setVerticalSyncEnabled(false);
    setKeyRepeatEnabled(true);

    // Get and cache the initial size of the window
    m_size = m_impl->getSize();

    // Reset frame time
    m_clock.restart();

    // Activate the window
    setActive();

    // Notify the derived class
    onCreate();
}
Exemplo n.º 12
0
GraphicsEngine::GraphicsEngine(string title) :
    sf::RenderWindow(sf::VideoMode(600, 600),
                     title,
                     sf::Style::Default,
                     sf::ContextSettings(24, 8, 4, 3, 3))
{
    setVerticalSyncEnabled(true);
    sscount = 1;

    VAOs = NULL;
    Buffers = NULL;

    // Make it the active window for OpenGL calls
    setActive();

    // Turn on GLEW
    if (glewInit())
    {
        cerr << "Unable to initialize GLEW ... exiting" << endl;
        exit(EXIT_FAILURE);
    }
}
Exemplo n.º 13
0
WindowManager::WindowManager() :
RenderWindow(sf::VideoMode(800, 600, 32), "SFML+Box 2D"),
m_debugDraw()
{
	setVerticalSyncEnabled(true);
}
Exemplo n.º 14
0
void sfRenderWindow_setVerticalSyncEnabled(sfRenderWindow* renderWindow, sfBool enabled)
{
    CSFML_CALL(renderWindow, setVerticalSyncEnabled(enabled == sfTrue));
}