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
#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";
@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 };
@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 / findstring_demo.c
Created April 28, 2021 20:54
FindString Example in C
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <ctype.h>
#define MATCH_NOT_FOUND SIZE_MAX
size_t findstring(const char* str, const char* match, size_t current_pos);
void main(void)
#pragma once
#include <SDL.h> // Unnecessary if the source including this header already includes SDL.h
#include <cmath> // For round()
struct SDL_RectF {
float x, y, w, h;
operator SDL_Rect()
{
return SDL_Rect{
#include <SDL.h>
#include <iostream>
#include <sstream>
#include <string>
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h" // https://github.com/nothings/stb/blob/master/stb_image.h
int main(int argc, char* argv[])
{
std::string app_title = "SDL_Guide 03: Image Loading & Rendering";
Imports System
Imports System.IO
Imports System.Linq
Imports System.Net
Imports System.Net.Http
Imports System.Runtime.InteropServices
Imports System.Threading.Tasks
Imports Dropbox.Api
Imports Dropbox.Api.Common
Imports Dropbox.Api.Files
@xeekworx
xeekworx / sdl_box_move_example.cpp
Last active January 5, 2023 23:01
SDL Renderer & Keyboard State Example
#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 Movement Example - Use the arrow keys!";
@xeekworx
xeekworx / sdl_nanovg_triangle_example.cpp
Last active July 28, 2018 19:27
SDL + GLAD + OpenGL + NanoVG Example in C++ (Triangle)
#include <SDL.h>
#include <glad\glad.h>
#include <nanovg.h>
#define NANOVG_GL3_IMPLEMENTATION
#include <nanovg_gl.h>
#include <nanovg_gl_utils.h> // For framebuffer utilities not shown in this code
#include <string>
#include <iostream>
#include <iomanip> // for setw
@xeekworx
xeekworx / nvgTriangle.c
Last active July 28, 2018 18:47
nvgTriangle
void nvgTriangle(NVGcontext * ctx, float x1, float y1, float x2, float y2, float x3, float y3)
{
nvgMoveTo(ctx, x1, y1);
nvgLineTo(ctx, x2, y2);
nvgLineTo(ctx, x3, y3);
nvgClosePath(ctx);
}