New install MinGW & GLES errors

I am hoping there is a smart cookie on this forum that is using MinGW with SDL2. I am new to SDL and have just finished a new install of MinGW and SDL2 using the 64bit SDL2-2.0.8-x86_64-w64-mingw32 files. I have download many tutorials and attempted to compile the SDL2 test files. They all act the same.

The simplest “hello world” and minimum graphics programs work but any program with more advanced commands such as “IMG_LoadTexture” or GLES required includes such as “glest” or “GLES2/” fail.

My goal is to be able to write the same code in Linux and Win 7…

  1. Would I be better off to use something besides MinGW in win 7?
  2. Since the SDL2 test programs seem to require openGL, why do I need MinGW in the first place. Why not just program in openGL?
  3. Can I accomplish everything that SDL2 can do without using openGL?
  4. If I must use GLES, where and how do I download it for MinGW?

Thanks for the suggestions.

  • IMG_LoadTexture is part of SDL_image that is a separate library
  • I have no idea what you mean by “glest”. The “GLES2” includes are for OpenGL ES. It is a version of OpenGL originally meant for devices like phones and tablets. It’s not normally supported by desktop computers directly. If you are not developing for iOS or Android you don’t probably need that
  • MinGW is a package containing a compiler (GCC) and a collection of libraries and tools. You can use Visual Studio to compile your SDL programs instead of minGW if you want to. You can use SDL and/or OpenGL with both. For crossplatform development I like MinGW myself, but for especially windows only games Visual Studio seems to be the de facto standard.
  • SDL2 tests are trying to test all kinds of SDL functionality. If you only use the SDL drawing API you don’t need to worry about OpenGL. The idea is that internally depending on the platform SDL might use OpenGL, Open GL ES, directX or whatever to do the drawing and you don’t need to care. However the problem is that the SDL API is quite bare bones and 2d only. a lot of people use SDL just to create a window (and handle input etc.) and do all the drawing themselves using a lot more powerful but a bit less portable 3d graphics API OpenGL (that can do 2d too obviously).
  • If you only need to draw stuff like 2d sprites and you don’t need shaders you will not need OpenGL

Thank you for your reply, your answers cleared up a lot of my confusion.

I have resolved my problems getting programs to compile to your comment that IMG_LoadTexture is part of SDL_image.h. I am using a fresh install of SDL2 and there isn’t an 'SDL2/SDL_image.h’ file.

Because of this I am also receiving errors for SDL_SetVideoMode, SDL_UpdateRect.

I have installed SDL_image.h and receive this message.

Error messages

main.c: In function ‘int SDL_main()’:
main.c:38:14: error: ‘SDL_SetVideoMode’ was not declared in this scope
screen = SDL_SetVideoMode(256, 256, 16, 0);
main.c:38:14: note: suggested alternative: ‘SDL_GetVideoDriver’
screen = SDL_SetVideoMode(256, 256, 16, 0);
main.c:71:5: error: ‘SDL_UpdateRect’ was not declared in this scope
SDL_UpdateRect(screen, 0, 0, 0, 0);
main.c:71:5: note: suggested alternative: ‘SDL_UpdateTexture’
SDL_UpdateRect(screen, 0, 0, 0, 0);
Press any key to continue . . .

Full code

/* Example of direct pixel access with SDL. */
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_rect.h>
#include <stdio.h>
#include <stdlib.h>
Uint16 CreateHicolorPixel(SDL_PixelFormat * fmt, Uint8 red,
                          Uint8 green, Uint8 blue)
    Uint16 value;
    /* This series of bit shifts uses the information from the
    SDL_Format structure to correctly compose a 16-bit pixel
    value from 8-bit red, green, and blue data. */
    value = ((red >> fmt->Rloss) << fmt->Rshift) +
            ((green >> fmt->Gloss) << fmt->Gshift) +
            ((blue >> fmt->Bloss) << fmt->Bshift);
    return value;

int main()
    SDL_Surface *screen;
    Uint16 *raw_pixels;
    int x, y;
    /* Initialize SDL's video system and check for errors. */
    if (SDL_Init(SDL_INIT_VIDEO) != 0) {
        printf("Unable to initialize SDL: %s\n", SDL_GetError());
        return 1;

    /* Make sure SDL_Quit gets called when the program exits! */
    /* Attempt to set a 256x256 hicolor (16-bit) video mode.
    This will set some type of 16-bit mode, but we won't
    know which particular pixel format ahead of time. If
    the video card can't handle hicolor modes, SDL will
    emulate it. */
    screen = SDL_SetVideoMode(256, 256, 16, 0);
    if (screen == NULL) {
        printf("Unable to set video mode: %s\n", SDL_GetError());
        return 1;

    /* Video memory can be strange, and it's sometimes necessary to
    "lock" it before it can be modified. SDL abstracts this with
    the SDL_LockSurface function. */
    /* Get a pointer to the video surface's memory. */
    raw_pixels = (Uint16 *) screen->pixels;
    /* We can now safely write to the video surface. We'll draw a
    nice gradient pattern by varying our red and blue components
    along the X and Y axes. Notice the formula used to calculate
    the offset into the framebuffer for each pixel.
    (The pitch is the number of bytes per scanline in memory.) */
    for (x = 0; x < 256; x++) {
        for (y = 0; y < 256; y++) {
            Uint16 pixel_color;
            int offset;
            pixel_color = CreateHicolorPixel(screen->format,
                                             x, 0, y);
            offset = (screen->pitch / 2 * y + x);
            raw_pixels[offset] = pixel_color;

    /* We're finished drawing, so unlock the surface. */
    /* Inform SDL that the screen has been changed. This is
    necessary because SDL's screen surface is not always the real
    framebuffer; it is sometimes emulated behind the scenes. */
    SDL_UpdateRect(screen, 0, 0, 0, 0);
    /* Pause for a few seconds as the viewer gasps in awe. */
    return 0;

If you want to use SDL_image, you need to install it.
As Olli said, it’s a separate library.
You can find it at

Pro-Tip: Put ```c in a line before your code block and ``` in a line behind it in posts here so their formatting is not screwed up (and you even get C syntax highlighting)

SDL_SetVideoMode and SDL_UpdateRect are SDL1.2 functions that are not available in SDL2 might help :slight_smile:

Thank you, the link is very helpful. I have downloaded it and I will read it.

It is rather amazing that a sophisticated piece of software like SDLv2 has been developed and it seems no simple tutor or basic set of programs exist for it. It makes you wonder what they used to develop and test it?

Even the “official SDL2” documentation uses SDL1.2 code! I have also noticed there is no tool chain comment for any SDL program I have found. Hence no way of knowing what a program is… SDL1, SDL1.2, SDL1.3, or SDL2! The above listed program said it was “a SDL2”, oh uhmm. has links to lots of tutorials, and
there is also