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 8178077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:40:44+00:00 2026-06-06T23:40:44+00:00

I am using SDL 1.2 for a project. It renders things just fine, but

  • 0

I am using SDL 1.2 for a project. It renders things just fine, but I want to do some small pixel shader effects. All of the examples for this show using OpenGl driver for SDL’s video subsystem.

So, I start the video subsystem with opengl as the driver, and tell SDL_SetVideoMode() to use SDL_OPENGL. When I go to run the program, it now starts crashing on the SetVideoMode() call, which worked fine without forcing OpenGl).

I went back and ran the program without forcing OpenGl and dumped out SDL_VideoDriverName() and it says I am using the “directx” driver.

My question is two-pronged: what is wrong that it doesn’t like the opengl driver, and how to I get SDL to use opengl without problems here? Or, how do I get the SDL surface into DirectX to apply pixel shader effects?

I would prefer to use OpenGl as it would be easier to port code to other platforms.

As an example, I have added this code that breaks when I try to use the OpenGl system:

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#include <SDL.h>

INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
{
    SDL_putenv("SDL_VIDEODRIVER=opengl");
    SDL_Init( SDL_INIT_EVERYTHING );
    SDL_VideoInit("opengl",0);

    SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );  // crashes here
    SDL_Surface *mWindow = SDL_SetVideoMode(1024,768,32,SDL_HWSURFACE|SDL_HWPALETTE|SDL_DOUBLEBUF|SDL_OPENGL);

    SDL_Quit();

    return 0; 
}
  • 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-06T23:40:45+00:00Added an answer on June 6, 2026 at 11:40 pm

    SDL without the OpenGL option uses DirectX to obtain direct access to a 3D drawing surface. Using OpenGL triggers a whole different codepath in SDL. And using OpenGL with SDL you no longer can use the SDL surface for direct access to the pixels It’s very likely your program crashes, because you’re still trying to directly access the surface.

    Anyway, if you want to use pixel shaders, you no longer must use direct pixel buffer access, as provided by plain SDL. You have to do everything through OpenGL then.

    Update

    Some of the parameters you give to SDL are mutually exclusive. Also the driver name given to SDL_VideoInit makes no sense if used together with OpenGL (it’s only relevant together with DirectDraw to select a specific output device).

    Also, because you already did call SDL_Init(SDL_INIT_EVERYTHING) the call to SDL_VideoInit is redundant and maybe harmfull actually.

    See this for a fully working OpenGL example:

    http://sdl.beuc.net/sdl.wiki/Using_OpenGL_With_SDL

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using SDL for a project of mine, and I want a shorter way
I'm using LUA for a SDL project. I downloaded the precompiled LIB and DLL
I am using SDL tridion 2011 SP1. I want to get the list of
I am using SDL Tridion 2011 SP1. I need small clarification regarding multimedia schema
I am building a GUI extension using SDL Tridion 2011 SP1. I want to
I am using SDL in my playground project and i am a bit worried
This is for a small game project with SDL on MinGW/Windows. I am working
Using SDL 1.3 I want to create fake fullscreen SDL_Window under linux. It is
I am using SDL for the view parts of my game project. And I
I'm writing a simple program using SDL, but I'm running into a strange problem.

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.