Skip to content

Instantly share code, notes, and snippets.

@nlguillemot
nlguillemot / main.cpp
Created April 28, 2017 03:03
stable opengl timestamps with D3D12
#ifdef _WIN32
#include <d3d12.h>
#include <dxgi1_5.h>
#pragma comment(lib, "d3d12.lib")
#pragma comment(lib, "dxgi.lib")
#endif
#ifdef _WIN32
void SetStablePowerState()
@nlguillemot
nlguillemot / tasks.md
Last active February 17, 2018 20:11
Musings on task parallelism

In order to effectively use a multi-core CPU, a decomposition of code into tasks must be made. By decomposing code into tasks, the tasks can be distributed among CPU cores by a scheduler. Tasks can have dependencies on other tasks, meaning that the tasks execute in a partial order. This partial order can be represented as a graph, where each task has predecessors and successors. A task can only execute when all its predecessors have completed.

To implement this, we can explicitly create a graph of tasks, with edges between tasks to identify predecessor/successor relationships. The problem with a general task graph system is that it's not productive to work with. Maybe it's okay for some purposes to have a GUI interface to build a task graph, but that's too tedious for everyday code. Imagine if you had to explicitly create nodes and edges when implementing a single-threaded function call graph, it would be so tedious!

@nlguillemot
nlguillemot / CSC230Assignment3.s
Created June 20, 2012 06:01
CSC 230 Assignment 3 - Treadmill
@ CSC230 Spring 2012 -- Treadmill program
@ Author: Nicolas Guillemot
@ Student ID number: V00695164
@ Global constants for physics
@ default value for weight
.equ DFT_WEIGHT, 100 @ lbs
@ minimum value for weight (see WeightMax for maximum)
.equ WEIGHT_MIN, 50 @ lbs
@ default value for target speed
@nlguillemot
nlguillemot / main.c
Created August 14, 2012 07:27
attempt to sort image by hue
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <math.h>
SDL_Surface *screen;
float hue_from_rgb(int r, int g, int b)
{
// return atan2(sqrt(3.0) * (g - b), 2.0f * r - g - b);
return atan2(2.0f * r - g - b, sqrt(3.0) * (g - b));
@nlguillemot
nlguillemot / gist:b1981969b07295376674
Created December 19, 2014 17:58
utility function to convert GLenum error codes to strings like gluErrorString
const char* GLErrorToString(GLenum err)
{
switch (err)
{
case GL_NO_ERROR: return "GL_NO_ERROR";
case GL_INVALID_ENUM: return "GL_INVALID_ENUM";
case GL_INVALID_VALUE: return "GL_INVALID_VALUE";
case GL_INVALID_OPERATION: return "GL_INVALID_OPERATION";
case GL_STACK_OVERFLOW: return "GL_STACK_OVERFLOW";
case GL_STACK_UNDERFLOW: return "GL_STACK_UNDERFLOW";
@nlguillemot
nlguillemot / superbasicgl.cpp
Created March 8, 2015 20:30
super basic GL
#include <windows.h>
#include <GL/gl.h>
#include <cmath>
int lineWidth = 1;
LRESULT CALLBACK MyWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_CLOSE)
@nlguillemot
nlguillemot / main.cpp
Created August 30, 2015 02:22
BasicGL
#include <Windows.h>
#include <GL/gl.h>
#pragma comment(lib, "OpenGL32.lib")
LRESULT CALLBACK MyWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CLOSE:
@nlguillemot
nlguillemot / main.d
Created June 11, 2013 07:14
gtkD with opengl3 using derelict3
import gdk.Event;
import gtk.DrawingArea;
import gtk.Main;
import gtk.MainWindow;
import gtk.Widget;
import gtk.Button;
import gtk.VBox;
import glgdk.GLConfig;
import glgdk.GLContext;
@nlguillemot
nlguillemot / Makefile
Created April 18, 2013 08:14
GLFWcursorposfun test
all:
dmd main.d -L-lDerelictGL3 -L-lDerelictGLFW3 -L-lDerelictUtil -L-ldl
import derelict.opengl3.gl3;
import derelict.glfw3.glfw3;
void main(){
DerelictGL3.load();
DerelictGLFW3.load();
glfwInit();
GLFWwindow* window = glfwCreateWindow(640,480,"Hello, World!",null,null);