Problems with SDL 2.0

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.)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44


#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;
}
Make sure SDL_CreateRenderer doesn't return a null pointer.
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.
Last edited on
Topic archived. No new replies allowed.