Skip to content

Instantly share code, notes, and snippets.

/*
* Nuklear - 1.32.0 - public domain
* no warrenty implied; use at your own risk.
* authored from 2015-2016 by Micha Mettke
*/
/*
* ==============================================================
*
* API
*
@sherjilozair
sherjilozair / sdl-sokol-sprite.c
Created June 9, 2018 14:05
Minimal sprite rendering example with SDL2 for windowing, sokol_gfx for graphics API using OpenGL 3.3 on MacOS
#include <OpenGL/gl3.h>
#include <SDL2/SDL.h>
#define SOKOL_IMPL
#define SOKOL_GLCORE33
#include <sokol_gfx.h>
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
#define CODE(...) #__VA_ARGS__
#include <stdio.h>
typedef struct Color{
int r, g, b, a
} Color;
typedef struct Vertex{
float x, y, z;
Color color;
} Vertex;
@sherjilozair
sherjilozair / main.c
Last active March 27, 2025 06:29
Minimal SDL2 + OpenGL3 example
#include <SDL2/SDL.h>
#ifdef __APPLE__
#include <OpenGL/gl3.h>
#include <OpenGL/gl3ext.h>
#else
#include <GL/gl.h>
#endif
#include <stdbool.h>
#define CODE(...) #__VA_ARGS__
#include "animal.h"
void Animal::inc(int i){
this->counter += i;
}
void Animal::say(){
std::cout << this->counter << std::endl;
}
SherjilOzair:build sherjilozair$ examples/05_triangle
Initialized SDL: ''
[2018-05-04 20:20:01.819393][Error] Error in OpenGL call:
Location: /Users/sherjilozair/gf/library/Window.cc:111
Expression: glEnable(GL_BLEND)
Error: GL_INVALID_ENUM
Description: An unacceptable value is specified for an enumerated argument.
Gamedev Framework (gf) example #05: Triangle
This example prints the hello world triangle of OpenGL.
You can click on the screen to see the screen coordinates and world coordinates.
[n.global]
output = sfml
[n.include]
/usr/local/include/SFML/
[Window/VideoMode.h]
preprocess = true
defines = true
@sherjilozair
sherjilozair / specnorm.py
Last active May 3, 2018 03:08
Spectral Normalization
import tensorflow as tf
import numpy as np
class SpecNorm(object):
def build(self, input_shape):
self.indim = input_shape[-1] * np.array(self.kernel_size).prod()
self.outdim = self.filters
self.u = self.add_variable(name='u', shape=(1, self.indim), trainable=False)
self.v = self.add_variable(name='v', shape=(self.outdim, 1), trainable=False)
super().build(input_shape)
sherjilozair-2:~ sherjil$ nimble install c2nim --verbose
Reading official package list
Downloading https://github.com/nim-lang/c2nim using git
Setting Nim stdlib prefix to
Setting Nim stdlib path to /Users/sherjil/.choosenim/toolchains/nim-#devel/lib
Warning: Package 'c2nim' has an incorrect structure. The top level of the package source directory should contain at most one module, named 'c2nim.nim', but a file named 'rules.nim' was found. This will be an error in the future.
Hint: If this is the primary source file in the package, rename it to 'c2nim.nim'. If it's a source file required by the main module, or if it is one of several modules exposed by 'c2nim', then move it into a 'c2nimpkg/' subdirectory. If it's a test file or otherwise not required to build the the package 'c2nim.nim', prevent its installation by adding `skipFiles = @["rules.nim"]` to the .nimble file. See https://github.com/nim-lang/nimble#libraries for more info.
Setting Nim stdlib prefix to
Setting Nim stdli
// Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.