Skip to content

Instantly share code, notes, and snippets.

View tilkinsc's full-sized avatar
▶️
Working on Lua.NET

Cody Tilkins tilkinsc

▶️
Working on Lua.NET
View GitHub Profile
@tilkinsc
tilkinsc / load_dds.c
Last active March 23, 2024 17:20
C OpenGL DDS Loading Tutorial
/*
Can load easier and more indepth with https://github.com/Hydroque/DDSLoader
Because a lot of crappy, weird DDS file loader files were found online. The resources are actually VERY VERY limited.
Written in C, can very easily port to C++ through casting mallocs (ensure your imports are correct), goto can be replaced.
https://www.gamedev.net/forums/topic/637377-loading-dds-textures-in-opengl-black-texture-showing/
http://www.opengl-tutorial.org/beginners-tutorials/tutorial-5-a-textured-cube/
^ Two examples of terrible code
@tilkinsc
tilkinsc / main.cpp
Last active February 20, 2024 01:34
WGL Full Demo
/**
*
* MIT License
*
* Copyright (c) 2017-2022 Cody Tilkins
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@tilkinsc
tilkinsc / sound.c
Created October 31, 2018 14:01
OpenAL how to load an Ogg Vorbis file and play it
// Created by: http://github.com/tilkinsc
// returns ALuint* aka a single openal buffer of ready-to-play ogg vorbis sound samples
// returns 0 on error
ALuint* sound_load_ogg(const char* path) {
ALenum error = 0;
ALuint* sound = 0;
FILE* fp = 0;
OggVorbis_File vf;
@tilkinsc
tilkinsc / init.lua
Created January 25, 2023 19:19
Lua but Functional
local sub = string.sub
local concat = table.concat
local insert = table.insert
string.where = function(self, predicate)
local buf = {}
for i = 1, #self do
local ch = sub(self, i, i)
if (predicate(ch)) then
insert(buf, ch)
end
@tilkinsc
tilkinsc / JsonSerializable.cs
Created January 10, 2023 18:39
Effective Json serialization for C# CSharp classes
using System.Text.Json;
namespace Meerkat.Json;
public interface IJSONSerializable
{
}
/// <summary>
/// Implements the ability to load JSON files. By default, if the json file
@tilkinsc
tilkinsc / main.cpp
Last active October 8, 2022 18:34
Getting fully started with wgl
See https://gist.github.com/tilkinsc/7f383faccf3722622f5d0cc9bd45e7e6
@tilkinsc
tilkinsc / TwoWayMemoryStream.cs
Created September 10, 2022 23:03
A memory stream will advance on read, this reduces the position.
using System.Runtime.InteropServices;
namespace Util;
class TwoWayMemoryStream : MemoryStream
{
private byte[] _buffer;
private TwoWayMemoryStream()
@tilkinsc
tilkinsc / ddsload.cs
Last active August 19, 2022 20:14
C# rudimentary loading DDS for OpenGL using Silk.NET
enum DDSD
{
NONE = 0x00,
CAPS = 0x01,
HEIGHT = 0x02,
WIDTH = 0x04,
PITCH = 0x08,
PIXELFORMAT = 0x1000,
MIPMAPCOUNT = 0x20000,
LINEARSIZE = 0x80000,
@tilkinsc
tilkinsc / wave.c
Last active August 10, 2022 22:03
A simpilex wave file parser
#include "wave.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
// wave.h start
typedef struct WaveData {
@tilkinsc
tilkinsc / texture_atlas.cpp
Last active July 13, 2022 21:34
OpenGL Texture Atlas Array Texture Example
// tiles_x the amount of tiles in the image in the x dimension
// tiles_y the amount of tiles in the image in the y dimension
void Texture::finalizeArray(GLsizei tiles_x, GLsizei tiles_y) {
// read in file data
Material* mat = new Material("file.bmp"); // MUST be power of 2
mat->mips = 1; // !single image!
// defines ogl parameters