Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan Bechard dbechrd

View GitHub Profile
View engine_development.md

RicoTech Engine (2016 - 2019)

Learning modern OpenGL. The first two quads I rendered on screen.

image

Five more quads (1 ground, 4 walls) added to scene. Added textures.

image

View convstr.c
#include <stdio.h>
#include "../../dlb/dlb_vector.h"
// NOTE: Have to store as offset rather than pointer in case vector reallocs. Could use block allocator but wutevs man.
typedef struct String {
size_t offset;
size_t length;
} String;
typedef enum TokenType {
View win32_last_modified_notify.c
#include "ta_asset_watcher.h"
#include "tinycthread/source/tinycthread.h"
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <tchar.h>
static ta_watcher_result ta_asset_watcher_wait_changes(ta_asset_watcher *watcher, HANDLE handle)
{
DWORD bytesReturned = 0;
View UnityComponentLister.cs
// Copyright 2020 - Dan Bechard
// https://github.com/dbechrd
// License: Public Domain
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
// Lists all classes that inherit from Component in Unity's debug log
// Note: This uses C#'s run-time type introspection (i.e. "reflection"),
@dbechrd
dbechrd / event_system_pseudo.cpp
Last active May 25, 2020
Pseudocode for a very basic event system in a game engine
View event_system_pseudo.cpp
At a high level, events work as follows:
- Each type of event must have a unique name or ID (e.g. "user_joined_game")
- Each type of event may have additional metadata (e.g. the "user_joined_game" event will likely have a "user_id" in the metadata)
- Zero or more event handlers (in the form of callback function, also sometimes called "listeners" and owned by "subscribers") can be registered for each type of event. This can be done in many different ways, one way would be to have a central event manager that keeps track by having a list of subscribers for each type of event. In a more advanced implementation, you could also have filters (e.g. only send me "user_position_changed" events for "user_id = 5"). I would recommend starting with a simple boolean "handled" flag as a filter to start (see below).
- Zero or more places where an event is fired (also called "triggered", done by a "publisher").
- When an even is fired/triggered by a publisher, it goes into an event queue. Generally you'd have one portion of a
View stb_to_c_array.c
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
int w, h, channels;
unsigned char *data;
FILE *file;
@dbechrd
dbechrd / __init__.py
Last active May 15, 2020
My-Craft Blender 2.80 Exporter
View __init__.py
bl_info = {
"name": "My-Craft Export (.mce)",
"description": "NexusNul is cool",
"author": "NexusNul",
"version": (2, 0, 0, 0),
'blender': (2, 80, 0),
"location": "File > Import-Export",
"wiki_url": "",
"category": "Import-Export"}
@dbechrd
dbechrd / hb_stb_truetype.c
Created Mar 12, 2020 — forked from rygorous/hb_stb_truetype.c
HarfBuzz->stb_truetype
View hb_stb_truetype.c
// ---- loading a font
static void load_font(void)
{
hb_blob_t *blob;
hb_face_t *face;
size_t filelen = 0;
void *filedata = stb_file("c:/windows/fonts/arial.ttf", &filelen);
if (filedata == 0) stbpg_fatal("Couldn't load font");
View win32_minimal.cpp
#include "Winning.h"
#include <sstream>
LRESULT CALLBACK WindowProc(
_In_ HWND hwnd,
_In_ UINT msg,
_In_ WPARAM wparam,
_In_ LPARAM lparam)
{
switch (msg) {
@dbechrd
dbechrd / timer.c
Created Feb 21, 2020 — forked from ForeverZer0/timer.c
Cross-platform, drop-in, high resolution timer for C/C++ projects.
View timer.c
/* ----------------------------------------------------------------------- */
/*
Easy embeddable cross-platform high resolution timer function. For each
platform we select the high resolution timer. You can call the 'ns()'
function in your file after embedding this.
*/
#include <stdint.h>
#if defined(__linux)
# define HAVE_POSIX_TIMER
# include <time.h>
You can’t perform that action at this time.