sdl_test's Introduction
1. To install SDL on ubuntu machine: sudo apt-get install libsdl2-dev 2. Include it to main.cpp as #include "SDL.h" 3. To compile main.cpp file: g++ main.cpp `pkg-config --cflags --libs sdl2` ----- >What is `pkg config`? >So, how the SDL "main loop" works? First, the guy looks at the API docs: API by category->Input events->event handling. From there, we read that in sdl all the events waiting to be handled are located in an event queue. Using SDL_PollEvent(returns 1 if there is pending event), SDL_PeepEvents() and SDL_WaitEvent() we can observe and handle waiting input events. Thus, main game (event) loop looks smth like this: while (1) { SDL_Event event; while(SDL_PollEvent(&event)) { // handle your events here } // do some other stuff here -- draw your app, etc } >How colors are stored in SDL? As Uint32. To create color use this function: Uint32 SDL_MapRGB(const SDL_PixelFormat* format, Uint8 r, Uint8 g, Uint8 b); >What is SDL_PixelFormat? >How to change the surface color? SDL_FillRect(screen, NULL, white);... but, don't forget to UPDATE the screen. If you change color but don't update screen, no visible changes will take place! >why i don't see any changes when I change rect color? Use update() function: int SDL_UpdateWindowSurface(SDL_Window* window); this function is equivalent to the SDL's 1.2 SDL_Flip() >Limiting frames per second
sdl_test's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.