Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Randy

Pages: [1]
1
Graphics / Vsync and Intel HD 3000
« on: November 23, 2011, 03:12:21 pm »
Yeah, I tested this on an older Intel machine and got the same problem, worked fine on a machine with an nVidia card. It's also funny how disabling/enabling Aero has an effect on FPS and tearing, at least on some other programs I found on the Interners. My uneducated guess it's a problem with the OGL implementation.

2
Graphics / Vsync and Intel HD 3000
« on: November 22, 2011, 12:22:40 pm »
Yeah, I added the VSync toggle later. It used to be on by default:
Code: [Select]
sf::RenderWindow window(sf::VideoMode(1200, 600), "SFML OpenGL", sf::Style::Default, sf::ContextSettings(32));
    window.EnableVerticalSync(enable);

Suprisingly forcing VSync on from the gfx settings has no effect either. Either I have no idea what I am doing, Intel drivers are defective or it's the windowed mode. It doesn't work in SDL either...

3
Graphics / Vsync and Intel HD 3000
« on: November 22, 2011, 11:46:23 am »
Code: [Select]
if(clock.GetElapsedTime()-t>=1000)
        {
            cout<<"VSync "<<enable<<" FPS "<<i<<endl;
            t=clock.GetElapsedTime();
            i=0;
        }
        i++;


i is the frame counter and the program writes to console each second. As I understand if VSync is enabled it should wait at window.Display() for the refresh rate sync witch is 60 Hz on my PC but the console shows I get 900 fps.
Link to zip. You can toggle VSync with v.

4
Graphics / Vsync and Intel HD 3000
« on: November 21, 2011, 11:51:18 pm »
Vsync doesn't want to work it seems. I'm in windowed mode with OpenGL using SFML2. Enabling/disabling VSync seems to have no effect on effective FSP. VSync is app controlled from the Intel gfx options. Shouldn't the thread halt at window.Display() if VSync is enabled?. Using x64 Win7.
Code: [Select]

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>
#include <iostream>

using std::cout;
using std::endl;

////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
bool enable=true;
int main()
{
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(1200, 600), "SFML OpenGL", sf::Style::Default, sf::ContextSettings(32));
    window.EnableVerticalSync(enable);
    //window.SetFramerateLimit(55);
    // Create a sprite for the background

    // Enable Z-buffer read and write
    glEnable(GL_DEPTH_TEST);
    glDepthMask(GL_TRUE);
    glClearDepth(1.f);

    // Setup a perspective projection
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(90.f, 1.f, 1.f, 500.f);

    // Bind our texture

    // Create a clock for measuring the time elapsed
    sf::Clock clock;

    // Start game loop
    int t=clock.GetElapsedTime();
    int i=0;
    while (window.IsOpened())
    {
        window.EnableVerticalSync(enable);

        // Process events
        sf::Event event;
        while (window.PollEvent(event))
        {
            // Close window : exit
            if (event.Type == sf::Event::Closed)
                window.Close();

            // Escape key : exit
            if ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Keyboard::Escape))
                window.Close();

            if ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Keyboard::V))
                cout<<(enable^=1)<<endl;

            // Adjust the viewport when the window is resized
            if (event.Type == sf::Event::Resized)
                glViewport(0, 0, event.Size.Width, event.Size.Height);
        }

        // Clear the depth buffer
        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

        // We get the position of the mouse cursor, so that we can move the box accordingly
        float x =  sf::Mouse::GetPosition(window).x * 200.f / window.GetWidth()  - 100.f;
        float y = -sf::Mouse::GetPosition(window).y * 200.f / window.GetHeight() + 100.f;

        // Apply some transformations
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glTranslatef(x, y, -100.f);
        glRotatef(clock.GetElapsedTime() * 0.05f, 1.f, 0.f, 0.f);
        glRotatef(clock.GetElapsedTime() * 0.03f, 0.f, 1.f, 0.f);
        glRotatef(clock.GetElapsedTime() * 0.09f, 0.f, 0.f, 1.f);

        // Draw a cube
        float size = 20.f;
        glBegin(GL_QUADS);

            glTexCoord2f(0, 0); glVertex3f(-size, -size, -size);
            glTexCoord2f(0, 1); glVertex3f(-size,  size, -size);
            glTexCoord2f(1, 1); glVertex3f( size,  size, -size);
            glTexCoord2f(1, 0); glVertex3f( size, -size, -size);

            glTexCoord2f(0, 0); glVertex3f(-size, -size, size);
            glTexCoord2f(0, 1); glVertex3f(-size,  size, size);
            glTexCoord2f(1, 1); glVertex3f( size,  size, size);
            glTexCoord2f(1, 0); glVertex3f( size, -size, size);

            glTexCoord2f(0, 0); glVertex3f(-size, -size, -size);
            glTexCoord2f(0, 1); glVertex3f(-size,  size, -size);
            glTexCoord2f(1, 1); glVertex3f(-size,  size,  size);
            glTexCoord2f(1, 0); glVertex3f(-size, -size,  size);

            glTexCoord2f(0, 0); glVertex3f(size, -size, -size);
            glTexCoord2f(0, 1); glVertex3f(size,  size, -size);
            glTexCoord2f(1, 1); glVertex3f(size,  size,  size);
            glTexCoord2f(1, 0); glVertex3f(size, -size,  size);

            glTexCoord2f(0, 1); glVertex3f(-size, -size,  size);
            glTexCoord2f(0, 0); glVertex3f(-size, -size, -size);
            glTexCoord2f(1, 0); glVertex3f( size, -size, -size);
            glTexCoord2f(1, 1); glVertex3f( size, -size,  size);

            glTexCoord2f(0, 1); glVertex3f(-size, size,  size);
            glTexCoord2f(0, 0); glVertex3f(-size, size, -size);
            glTexCoord2f(1, 0); glVertex3f( size, size, -size);
            glTexCoord2f(1, 1); glVertex3f( size, size,  size);

        glEnd();

        // Draw some text on top of our OpenGL object
//        window.SaveGLStates();
//        sf::Text text("SFML / OpenGL demo");
//        text.SetPosition(250.f, 450.f);
//        text.SetColor(sf::Color(255, 255, 255, 170));
//        window.Draw(text);
//        window.RestoreGLStates();

        // Finally, display the rendered frame on screen
        window.Display();
        //glFinish();
        if(clock.GetElapsedTime()-t>=1000)
        {
            cout<<"VSync "<<enable<<" FPS "<<i<<endl;
            t=clock.GetElapsedTime();
            i=0;
        }
        i++;
    }

    // Don't forget to destroy our texture

    return EXIT_SUCCESS;
}

Pages: [1]