Skip to content

Instantly share code, notes, and snippets.

View recp's full-sized avatar
🔭
Inventing

Recep Aslantas recp

🔭
Inventing
View GitHub Profile
#version 410
uniform mat4 MVP; // Projection * View * Model matrix
uniform mat4 MV; // View * Model Matrix
uniform mat4 NM; // Normal matrix
uniform int NMU; // Use normal matrix
layout(location = 0) in vec3 POSITION;
layout(location = 1) in vec3 NORMAL;
#version 410
subroutine
vec4
technique(vec4 light, vec3 L);
struct ColorOrTex {
vec4 color;
};
@recp
recp / main.cc
Created February 15, 2017 12:59
libui - usage
#include <ui-app.h>
#include <ui-window.h>
using namespace ui;
int main(int argc, const char *argv[]) {
App app;
Window mainWindow({{10,0}, {800, 600}});
/*
* Copyright (c), Recep Aslantas.
* MIT License (MIT), http://opensource.org/licenses/MIT
*/
#version 410
uniform mat4 MVP; // Projection * View * Model matrix
uniform mat4 MV; // View * Model Matrix
uniform mat4 NM; // Normal matrix
/*
* Copyright (c), Recep Aslantas.
* MIT License (MIT), http://opensource.org/licenses/MIT
*/
#version 410
#define AmbientlLight 1u
#define DirectionalLight 2u
#define PointLight 3u
@recp
recp / camera-vertices.c
Created November 25, 2017 14:34
camera-vertices
void
gkPrepareCameraProp(GkCamera * __restrict cam) {
mat4 projViewInv;
vec4 *vert;
vec3 min, max;
int32_t i;
vert = cam->vertices;
glm_mat4_inv(cam->projView, projViewInv);
@recp
recp / useful.glsl
Created January 15, 2018 14:32
OpenGL
Source: https://www.opengl.org/discussion_boards/showthread.php/173019-View-Space-Light-Position-Moving
vec3 PositionFromDepth_DarkPhoton(in float depth)
{
vec2 ndc; // Reconstructed NDC-space position
vec3 eye; // Reconstructed EYE-space position
eye.z = near * far / ((depth * (far - near)) - far);
@recp
recp / aabb_transform.c
Last active August 30, 2022 04:46
aabb transform
CGLM_INLINE
void
glm_aabb_transform(vec3 box[2], mat4 m, vec3 dest[2]) {
vec3 v[2], xa, xb, ya, yb, za, zb, tmp;
glm_vec_scale(m[0], box[0][0], xa);
glm_vec_scale(m[0], box[1][0], xb);
glm_vec_scale(m[1], box[0][1], ya);
glm_vec_scale(m[1], box[1][1], yb);
@recp
recp / GLView.mm
Created March 4, 2018 16:46
GLView
/*
* Copyright (c), Recep Aslantas. All rights reserved.
*/
#import "GLView.h"
#import <OpenGL/OpenGL.h>
#import <OpenGL/gl3.h>
@interface GLView()
@end
@recp
recp / GLView.h
Last active July 27, 2022 10:35
Cocoa: Custom OpenGL View
/*
* Copyright (c), Recep Aslantas. All rights reserved.
*/
#import <Cocoa/Cocoa.h>
@protocol GLViewDelegate;
@interface GLView : NSView {
NSOpenGLContext * m_openGLContext;