Skip to content

Instantly share code, notes, and snippets.

View EncodeTheCode's full-sized avatar
💭
Coding useful tools for workflow.

EncodeTheCode

💭
Coding useful tools for workflow.
View GitHub Profile
import struct
import json
import numpy as np
from pathlib import Path
from OpenGL.GL import *
from OpenGL.GL.shaders import compileProgram, compileShader
import glfw
import time
"""
# GLB_3D_renderer_simple.py
"""
Simple GLB loader + animation player for intermediate Python/OpenGL users.
Focuses on node TRS animation (translation, rotation quaternion, scale) and morph weights.
Does not implement GPU skinning in full; hooks are provided for extension.
Dependencies: pip install pygltflib numpy PyOpenGL glfw
"""
import json
# GLB_3D_renderer.py
"""
Combined GLB loader + texture loader + animation player + renderer with GPU skinning.
Requires: pygltflib, numpy, PyOpenGL, glfw, Pillow
Run: python GLB_3D_renderer.py model.glb
"""
import os
import sys
import math
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Optimized WoW-style Canvas Tooltip</title>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<style>
body { background: #0b0b0b; color: #ddd; font-family: Arial, Helvetica, sans-serif; padding: 18px; }
h1 { font-size: 18px; margin: 6px 0 12px; color: #fff; }
.row { display:flex; gap:20px; align-items:flex-start; flex-wrap:wrap; }
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>WoW-style Item Tooltip — Canvas + CSS Example</title>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<style>
/* ---------- DOM tooltip CSS (optional, for reference or fallback) ---------- */
:root{
--bg-1: rgba(17,17,17,0.96);
#include <bits/stdc++.h>
using namespace std;
/*
A heuristic "auto-semicolon" preprocessor.
Reads stdin or a file and writes to stdout.
Inserts semicolons at newline boundaries when it appears a statement ended.
Not a full C++ parser — best-effort for common constructs.
*/
// auto_semi_compiler.cpp
// Compile: g++ -std=c++17 -O2 auto_semi_compiler.cpp -o auto_semi_compiler
//
// Usage:
// ./auto_semi_compiler <all original clang++/g++ args...>
// Example (transparent):
// ./auto_semi_compiler -std=c++17 -O2 -c foo.nocpp -o foo.o
//
// By default it will try to run "clang++" as the real compiler.
// Set REAL_CXX environment variable to point to another compiler (e.g. g++).
// auto_semi_improved.cpp
// Heuristic but improved auto-semicolon inserter.
// Not a full C++ parser; still heuristic but handles many more edge cases.
#include <bits/stdc++.h>
using namespace std;
enum class TokKind {
IDENT, NUMBER, STRING, RAW_STRING, CHAR, PUNCT, OP, NEWLINE, SPACE,
PREPROCESSOR, COMMENT_LINE, COMMENT_BLOCK, END
# glb_player_glfw.py
import time, ctypes, math
import numpy as np
import glfw
from OpenGL.GL import *
from OpenGL.GL.shaders import compileProgram, compileShader
import pyassimp
# ---------------- math helpers ----------------
def identity4(): return np.eye(4, dtype=np.float32)
# fps_demo.py
"""
Minimal FPS demo using PyGame + PyOpenGL + NumPy + Pillow.
Features:
- Camera with pitch, yaw, roll (mouse look & WASD movement)
- Material + SamplerConfig to pick filters, wrap, anisotropy
- PNG loading with alpha support, mipmaps, cached samplers
- VAO/VBO-based meshes (plane + cube)
- Grouped draws by material to minimize texture binds