SDL2 Tutorial: How To Draw and Render Using C++

preview_player
Показать описание
SDL2 helps programmers draw graphics to the screen by providing a simple C style interface to drawing functions simple collision detection algorithms and an event system for polling inputs. All of these are great for creating simple video games or computer visuals. To learn more about SDL see their official documentation

Give me money:

Below are affiliate links, I may earn something if you purchase the mentioned product or service linked.

📚 Recommended Books

💵 Get $100 in credits from Vultr with this link

0:00 - Intro
0:13 - Create Window
2:50 - Draw Color
5:40 - Drawing
7:50 - Compiling
9:25 - SDL_Rect
18:36 - More drawing functions
Рекомендации по теме
Комментарии
Автор

This is such a thorough tutorial. Helped me a lot!

AliRaza-gdlk
Автор

love the comprehensive explanation, gonna watch more

gasparliboreiro
Автор

Light theme is a crime... Great tutorial though!

Shovelzzzz
Автор

Hey, I was having some issues with the vector and the forloop using the emplace_back "C2661: no overloaded function takes 2 arguments"

I'm not sure why it was not allowing me to use this on the vector but what i ended up doing is using the push_back function:

-(below std::vector<SDL_Point> v BUT outside the forloop) SDL_Point temp;
- (Inside for loop) temp.x = rand() % 640;
- (right below that line) temp.y = rand() % 480;
- (right below that line) v.push_back(temp);

Not sure why i got that message but i got the same result using push_back

Steven-dtsh
Автор

Tried using SDL2 in VSCodium on Arch but always got the error : "main.cpp:(.text+0x2d): undefined reference to `SDL_Init' ". Any idea what this could be? Thanks a lot.

marian
Автор

Is it possible to set the renderer to be transparent?

chigozie
Автор

can someone tell me how to setup the sdl.h file?? (preference without ides...) when i downloaded it gave me an dll and a readme

rodrigoqteixeira
Автор

Thanks a bunch, been having such a headache learning how to use this library, as graphics.h does not work on wayland. Saved me so much time.

tylerfife
Автор

Hello, when I run my programs, the window is not moveable, and I can not close the window using the window itself, I instead have to close the CMD window. Is there a fix to this?

Flanksss
Автор

I love your tutorials but the hardest part of following them is to get sdl2 installed, I'm getting bald with the ammout of errors and videos that work but not whey I try, I wish youn made a compehensive video about installing dependencis for c++ usage

gasparliboreiro
Автор

This is the 2nd tutorial of yours that I've ALMOST completed.This tutorial and the spinning cube in SDL2 works great up until I use the emplace_back function and then it breaks. Ive commented out the "v.emplace_back(rand() % 640, rand() % 480);" and it compiles fine.
Any Idea?

error: new initializer expression list treated as compound expression [-fpermissive]
{ ::new((void *)__p) }

error: no matching function for call to 'SDL_Point::SDL_Point(int)'
In file included from C:/SDL2-W-image/include/SDL2/SDL_video.h:33:0,
from C:/SDL2-W-image/include/SDL2/SDL_events.h:33,
from C:/SDL2-W-image/include/SDL2/SDL.h:41,
from
note: candidate: SDL_Point::SDL_Point()
typedef struct SDL_Point

mrdouble
visit shbcf.ru