Hey guys , i am starting to learn SDL in order to make some 2d games , however , while i was trying to open my first window i am getting this error ,
(First-chance exception at 0x00BDAFB8 in breakout.exe: 0xC0000005: Access violation executing location 0x00BDAFB8.)
If there is a handler for this exception, the program may be safely continued.)
#include<SDL.h>
#include <iostream>
SDL_Window* g_pWindow = 0;
SDL_Renderer* g_pRenderer = 0;
int main(int argc, char* args[])
{
// initialize SDL
if (SDL_Init(SDL_INIT_EVERYTHING) >= 0)
{
// if succeeded create our window
g_pWindow = SDL_CreateWindow("Chapter 1: Setting up SDL",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
640, 480,
SDL_WINDOW_RESIZABLE);
// if the window creation succeeded create our renderer
if (g_pWindow != 0)
{
g_pRenderer = SDL_CreateRenderer(g_pWindow, -1, 0);
}
}
else
{
return 1; // sdl could not initialize
}
// everything succeeded lets draw the window
// set to black // This function expects Red, Green, Blue and
// Alpha as color values
SDL_SetRenderDrawColor(g_pRenderer, 0, 0, 0, 255);
// clear the window to black
SDL_RenderClear(g_pRenderer);
// show the window
SDL_RenderPresent(g_pRenderer);
// set a delay before quitting
SDL_Delay(5000);
// clean up SDL
SDL_Quit();
return 0;
}
Hey guys , i managed to fix the problem.
for some reason i needed to change the flag in the SDL_CreateRenderer from SDL_RENDERER_ACCELERATED to SDL_RENDERER_SOFTWARE .
do you guys know the reason of that ?
much appreciated.