Skip to content

Instantly share code, notes, and snippets.

View 8Observer8's full-sized avatar

Ivan 8Observer8

View GitHub Profile
@8Observer8
8Observer8 / debug-drawer.js
Created February 11, 2023 08:52
Debug drawer for box2d.ts
import { mat4, quat, vec3 } from "gl-matrix";
import { gl } from "./webgl-context.js";
import { getEuler } from "./math-helpers.js"
// This class implements debug drawing callbacks that
// are invoked inside b2World::Step
export default class DebugDrawer {
constructor(program, pixelsPerMeter) {
this.program = program;
#!/usr/bin/python
# coding=utf-8
import os, pygame, time, random, uuid, sys
class myRect(pygame.Rect):
""" Add type property """
def __init__(self, left, top, width, height, type):
pygame.Rect.__init__(self, left, top, width, height)
self.type = type
@8Observer8
8Observer8 / main.py
Created February 6, 2023 11:05
Button over OpenGL canvas in PyQt6
import sys
from OpenGL.GL import *
from PyQt6.QtCore import QSize, Qt
from PyQt6.QtOpenGLWidgets import QOpenGLWidget
from PyQt6.QtWidgets import QApplication, QPushButton, QVBoxLayout
class OpenGLWidget(QOpenGLWidget):
@8Observer8
8Observer8 / color.frag
Created January 29, 2023 12:52
Click detection with AABB, Box2D, OpenGL 2.1, PyQt6, Python 3.8
precision mediump float;
uniform vec3 uColor;
void main()
{
gl_FragColor = vec4(uColor, 1.0);
}
@8Observer8
8Observer8 / index.html
Last active November 29, 2022 17:02
Load Ammo.js and a texture using Promise. WebGL, JavaScript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Load Ammo.js and a texture using Promise. Rollup, WebGL, JavaScript</title>
</head>
@8Observer8
8Observer8 / index.html
Last active November 29, 2022 14:00
Load a texture using Promise, draw a triangle and import glMatrix as ES6-module
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example</title>
</head>
<body>
@8Observer8
8Observer8 / index.html
Last active November 28, 2022 23:13
Import glMatrix and a simple triangle in WebGL
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dog. WebGL, JavaScript</title>
</head>
<body>
@8Observer8
8Observer8 / .clang-format
Last active October 24, 2022 18:16
clang, extended braces: clang-format *.h *.cpp -i --style=file:"E:/clang-format/MyStyleWebKit/.clang-format"
---
Language: Cpp
# BasedOnStyle: WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignArrayOfStructures: None
AlignConsecutiveMacros: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
@8Observer8
8Observer8 / main.cpp
Created October 19, 2022 22:17
explosion-bullet-opengl1-freeglut-cpp
#define FREEGLUT_STATIC
#include <GL/freeglut.h>
#include <GL/glu.h>
#include <algorithm>
#include <btBulletDynamicsCommon.h>
#include <iostream>
#include <set>
#define EXPLOSION_STRENGTH 50.f
@8Observer8
8Observer8 / main.cpp
Created October 19, 2022 02:49
trigger-bullet-opengl1-freeglut-cpp
#define FREEGLUT_STATIC
#include <GL/freeglut.h>
#include <GL/glu.h>
#include <algorithm>
#include <btBulletDynamicsCommon.h>
#include <iostream>
#include <set>
int winW = 350, winH = 350;