Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8774201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:30:04+00:00 2026-06-13T18:30:04+00:00

I dont understand why my SDL app wont set the DOUBLE_BUF as i’m asking;

  • 0

I dont understand why my SDL app wont set the DOUBLE_BUF as i’m asking;

Here is a short code, this, executed without arguments open a fullscreen window, 1024*768, in 32 BPP mode.

#include <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>

#include "main.h"

SDL_Surface *screen;
Main mainstruct;

void testModesInFormat(SDL_PixelFormat * format)
{

    SDL_Rect **modes;
    int i;

    printf("Available hardware accelerated, fullscreen modes in %d bpp:\n",
           format->BitsPerPixel);

    modes = SDL_ListModes(format, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_DOUBLEBUF);

    // Check is there are any modes available
    if(modes == (SDL_Rect **) 0)
    {
        printf("\tNo modes available!\n");
        return;
    }

    // Check if our resolution is restricted
    if(modes == (SDL_Rect **) - 1)
    {
        printf("\tAll resolutions available.\n");
    }
    else
    {
        // Print valid modes
        for(i = 0; modes[i]; ++i)
            printf("\t%d x %d\n", modes[i]->w, modes[i]->h);
    }

    free(modes);

}

void testModes()
{
    SDL_PixelFormat format;
    format.BitsPerPixel = 16;
    testModesInFormat(&format);
    format.BitsPerPixel = 24;
    testModesInFormat(&format);
    format.BitsPerPixel = 32;
    testModesInFormat(&format);
}

int main(int argc, char *argv[])
{

    printf("Hello world!\n");
    Uint32 flags = SDL_DOUBLEBUF;
    int w, h, bpp;
    int i;
    int hw_mem = 1;
    w = 1024;
    h = 768;
    bpp = 32;

    mainstruct.full_screen = 1;

    if(SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO) < 0)
    {
        fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
        exit(1);
    }
    atexit(SDL_Quit);

    for(i = 0; i < argc; i++)
    {
        if(!strcmp(argv[i], "--window"))
        {
            mainstruct.full_screen = 0;
        }
        else if(!strcmp(argv[i], "--no-hardwarememory") || !strcmp(argv[i], "-nohw"))
        {
            hw_mem = 0;
        }
        else if(!strcmp(argv[i], "--test") || !strcmp(argv[i], "-t"))
        {
            testModes();
            exit(0);
        }
    }

    if(hw_mem)
    {
        flags |= SDL_HWSURFACE;
    }
    else
    {
        flags |= SDL_SWSURFACE;
    }
    if(mainstruct.full_screen)
    {
        flags |= SDL_FULLSCREEN;
    }
    fprintf(stderr, "Attempting to set %dx%dx%d video mode.\n", w, h, bpp);
    fflush(stderr);
    screen = SDL_SetVideoMode(w, h, bpp, flags);
    if(screen == NULL)
    {
        fprintf(stderr, "Unable to set %dx%dx%d video: %s\n", w, h, bpp,
                SDL_GetError());
        exit(1);
    }
    fprintf(stderr, "Success:\n");
    fprintf(stderr, "\tSDL_HWSURFACE =%s\n",
            (screen->flags & SDL_HWSURFACE ? "true" : "false"));
    fprintf(stderr, "\tSDL_FULLSCREEN=%s\n",
            (screen->flags & SDL_FULLSCREEN ? "true" : "false"));
    fprintf(stderr, "\tSDL_DOUBLEBUF =%s\n",
            (screen->flags & SDL_DOUBLEBUF ? "true" : "false"));
    fprintf(stderr, "\tw=%d h=%d bpp=%d pitch=%d\n", screen->w, screen->h,
            screen->format->BitsPerPixel, screen->pitch);
    fflush(stderr);
    return 0;
}

As you see, args are;
–window disable fullscreen
–no-hardwarememory set SDL_SWSURFACE in place of SDL_HWSURFACE
–test call the testModes() function

So here are my output;

Without arguments ( flags are “SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_FULLSCREEN” ) I get this;

Attempting to set 1024x768x32 video mode.
Success:
    SDL_HWSURFACE =false
    SDL_FULLSCREEN=true
    SDL_DOUBLEBUF =false
    w=1024 h=768 bpp=32 pitch=4096

With the –test arg, i get this:

Available hardware accelerated, fullscreen modes in 16 bpp:
    1920 x 1080
    1768 x 992
    1680 x 1050
    [...]
    640 x 480
Available hardware accelerated, fullscreen modes in 24 bpp:
    No modes available!
Available hardware accelerated, fullscreen modes in 32 bpp:
    1920 x 1080
    1768 x 992
    1680 x 1050
    [...]
    640 x 480

For thoses who want to compile this, here is the main.h

#ifndef MAIN_H
#define MAIN_H
#include "SDL.h"
#include "SDL_thread.h"

typedef struct _main {
  int full_screen;
} Main;
extern Main mainstruct;

#endif

So i want to understand why DOUBLE_BUF does not work, in 32bpp fullscreen ..
Some ideas ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:30:06+00:00Added an answer on June 13, 2026 at 6:30 pm

    If you’re using Windows, the problem is probably in:

    SDL 1.2.10 Release Notes
    ...
    Windows Notes 
      The "windib" video driver is the default now, to prevent problems with 
      certain laptops, 64-bit Windows, and Windows Vista. The DirectX driver is 
      still available, and can be selected by setting the environment variable
      SDL_VIDEODRIVER to "directx".
    ...
    

    http://www.libsdl.org/release/changes.html

    After adding SDL_putenv("SDL_VIDEODRIVER=directx"); to your code the programm prints out:

    Attempting to set 1024x768x32 video mode.
    Success:
        SDL_HWSURFACE =true
        SDL_FULLSCREEN=true
        SDL_DOUBLEBUF =true
        w=1024 h=768 bpp=32 pitch=4096
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

according to this code i dont understand about NSClassFromString how did i know viewControllerName
I dont understand why my code does not work. This is my code. I
This code works, but i dont understand why. With DeferredLoadingEnabld = false, I would
I dont understand the function of these characters -> in this code: $var->getImageInfo(); the
i dont understand the problem with returning multiple rows: here is my table BBC:
I dont understand what would be the problem with the following code. It needs
The following (pseudo-) code induces some behaviour which I dont understand. I have 2
I dont understand why this doesn't work. On message WM_LBUTTONDOWN, the coordinates of the
I dont understand why, when i run my code the for each loop under
I dont understand DatePeriod, DateInterval classes very well. This question is linked to another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.