Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Advanced C: Graphics with SDL

Lesson 47 of 53 in the free Foundation of C & C++ notes on Siksha Sarovar, written by Rohit Jangra.

Beyond the Text Console

Are you tired of black-and-white text programs? It's time to draw! While standard C doesn't have graphics, we can use a library called SDL (Simple DirectMedia Layer).

What can SDL do?

  • Draw lines, circles, and images.
  • Play sound and music.
  • Handle input from Joysticks and Gamepads.
  • Manage high-performance graphics windows.

Many Famous Games were built with C/C++ and SDL:

  • Half-Life
  • Portal
  • Team Fortress 2
  • FTL: Faster Than Light

The Basic Loop of a Graphic Program

  1. Initialize: Start the graphics engine.
  2. Input: Check if the user moved the mouse or pressed a key.
  3. Update: Change the position of objects (like a player jumping).
  4. Draw: Clear the screen and draw the new scene.
  5. Repeat: Do this 60 times per second (60 FPS).
If you want to become a Game Developer, learning SDL with C is the best way to understand how game engines like Unreal or Unity work behind the scenes.