# Failed to enable VSync on Intel(R) HD Graphics 630 (i7-7700)

**URL:** <https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791>\
**Category:** SDL Development\
**Created:** [July 9, 2026, 8:58am UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791 "2026-07-09T08:58:56Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [July 9, 2026, 8:58am UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/1 "2026-07-09T08:58:56Z")

</div>

I cannot enable it on Desktop:

```cpp
    int status = SDL_GL_SetSwapInterval(1);
    if (status != 0)
    {
        SDL_Log("VSync failed: %s", SDL_GetError());
    }

```

Solution is to limit FPS:

```cpp
SDL_AppResult SDL_AppIterate(void *appState)
{
    App *app = (App *)appState;

    // High-precision timing variables
    static Uint64 lastFrameTime = 0;
    const Uint64 targetFrameTimeNS = 16666666; // ~16.6ms for 60 FPS
    
    Uint64 now = SDL_GetTicksNS();
    
    // If we haven't hit the target time, yield the CPU
    if ((now - lastFrameTime) < targetFrameTimeNS)
    {
        // Sleep to yield control back to the Windows scheduler
        // This drops CPU usage from 15% to <1%
        SDL_Delay(1); 
        return SDL_APP_CONTINUE;
    }
    
    // Update our last frame time
    lastFrameTime = now;

    glClear(GL_COLOR_BUFFER_BIT);

```

Before:

 ![image](https://discourse.libsdl.org/uploads/default/original/2X/4/429a68847a003adff71dd42057e1eed74fc68044.png)

After:

 ![image](https://discourse.libsdl.org/uploads/default/original/2X/d/d77f176901f5a78ff17996f7cad3327140d96660.png)

P.S. I use the latest Intel drivers:

 ![image](https://discourse.libsdl.org/uploads/default/original/2X/2/210f4d406b995b089e4e3c7119be0b1babcd2593.png)

---

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [July 9, 2026, 9:04am UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/2 "2026-07-09T09:04:36Z")

</div>

> [@My step by step guides for SDL3 to build for Android and WebAssembly](https://discourse.libsdl.org/t/my-step-by-step-guides-for-sdl3-to-build-for-android-and-webassembly/50766/75):
>
> The thread is about building SDL3 ‘_for Android and WebAssembly_’ so when you say “on desktop” do you mean specifically when running in a browser, or more generally?

I think a browser does not need a VSync but it is failed to enable VSync on the browser too. The browser app spends 1-2% of CPU. I will not limit FPS for the browser because `requestAnimationFrame` works perfect. The browser limits FPS to 60 and plays animations very smoothly. This problem is actual for Dektop.

This is my example in for Desktop and prints `VSync failed` but I solved the problem (with 15% CPU) using the limit of FPS from the first message for the topic. Full code:

main.c

```cpp
#define SDL_MAIN_USE_CALLBACKS 1

#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <glad/glad.h>

typedef struct
{
    SDL_Window *window;
    SDL_GLContext glContext;
    GLuint shaderProgram;
    GLuint vao, vbo;
} App;

const char *vertexShaderSource =
    "#version 330 core\n"
    "layout (location = 0) in vec3 aPosition;\n"
    "void main()\n"
    "{\n"
    " gl_Position = vec4(aPosition, 1.0);\n"
    "}\n";

const char *fragmentShaderSource =
    "#version 330 core\n"
    "precision mediump float;\n"
    "out vec4 fragColor;\n"
    "void main()\n"
    "{\n"
    " fragColor = vec4(0.75, 1, 0.7, 1.0);\n"
    "}\n";

SDL_AppResult SDL_AppInit(void **appState, int argc, char *argv[])
{
    App *app = (App *)SDL_malloc(sizeof(App));
    *appState = app;

    if (!SDL_Init(SDL_INIT_VIDEO))
    {
        SDL_Log("Couldn't initialize SDL: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); // Enable MULTISAMPLE
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 8); // Can be 2, 4, 8 or 16

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
        SDL_GL_CONTEXT_PROFILE_CORE);

    app->window = SDL_CreateWindow("SDL3, OpenGL", 380, 380, SDL_WINDOW_OPENGL);
    if (!app->window)
    {
        SDL_Log("Couldn't create the window: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    app->glContext = SDL_GL_CreateContext(app->window);
    if (!app->glContext)
    {
        SDL_Log("Couldn't create the glConext: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    if (!gladLoadGLLoader((GLADloadproc)SDL_GL_GetProcAddress))
    {
        SDL_Log("Failed to initialize OpenGL function pointers");
        return SDL_APP_FAILURE;
    }

    int status = SDL_GL_SetSwapInterval(1);
    if (status != 0)
    {
        SDL_Log("VSync failed: %s", SDL_GetError());
    }

    glClearColor(0.2f, 0.2f, 0.2f, 1.f);

    GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
    glShaderSource(vertexShader, 1, &vertexShaderSource, NULL);
    glCompileShader(vertexShader);

    GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
    glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL);
    glCompileShader(fragmentShader);

    app->shaderProgram = glCreateProgram();
    glAttachShader(app->shaderProgram, vertexShader);
    glAttachShader(app->shaderProgram, fragmentShader);
    glLinkProgram(app->shaderProgram);
    glDeleteShader(vertexShader);
    glDeleteShader(fragmentShader);

    glUseProgram(app->shaderProgram);

    // clang-format off
    GLfloat vertexPositions[] = {
        -0.5f, -0.5f, 0.f,
        0.5f, -0.5f, 0.f,
        0.f, 0.5f, 0.f
    };
    // clang-format on

    glGenVertexArrays(1, &app->vao);
    glGenBuffers(1, &app->vbo);
    glBindVertexArray(app->vao);
    glBindBuffer(GL_ARRAY_BUFFER, app->vbo);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertexPositions), vertexPositions, GL_STATIC_DRAW);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (void *)0);
    glEnableVertexAttribArray(0);
    glBindVertexArray(0);

    return SDL_APP_CONTINUE;
}

SDL_AppResult SDL_AppEvent(void *appState, SDL_Event *event)
{
    App *app = (App *)appState;

    switch (event->type)
    {
        case SDL_EVENT_QUIT:
            return SDL_APP_SUCCESS;
        default:
            break;
    }

    return SDL_APP_CONTINUE;
}

SDL_AppResult SDL_AppIterate(void *appState)
{
    App *app = (App *)appState;

    // High-precision timing variables
    static Uint64 lastFrameTime = 0;
    const Uint64 targetFrameTimeNS = 16666666; // ~16.6ms for 60 FPS

    Uint64 now = SDL_GetTicksNS();

    // If we haven't hit the target time, yield the CPU
    if ((now - lastFrameTime) < targetFrameTimeNS)
    {
        // Sleep to yield control back to the Windows scheduler
        // This drops CPU usage from 15% to <1%
        SDL_Delay(1);
        return SDL_APP_CONTINUE;
    }

    // Update our last frame time
    lastFrameTime = now;

    glClear(GL_COLOR_BUFFER_BIT);

    glBindVertexArray(app->vao);
    glDrawArrays(GL_TRIANGLES, 0, 3);

    glBindVertexArray(0);
    SDL_GL_SwapWindow(app->window);
    return SDL_APP_CONTINUE;
}

void SDL_AppQuit(void *appState, SDL_AppResult result)
{
    App *app = (App *)appState;
    glDeleteProgram(app->shaderProgram);
    SDL_GL_DestroyContext(app->glContext);
    SDL_DestroyWindow(app->window);
    SDL_Quit();
}

```

---

<div class="post-metadata">

**Author:** ![Daniel1985](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/d/a5b964/32.png) [@Daniel1985](https://discourse.libsdl.org/u/Daniel1985)\
**Post date:** [July 9, 2026, 9:40am UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/3 "2026-07-09T09:40:17Z")

</div>

Since you’re using the main-callbacks functionality in SDL3, you might want to consider setting the callback rate of SDL\_AppIterate, instead of doing manual frame limiting.

Code example:

```cpp
SDL_AppResult SDL_AppInit(void** appState, int argc, char* argv)
{
	if(!SDL_Init(SDL_INIT_VIDEO))
		return SDL_AppResult::SDL_APP_FAILURE;

	SDL_Window* window = nullptr;
	SDL_Renderer*	renderer	= nullptr;
	if(!SDL_CreateWindowAndRenderer("Window", WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_HIDDEN, &window, &renderer))
		return SDL_AppResult::SDL_APP_FAILURE;

	/**
	* "0" = SDL_AppIterate will be called as often as possible
	* "30" = SDL_AppIterate will be called 30 times per seconds (30 FPS)
	* "60" = SDL_AppIterate will be called 60 times per seconds (60 FPS)
	* "120" = SDL_AppIterate will be called 120 times per seconds (120 FPS)
	* Other integer values, in quotes
	* "59.94" = SDL doesn't round values, so 59.94 will be respected and used 
	* "waitevent" = SDL_AppIterate will not be called until new event(s) have arrived (and been processed by SDL_AppEvent)
	*/
	if(!SDL_SetHint(SDL_HINT_MAIN_CALLBACK_RATE, "0"))
		return SDL_AppResult::SDL_APP_FAILURE;

	return SDL_APP_CONTINUE;

}

```

---

<div class="post-metadata">

**Author:** ![Peter87](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/p/f07891/32.png) [@Peter87](https://discourse.libsdl.org/u/Peter87)\
**Post date:** [July 9, 2026, 9:42am UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/4 "2026-07-09T09:42:05Z")

</div>

I don’t know why vsync does not work for you but its purpose is not only to avoid wasting CPU power but also to avoid [tearing](https://en.wikipedia.org/wiki/Screen_tearing).

---

<div class="post-metadata">

**Author:** ![Sward](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sward/32/5719_2.png) [@Sward](https://discourse.libsdl.org/u/Sward)\
**Post date:** [July 9, 2026, 6:02pm UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/5 "2026-07-09T18:02:03Z")

</div>

```auto
int status = SDL_GL_SetSwapInterval(1);

    if (status != 0)
    {
        SDL_Log("VSync failed: %s", SDL_GetError());
    }

```

In C/C++ bool values `false == 0`  
The function reports true on success.  
So I’m seeing `if(status != false)` above, which means you are reporting a failure upon success.  
Edit: this happened to me enough times that I only use the keywords true/false instead of zero and not-zero when possible.

---

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [July 9, 2026, 6:55pm UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/6 "2026-07-09T18:55:50Z")

</div>

> [@Sward](#):
>
> It would be easier to read if you use the keywords instead of zero and not-zero

Thanks! I fixed it:

```cpp
    const int VSYNC_OFF = 0;
    const int VSYNC_ON = 1;
    if (!SDL_GL_SetSwapInterval(VSYNC_ON))
    {
        SDL_Log("VSync failed: %s", SDL_GetError());
    }

```

It no longer reports a ‘VSync failed’ error in the console. My monitor (Dell E2420HS) supports a maximum of 60 FPS, so I assume VSync is effectively capping the framerate. However, my app still consumes about 15% CPU. Is this expected behavior?

 ![image](https://discourse.libsdl.org/uploads/default/original/2X/4/4df076fcf189b3be2eb0d9318dacdfe78b2c7efa.png)

> [@Daniel1985](#):
>
> setting the callback rate of SDL\_AppIterate, instead of doing manual frame limiting

Thanks! It works!

 ![image](https://discourse.libsdl.org/uploads/default/original/2X/e/ea95f7d51890a9d0c517e6228e0e68cf3abb2bc5.png)

It works for a simple triangle from the first post:

 ![image](https://discourse.libsdl.org/uploads/default/original/2X/d/d43af06d75c1bc3f7e1408f3e1f2b9364f4fd2c1.png)

And for this simplified version (a setting of a background only):

main.c

```cpp
#define SDL_MAIN_USE_CALLBACKS 1

#include <glad/glad.h>
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>

typedef struct
{
    SDL_Window *window;
    SDL_GLContext glContext;
} App;

SDL_AppResult SDL_AppInit(void **appState, int argc, char *argv[])
{
    App *app = (App *)SDL_malloc(sizeof(App));
    *appState = app;

    if(!SDL_SetHint(SDL_HINT_MAIN_CALLBACK_RATE, "60"))
    {
        SDL_Log("Failed to set a frame rate: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    if (!SDL_Init(SDL_INIT_VIDEO))
    {
        SDL_Log("Couldn't initialize SDL: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); // Enable MULTISAMPLE
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 8); // Can be 2, 4, 8 or 16

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);

    app->window = SDL_CreateWindow("SDL3, OpenGL", 380, 380, SDL_WINDOW_OPENGL);
    if (!app->window)
    {
        SDL_Log("Couldn't create the window: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    app->glContext = SDL_GL_CreateContext(app->window);
    if (!app->glContext)
    {
        SDL_Log("Couldn't create the glConext: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    if (!gladLoadGLLoader((GLADloadproc)SDL_GL_GetProcAddress))
    {
        SDL_Log("Failed to initialize OpenGL function pointers");
        return SDL_APP_FAILURE;
    }

    glClearColor(0.2f, 0.2f, 0.2f, 1.f);

    return SDL_APP_CONTINUE;
}

SDL_AppResult SDL_AppEvent(void *appState, SDL_Event *event)
{
    switch (event->type)
    {
        case SDL_EVENT_QUIT:
            return SDL_APP_SUCCESS;
        default:
            break;
    }

    return SDL_APP_CONTINUE;
}

SDL_AppResult SDL_AppIterate(void *appState)
{
    App *app = (App *)appState;

    glClear(GL_COLOR_BUFFER_BIT);

    SDL_GL_SwapWindow(app->window);
    return SDL_APP_CONTINUE;
}

void SDL_AppQuit(void *appState, SDL_AppResult result)
{
    App *app = (App *)appState;
    SDL_GL_DestroyContext(app->glContext);
    SDL_DestroyWindow(app->window);
    SDL_Quit();
}

```

---

<div class="post-metadata">

**Author:** ![Peter87](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/p/f07891/32.png) [@Peter87](https://discourse.libsdl.org/u/Peter87)\
**Post date:** [July 9, 2026, 7:51pm UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/7 "2026-07-09T19:51:53Z")

</div>

> [@Sward](#):
>
> ```auto
> int status = SDL_GL_SetSwapInterval(1);
> if (status != 0)
> {
> SDL_Log("VSync failed: %s", SDL_GetError());
> }
> 
> ```
> 
> In C/C++ bool values, isn’t `false == 0`? The function reports true on success. So I’m seeing `if(status != false)` above, which means you are reporting a failure upon success.

`SDL_GL_SetSwapInterval` used to returned an `int` (0 on success, -1 on failure) in SDL2 so that piece of code is correct for SDL2 but not for SDL3.

* * *

> [@8Observer8](#):
>
> However, my app still consumes about 15% CPU. Is this expected behavior?

Does your CPU have six cores by any chance?

100% / 6 ≈ 16.7 %

---

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [July 9, 2026, 7:57pm UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/8 "2026-07-09T19:57:52Z")

</div>

> [@Peter87](#):
>
> Does your CPU have six cores by any chance?

4 cores, 8 virtual threads:

 ![image](https://discourse.libsdl.org/uploads/default/original/2X/9/989299716a03286187b6db80193ce7fab75edd81.png)

---

<div class="post-metadata">

**Author:** ![Peter87](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/p/f07891/32.png) [@Peter87](https://discourse.libsdl.org/u/Peter87)\
**Post date:** [July 9, 2026, 8:08pm UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/9 "2026-07-09T20:08:54Z")

</div>

I’m not sure but I suspect vsync is not working for you. I suggest you count and print the number of times `SDL_AppIterate` is called each second to find out.

---

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [July 9, 2026, 8:13pm UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/10 "2026-07-09T20:13:26Z")

</div>

This is exactly a minimum program that I ran where I enagle VSync and `SDL_GL_SetSwapInterval` returns `true`:

main.c

```cpp
#define SDL_MAIN_USE_CALLBACKS 1

#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <glad/glad.h>

typedef struct
{
    SDL_Window *window;
    SDL_GLContext glContext;
} App;

SDL_AppResult SDL_AppInit(void **appState, int argc, char *argv[])
{
    SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
    SDL_SetHint(SDL_HINT_RENDER_VSYNC, "1");

    App *app = (App *)SDL_malloc(sizeof(App));
    *appState = app;

    if (!SDL_Init(SDL_INIT_VIDEO))
    {
        SDL_Log("Couldn't initialize SDL: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); // Enable MULTISAMPLE
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 8); // Can be 2, 4, 8 or 16

    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);

    app->window = SDL_CreateWindow("SDL3, OpenGL", 380, 380, SDL_WINDOW_OPENGL);
    if (!app->window)
    {
        SDL_Log("Couldn't create the window: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    app->glContext = SDL_GL_CreateContext(app->window);
    if (!app->glContext)
    {
        SDL_Log("Couldn't create the glConext: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    if (!SDL_GL_MakeCurrent(app->window, app->glContext))
    {
        SDL_Log("Couldn't make context current: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    if (!gladLoadGLLoader((GLADloadproc)SDL_GL_GetProcAddress))
    {
        SDL_Log("Failed to initialize OpenGL function pointers");
        return SDL_APP_FAILURE;
    }

    const unsigned char *renderer = glGetString(GL_RENDERER);
    const unsigned char *vendor = glGetString(GL_VENDOR);
    SDL_Log("Vendor: %s", vendor);
    SDL_Log("Renderer: %s", renderer);

    SDL_Log("SDL Compiled Version: %d.%d.%d",
        SDL_MAJOR_VERSION,
        SDL_MINOR_VERSION,
        SDL_MICRO_VERSION);

    int linked_version = SDL_GetVersion();
    SDL_Log("SDL Linked Version (raw): %d", linked_version);

    SDL_Log("SDL Linked Version: %d.%d.%d",
        SDL_VERSIONNUM_MAJOR(linked_version),
        SDL_VERSIONNUM_MINOR(linked_version),
        SDL_VERSIONNUM_MICRO(linked_version));

    glClearColor(0.2f, 0.2f, 0.2f, 1.f);

    SDL_ShowWindow(app->window);

    const int VSYNC_OFF = 0;
    const int VSYNC_ON = 1;
    if (!SDL_GL_SetSwapInterval(VSYNC_ON))
    {
        SDL_Log("VSync failed: %s", SDL_GetError());
    }

    return SDL_APP_CONTINUE;
}

SDL_AppResult SDL_AppEvent(void *appState, SDL_Event *event)
{
    App *app = (App *)appState;

    switch (event->type)
    {
        case SDL_EVENT_QUIT:
            return SDL_APP_SUCCESS;
        default:
            break;
    }

    return SDL_APP_CONTINUE;
}

SDL_AppResult SDL_AppIterate(void *appState)
{
    App *app = (App *)appState;

    glClear(GL_COLOR_BUFFER_BIT);

    SDL_GL_SwapWindow(app->window);
    return SDL_APP_CONTINUE;
}

void SDL_AppQuit(void *appState, SDL_AppResult result)
{
    App *app = (App *)appState;
    SDL_GL_DestroyContext(app->glContext);
    SDL_DestroyWindow(app->window);
    SDL_Quit();
}

```

Project files: [vsync-failed-min-app-opengl-sdl3-mingw-c.zip](https://discourse.libsdl.org/uploads/short-url/mugV12bczwoKc9FXuqYGFgxkSmu.zip) (3.0 KB)

 ![image](https://discourse.libsdl.org/uploads/default/original/2X/c/c55398382f7a9dbefda0972400af573a805f9b58.png)

---

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [July 9, 2026, 8:18pm UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/11 "2026-07-09T20:18:36Z")

</div>

> [@Peter87](#):
>
> I suggest you count and print the number of times `SDL_AppIterate` is called each second to find out.

Thank you! I will do it.

---

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [July 9, 2026, 8:23pm UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/12 "2026-07-09T20:23:51Z")

</div>

Test with FPS and VSync:

 ![image](https://discourse.libsdl.org/uploads/default/original/2X/1/18823041edf2e0c25207b8892d3016548b100d2c.png)

main.c

```cpp
#define SDL_MAIN_USE_CALLBACKS 1

#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <glad/glad.h>

typedef struct
{
    SDL_Window *window;
    SDL_GLContext glContext;
    Uint64 frameCount;
    Uint64 lastLogTime;
} App;

SDL_AppResult SDL_AppInit(void **appState, int argc, char *argv[])
{
    SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
    SDL_SetHint(SDL_HINT_RENDER_VSYNC, "1");

    App *app = (App *)SDL_malloc(sizeof(App));
    *appState = app;

    app->frameCount = 0;
    app->lastLogTime = SDL_GetTicks();

    if (!SDL_Init(SDL_INIT_VIDEO))
    {
        SDL_Log("Couldn't initialize SDL: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); // Enable MULTISAMPLE
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 8); // Can be 2, 4, 8 or 16

    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);

    app->window = SDL_CreateWindow("SDL3, OpenGL", 380, 380, SDL_WINDOW_OPENGL);
    if (!app->window)
    {
        SDL_Log("Couldn't create the window: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    app->glContext = SDL_GL_CreateContext(app->window);
    if (!app->glContext)
    {
        SDL_Log("Couldn't create the glConext: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    if (!SDL_GL_MakeCurrent(app->window, app->glContext))
    {
        SDL_Log("Couldn't make context current: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    if (!gladLoadGLLoader((GLADloadproc)SDL_GL_GetProcAddress))
    {
        SDL_Log("Failed to initialize OpenGL function pointers");
        return SDL_APP_FAILURE;
    }

    const unsigned char *renderer = glGetString(GL_RENDERER);
    const unsigned char *vendor = glGetString(GL_VENDOR);
    SDL_Log("Vendor: %s", vendor);
    SDL_Log("Renderer: %s", renderer);

    SDL_Log("SDL Compiled Version: %d.%d.%d",
        SDL_MAJOR_VERSION,
        SDL_MINOR_VERSION,
        SDL_MICRO_VERSION);

    int linked_version = SDL_GetVersion();
    SDL_Log("SDL Linked Version (raw): %d", linked_version);

    SDL_Log("SDL Linked Version: %d.%d.%d",
        SDL_VERSIONNUM_MAJOR(linked_version),
        SDL_VERSIONNUM_MINOR(linked_version),
        SDL_VERSIONNUM_MICRO(linked_version));

    glClearColor(0.2f, 0.2f, 0.2f, 1.f);

    SDL_ShowWindow(app->window);

    const int VSYNC_OFF = 0;
    const int VSYNC_ON = 1;
    if (!SDL_GL_SetSwapInterval(VSYNC_ON))
    {
        SDL_Log("VSync failed: %s", SDL_GetError());
    }

    return SDL_APP_CONTINUE;
}

SDL_AppResult SDL_AppEvent(void *appState, SDL_Event *event)
{
    App *app = (App *)appState;

    switch (event->type)
    {
        case SDL_EVENT_QUIT:
            return SDL_APP_SUCCESS;
        default:
            break;
    }

    return SDL_APP_CONTINUE;
}

SDL_AppResult SDL_AppIterate(void *appState)
{
    App *app = (App *)appState;

    app->frameCount++;
    Uint64 now = SDL_GetTicks();
    if (now - app->lastLogTime >= 1000)
    {
        SDL_Log("Frames per second: %llu", app->frameCount);
        app->frameCount = 0;
        app->lastLogTime = now;
    }

    glClear(GL_COLOR_BUFFER_BIT);

    SDL_GL_SwapWindow(app->window);
    return SDL_APP_CONTINUE;
}

void SDL_AppQuit(void *appState, SDL_AppResult result)
{
    App *app = (App *)appState;
    SDL_GL_DestroyContext(app->glContext);
    SDL_DestroyWindow(app->window);
    SDL_Quit();
}

```

I try to enable VSync in two places. Here:

```cpp
    SDL_SetHint(SDL_HINT_RENDER_VSYNC, "1");

```

and here:

```cpp
    const int VSYNC_OFF = 0;
    const int VSYNC_ON = 1;
    if (!SDL_GL_SetSwapInterval(VSYNC_ON))
    {
        SDL_Log("VSync failed: %s", SDL_GetError());
    }

```

---

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [July 9, 2026, 8:29pm UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/13 "2026-07-09T20:29:33Z")

</div>

So, it looks like VSync was enabled because `SDL_GL_SetSwapInterval` returns `true` and I see 60 FPS. Without VSync I see this:

 ![image](https://discourse.libsdl.org/uploads/default/original/2X/4/4040dd6f2517018ec3d891fbb7ff6b895cf5818c.png)

main.c

```cpp
#define SDL_MAIN_USE_CALLBACKS 1

#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <glad/glad.h>

typedef struct
{
    SDL_Window *window;
    SDL_GLContext glContext;
    Uint64 frameCount;
    Uint64 lastLogTime;
} App;

SDL_AppResult SDL_AppInit(void **appState, int argc, char *argv[])
{
    SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
    // SDL_SetHint(SDL_HINT_RENDER_VSYNC, "1");

    App *app = (App *)SDL_malloc(sizeof(App));
    *appState = app;

    app->frameCount = 0;
    app->lastLogTime = SDL_GetTicks();

    if (!SDL_Init(SDL_INIT_VIDEO))
    {
        SDL_Log("Couldn't initialize SDL: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); // Enable MULTISAMPLE
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 8); // Can be 2, 4, 8 or 16

    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);

    app->window = SDL_CreateWindow("SDL3, OpenGL", 380, 380, SDL_WINDOW_OPENGL);
    if (!app->window)
    {
        SDL_Log("Couldn't create the window: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    app->glContext = SDL_GL_CreateContext(app->window);
    if (!app->glContext)
    {
        SDL_Log("Couldn't create the glConext: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    if (!SDL_GL_MakeCurrent(app->window, app->glContext))
    {
        SDL_Log("Couldn't make context current: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    if (!gladLoadGLLoader((GLADloadproc)SDL_GL_GetProcAddress))
    {
        SDL_Log("Failed to initialize OpenGL function pointers");
        return SDL_APP_FAILURE;
    }

    const unsigned char *renderer = glGetString(GL_RENDERER);
    const unsigned char *vendor = glGetString(GL_VENDOR);
    SDL_Log("Vendor: %s", vendor);
    SDL_Log("Renderer: %s", renderer);

    SDL_Log("SDL Compiled Version: %d.%d.%d",
        SDL_MAJOR_VERSION,
        SDL_MINOR_VERSION,
        SDL_MICRO_VERSION);

    int linked_version = SDL_GetVersion();
    SDL_Log("SDL Linked Version (raw): %d", linked_version);

    SDL_Log("SDL Linked Version: %d.%d.%d",
        SDL_VERSIONNUM_MAJOR(linked_version),
        SDL_VERSIONNUM_MINOR(linked_version),
        SDL_VERSIONNUM_MICRO(linked_version));

    glClearColor(0.2f, 0.2f, 0.2f, 1.f);

    SDL_ShowWindow(app->window);

    // const int VSYNC_OFF = 0;
    // const int VSYNC_ON = 1;
    // if (!SDL_GL_SetSwapInterval(VSYNC_ON))
    // {
    // SDL_Log("VSync failed: %s", SDL_GetError());
    // }

    return SDL_APP_CONTINUE;
}

SDL_AppResult SDL_AppEvent(void *appState, SDL_Event *event)
{
    App *app = (App *)appState;

    switch (event->type)
    {
        case SDL_EVENT_QUIT:
            return SDL_APP_SUCCESS;
        default:
            break;
    }

    return SDL_APP_CONTINUE;
}

SDL_AppResult SDL_AppIterate(void *appState)
{
    App *app = (App *)appState;

    app->frameCount++;
    Uint64 now = SDL_GetTicks();
    if (now - app->lastLogTime >= 1000)
    {
        SDL_Log("Frames per second: %llu", app->frameCount);
        app->frameCount = 0;
        app->lastLogTime = now;
    }

    glClear(GL_COLOR_BUFFER_BIT);

    SDL_GL_SwapWindow(app->window);
    return SDL_APP_CONTINUE;
}

void SDL_AppQuit(void *appState, SDL_AppResult result)
{
    App *app = (App *)appState;
    SDL_GL_DestroyContext(app->glContext);
    SDL_DestroyWindow(app->window);
    SDL_Quit();
}

```

---

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [July 9, 2026, 8:32pm UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/14 "2026-07-09T20:32:08Z")

</div>

VSync caps the FPS at 60 and limits GPU usage, but it does not limit CPU usage. Should it?

---

<div class="post-metadata">

**Author:** ![Peter87](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/p/f07891/32.png) [@Peter87](https://discourse.libsdl.org/u/Peter87)\
**Post date:** [July 9, 2026, 10:02pm UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/15 "2026-07-09T22:02:39Z")

</div>

Yes, I would have expected vsync to lower the CPU usage. Not sure why it doesn’t. Maybe the driver implements it as “busy wait”, I really have no idea…

---

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [July 14, 2026, 12:19am UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/16 "2026-07-14T00:19:30Z")

</div>

VSync works on my computer for `SDL_Renderer`:

 ![image](https://discourse.libsdl.org/uploads/default/original/2X/6/60463226c03dbf097429acfe2eff08ce09667996.png)

main.c

```cpp
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>

int main(int argc, char *argv[])
{
    if (!SDL_Init(SDL_INIT_VIDEO))
    {
        return -1;
    }

    SDL_Window *window = SDL_CreateWindow("SDL3, C", 380, 380, 0);
    SDL_Renderer *renderer = SDL_CreateRenderer(window, NULL);

    // Enable VSync (1 = sync with every refresh)
    if (!SDL_SetRenderVSync(renderer, 1))
    {
        SDL_Log("Failed to enable VSync: %s", SDL_GetError());
    }

    bool running = true;
    SDL_Event event;

    while (running)
    {
        while (SDL_PollEvent(&event))
        {
            if (event.type == SDL_EVENT_QUIT)
            {
                running = false;
            }
        }

        SDL_SetRenderDrawColor(renderer, 20, 20, 20, 255);
        SDL_RenderClear(renderer);

        // Rectangle 1 (Red)
        SDL_FRect rect1 = { 50.0f, 150.0f, 100.0f, 50.0f };
        SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
        SDL_RenderFillRect(renderer, &rect1);

        // Rectangle 2 (Green)
        SDL_FRect rect2 = { 200.0f, 150.0f, 100.0f, 50.0f };
        SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
        SDL_RenderFillRect(renderer, &rect2);

        // Rectangle 3 (Blue)
        SDL_FRect rect3 = { 125.0f, 50.0f, 100.0f, 50.0f };
        SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255);
        SDL_RenderFillRect(renderer, &rect3);

        SDL_RenderPresent(renderer);
    }

    SDL_DestroyRenderer(renderer);
    SDL_DestroyWindow(window);
    SDL_Quit();
    return 0;
}

```

---

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [July 14, 2026, 12:30am UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/17 "2026-07-14T00:30:39Z")

</div>

VSync works for SDL3-callbacks too for `SDL_Renderer`:

 ![image](https://discourse.libsdl.org/uploads/default/original/2X/a/a933fbde7ed0c48d651c79d1c1414cec467015ad.png)

main.c

```cpp
#define SDL_MAIN_USE_CALLBACKS 1 // Use callback functions instead of main()

#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>

// We will use this renderer to draw into this window every frame
static SDL_Window *window = NULL;
static SDL_Renderer *renderer = NULL;

// This function runs once at startup
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
{
    if (!SDL_Init(SDL_INIT_VIDEO))
    {
        SDL_Log("Couldn't initialize SDL: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    if (!SDL_CreateWindowAndRenderer("SDL3 Rectangles", 380, 380, 0, &window, &renderer))
    {
        SDL_Log("Couldn't create window/renderer: %s", SDL_GetError());
        return SDL_APP_FAILURE;
    }

    // Enable VSync (1 = sync with every refresh)
    if (!SDL_SetRenderVSync(renderer, 1))
    {
        SDL_Log("Failed to enable VSync: %s", SDL_GetError());
    }

    return SDL_APP_CONTINUE; // Continue program execution!
}

// This function runs whenever a new event occurs (mouse input, key presses, etc.)
SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
{
    if (event->type == SDL_EVENT_QUIT)
    {
        return SDL_APP_SUCCESS; // Terminate the program, reporting success to the OS
    }
    return SDL_APP_CONTINUE; // Continue program execution!
}

// This function runs once per frame and is the heart of the program
SDL_AppResult SDL_AppIterate(void *appstate)
{
    SDL_SetRenderDrawColor(renderer, 38, 43, 51, 255);

    // Clear the window with the draw color
    SDL_RenderClear(renderer);

    // Rectangle 1 (Red)
    SDL_FRect rect1 = { 50.0f, 150.0f, 100.0f, 50.0f };
    SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
    SDL_RenderFillRect(renderer, &rect1);

    // Rectangle 2 (Green)
    SDL_FRect rect2 = { 200.0f, 150.0f, 100.0f, 50.0f };
    SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
    SDL_RenderFillRect(renderer, &rect2);

    // Rectangle 3 (Blue)
    SDL_FRect rect3 = { 125.0f, 50.0f, 100.0f, 50.0f };
    SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255);
    SDL_RenderFillRect(renderer, &rect3);

    // Present the freshly cleared result to the screen
    SDL_RenderPresent(renderer);

    return SDL_APP_CONTINUE; // Continue program execution!
}

// This function runs once upon shutdown
void SDL_AppQuit(void *appstate, SDL_AppResult result)
{
    // SDL will clean up the window and renderer for us
}

```

CMakeLists.txt

```cmake
set(CMAKE_BUILD_TYPE "Debug")
cmake_minimum_required(VERSION 3.21)
project(rectangles-callbacks-sdl3-mingw-c)

set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)

set(SDL3_DIR "C:/libs/SDL3-devel-3.4.12-mingw/lib/cmake/SDL3")
find_package(SDL3 REQUIRED)

add_executable(app)

target_sources(app
PRIVATE
    src/main.c
)

target_link_libraries(app PRIVATE SDL3::SDL3)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    target_link_options(app PRIVATE -mconsole)
else()
    target_link_options(app PRIVATE -mwindows)
endif()

```

---

<div class="post-metadata">

**Author:** ![Sward](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sward/32/5719_2.png) [@Sward](https://discourse.libsdl.org/u/Sward)\
**Post date:** [July 14, 2026, 1:16am UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/18 "2026-07-14T01:16:09Z")

</div>

I don’t know much about openGL, but I found this:  
Try calling [glFinish](https://wikis.khronos.org/opengl/Swap_Interval) after window swap. That seems to sync the CPU with the GPU refresh rate.

- The function pauses until all previous GL functions have finished their action, and since you set the swap interval, it pauses the CPU for a full vsync.

The bottom of that link says glFinish is not recommended for games with high-action and high-throughput needs, but good for smaller apps.

It looks like [glFinish (Kronos doc)](https://registry.khronos.org/OpenGL-Refpages/gl4/html/glFinish.xhtml) is basically available for all modern versions of OpenGL.

You likely know this, but I should say that VSync should not directly control your game’s physics. If your character moves 4 pixels per frame, then proper gameplay is directly locked to your FPS. Many gaming monitors now run anywhere from 144 to 1000 FPS (and beyond). If you code expecting 60FPS, then those high FPS devices might run your game from 2 to 16 times faster than expected.  
I still use VSync wrong in test code for simplicity’s sake, but for production code I think delta-time is the preferred method: [Hints to Fixing Game Timing](https://andreleite.com/posts/2025/game-loop/fixed-timestep-game-loop/).

---

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [July 24, 2026, 4:31pm UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/20 "2026-07-24T16:31:00Z")

</div>

VSync works well with `SDL Renderer` but it does not work for `OpenGL`:

 ![image](https://discourse.libsdl.org/uploads/default/original/2X/f/f5893e6bcbf3f674a4704d8458c890a9b3a19ba1.png)

Compare my examples:

Renderer: [vsync-sdl3-renderer-main-c.zip](https://discourse.libsdl.org/uploads/short-url/9EhUSfdZZKNiM0SUCwTJSuoR8l3.zip) (2.2 KB)

```cpp
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>

int main(int argc, char *argv[]) {
    SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
    SDL_Init(SDL_INIT_VIDEO);

    SDL_Window *window = SDL_CreateWindow("SDL3 Renderer", 380, 380, 0);
    SDL_Renderer *renderer = SDL_CreateRenderer(window, NULL);

    // Enable VSync (1 = sync with every refresh)
    if (!SDL_SetRenderVSync(renderer, 1))
        SDL_Log("Failed to enable VSync: %s", SDL_GetError());

    bool running = true;
    SDL_Event event;

    while (running) {
        while (SDL_PollEvent(&event)) {
            if (event.type == SDL_EVENT_QUIT)
                running = false;
        }

        SDL_SetRenderDrawColor(renderer, 20, 20, 20, 255);
        SDL_RenderClear(renderer);

        SDL_FRect rect1 = { 50.0f, 150.0f, 100.0f, 50.0f };
        SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
        SDL_RenderFillRect(renderer, &rect1);

        SDL_RenderPresent(renderer);
    }

    SDL_DestroyRenderer(renderer);
    SDL_DestroyWindow(window);
    SDL_Quit();
    return 0;
}

```

OpenGL 3.3: [vsync-sdl3-opengl-main-c.zip](https://discourse.libsdl.org/uploads/short-url/oQlfiz8Yv3AASNJICQsckLF3G9W.zip) (2.3 KB)

```cpp
#include <glad/glad.h>
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>

int main(int argc, char *argv[]) {
    SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
    SDL_Init(SDL_INIT_VIDEO);

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);

    SDL_Window *window = SDL_CreateWindow("SDL3 OpenGL", 380, 380, SDL_WINDOW_OPENGL);
    SDL_GLContext glContext = SDL_GL_CreateContext(window);
    gladLoadGLLoader((GLADloadproc)SDL_GL_GetProcAddress);

    // Enable VSync (1 = sync with every refresh)
    if (!SDL_GL_SetSwapInterval(1))
    {
        SDL_Log("Failed to enable VSync: %s", SDL_GetError());
    }

    glClearColor(0.2f, 0.2f, 0.2f, 1.f);

    bool running = true;
    SDL_Event event;

    while (running) {
        while (SDL_PollEvent(&event)) {
            if (event.type == SDL_EVENT_QUIT)
                running = false;
        }

        glClear(GL_COLOR_BUFFER_BIT);

        SDL_GL_SwapWindow(window);

        glFinish();
    }

    SDL_GL_DestroyContext(glContext);
    SDL_DestroyWindow(window);
    SDL_Quit();
    return 0;
}

```

CMakeLists.txt

```cmake
set(CMAKE_BUILD_TYPE "Debug")
cmake_minimum_required(VERSION 3.21)
project(vsync-sdl3-opengl-main-c)

set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)

set(SDL3_DIR "C:/libs/SDL3-devel-3.4.12-mingw/lib/cmake/SDL3")
find_package(SDL3 REQUIRED)

add_executable(app)

target_include_directories(app PRIVATE C:/libs/glad-0.1.36/opengl-3.3/include)

target_sources(app
PRIVATE
    C:/libs/glad-0.1.36/opengl-3.3/src/glad.c
    src/main.c
)

target_link_libraries(app PRIVATE SDL3::SDL3)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    target_link_options(app PRIVATE -mconsole)
else()
    target_link_options(app PRIVATE -mwindows)
endif()

```

As you can see I’ve tried to add `glFinish` in the OpenGL example above but it does not help:

```cpp
    while (running) {
        while (SDL_PollEvent(&event)) {
            if (event.type == SDL_EVENT_QUIT)
                running = false;
        }

        glClear(GL_COLOR_BUFFER_BIT);

        SDL_GL_SwapWindow(window);

        glFinish();
    }

```

I’ve added this line of code: `SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");` to the `SDL Renderer` example because I thought that maybe it is a problem with `OpenGL` driver and `SDL Renderer` uses `DirectX` on Windows.

---

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [July 24, 2026, 4:50pm UTC](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791/21 "2026-07-24T16:50:26Z")

</div>

It looks like VSync works for OpenGL too because it limits frame counter:

 ![image](https://discourse.libsdl.org/uploads/default/original/2X/0/03baf71928dad51274119ed8e223212ef4d8b5e7.png)

But it does not limit a CPU % usage:

 ![image](https://discourse.libsdl.org/uploads/default/original/2X/9/9f1eff36702b75db2c3e09cd397d0a49f2b53efb.png)

```cpp
#include <glad/glad.h>
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>

int main(int argc, char *argv[]) {
    SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
    SDL_Init(SDL_INIT_VIDEO);

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);

    SDL_Window *window = SDL_CreateWindow("SDL3 OpenGL", 380, 380, SDL_WINDOW_OPENGL);
    SDL_GLContext glContext = SDL_GL_CreateContext(window);
    SDL_GL_MakeCurrent(window, glContext);
    gladLoadGLLoader((GLADloadproc)SDL_GL_GetProcAddress);

    // Enable VSync (1 = sync with every refresh)
    if (!SDL_GL_SetSwapInterval(1))
    {
        SDL_Log("Failed to enable VSync: %s", SDL_GetError());
    }

    glClearColor(0.2f, 0.2f, 0.2f, 1.f);

    const unsigned char *renderer = glGetString(GL_RENDERER);
    const unsigned char *vendor = glGetString(GL_VENDOR);
    SDL_Log("Vendor: %s", vendor);
    SDL_Log("Renderer: %s", renderer);

    SDL_Log("SDL Compiled Version: %d.%d.%d",
        SDL_MAJOR_VERSION,
        SDL_MINOR_VERSION,
        SDL_MICRO_VERSION);

    int linked_version = SDL_GetVersion();
    SDL_Log("SDL Linked Version (raw): %d", linked_version);

    SDL_Log("SDL Linked Version: %d.%d.%d",
        SDL_VERSIONNUM_MAJOR(linked_version),
        SDL_VERSIONNUM_MINOR(linked_version),
        SDL_VERSIONNUM_MICRO(linked_version));

    Uint64 frameCount;
    Uint64 lastLogTime;

    bool running = true;
    SDL_Event event;

    while (running) {
        while (SDL_PollEvent(&event)) {
            if (event.type == SDL_EVENT_QUIT)
                running = false;
        }

        frameCount++;
        Uint64 now = SDL_GetTicks();
        if (now - lastLogTime >= 1000)
        {
            SDL_Log("Frames per second: %llu", frameCount);
            frameCount = 0;
            lastLogTime = now;
        }

        glClear(GL_COLOR_BUFFER_BIT);

        SDL_GL_SwapWindow(window);

        glFinish();
    }

    SDL_GL_DestroyContext(glContext);
    SDL_DestroyWindow(window);
    SDL_Quit();
    return 0;
}

```

CMakeLists.txt

```cmake
set(CMAKE_BUILD_TYPE "Debug")
cmake_minimum_required(VERSION 3.21)
project(vsync-sdl3-opengl-main-c)

set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)

set(SDL3_DIR "C:/libs/SDL3-devel-3.4.12-mingw/lib/cmake/SDL3")
find_package(SDL3 REQUIRED)

add_executable(app)

target_include_directories(app PRIVATE C:/libs/glad-0.1.36/opengl-3.3/include)

target_sources(app
PRIVATE
    C:/libs/glad-0.1.36/opengl-3.3/src/glad.c
    src/main.c
)

target_link_libraries(app PRIVATE SDL3::SDL3)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    target_link_options(app PRIVATE -mconsole)
else()
    target_link_options(app PRIVATE -mwindows)
endif()

```

[Next page](https://discourse.libsdl.org/t/failed-to-enable-vsync-on-intel-r-hd-graphics-630-i7-7700/68791.md?page=2)
