Skip to content

Instantly share code, notes, and snippets.

View chrisdill's full-sized avatar

Chris Dill chrisdill

View GitHub Profile
@chrisdill
chrisdill / UpdateTools.c
Created June 20, 2021 17:30
Testing changes to tools in core(gifs/screenshots/events) to make it easier to maintain/modify.
// Built in tools for learning and testing
static void UpdateTools()
{
#if defined(SUPPORT_SCREEN_CAPTURE)
// Check screen capture key (raylib key: KEY_F12)
if (IsKeyPressed(KEY_F12))
{
#if defined(SUPPORT_GIF_RECORDING) && defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) || defined(PLATFORM_UWP)
if (IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_RIGHT_CONTROL))
@chrisdill
chrisdill / batch-drawing1.c
Last active March 23, 2021 13:22
DrawTexturePro and DrawRectanglePro optimizations
// Updated with bug fixes etc
// Draw a part of a texture (defined by a rectangle) with 'pro' parameters
// NOTE: origin is relative to destination rectangle size
void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint)
{
// Check if texture is valid
if (texture.id > 0)
{
float width = (float)texture.width;
@chrisdill
chrisdill / CubeTexture1.cs
Created January 19, 2021 22:30
Drawing a cube with Rlgl using 2 textures
using System.Numerics;
using Raylib_cs;
namespace Testing
{
public class CubeTexture1
{
// Draw cube with multiple textures for different faces
// NOTE: Cube position is the center position
static void DrawCubeCustom(Texture2D texture1, Texture2D texture2, Vector3 position, float width, float height, float length, Color color)
@chrisdill
chrisdill / build_live_reload.sh
Created January 23, 2020 15:37
A fun little test of a SDL2 platform layer for hot code reloading with rayfork
#!/bin/bash
INCLUDES="-I../../dependencies/cgltf -I../../dependencies/dr_libs -I../../dependencies/jar -I../../dependencies/miniaudio -I../../dependencies/par -I../../dependencies/stb -I../../dependencies/tinyobjloader-c -I../../examples/dependencies/ -I../../examples/dependencies/sokol -I../../rayfork"
if [ "$(uname)" = "Darwin" ]
then
FLAGS="-g -D_DEFAULT_SOURCE -ObjC -fobjc-arc"
LIBRARIES="-framework Cocoa"
else
FLAGS="-g -D_DEFAULT_SOURCE"
@chrisdill
chrisdill / RayForm.cs
Last active June 6, 2024 15:34
Using raylib from inside a win forms application
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Raylib_cs;
using Color = Raylib_cs.Color;
namespace Rayforms
{
public class RayForm : Form