Skip to content

Instantly share code, notes, and snippets.

View xeekworx's full-sized avatar
💭
Looking for open-source tool ideas.

Xeek xeekworx

💭
Looking for open-source tool ideas.
View GitHub Profile
@xeekworx
xeekworx / sdl_box_move_example.c
Created June 20, 2022 05:41
SDL Renderer & Keyboard State Example in C
#include <SDL.h>
#include <stdio.h>
// Macros used to keep the box within the screen's boundaries. In C++ std::min and std::max can be used.
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
// This is the forward declaration for shutdown so that main() knows it exists, check below main() for the function
// body.
int shutdown(SDL_Window* main_window, SDL_Renderer* renderer, const char* error_prefix, const char* error);
@xeekworx
xeekworx / sdl_textediting.cpp
Created October 30, 2022 16:37
With SDL use SDL_TEXTINPUT and SDL_ttf to enter and display text.
#include <SDL.h>
#include <SDL_ttf.h>
#include <iostream>
int main(int argc, char* argv[])
{
const std::string app_title = "SDL_TextBoxExample";
const SDL_Color background_color = SDL_Color{ 0, 50, 255, 255 };
const SDL_Color foreground_color = SDL_Color{ 255, 255, 255, 255 };
const SDL_Rect window_rect = SDL_Rect{ SDL_WINDOWPOS_CENTERED , SDL_WINDOWPOS_CENTERED , 1280, 720 };
#include <SDL.h>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <format>
int main(int argc, char* argv[])
{
std::string app_title = "SDL Box Example";