Skip to content

Instantly share code, notes, and snippets.

View 8Observer8's full-sized avatar

Ivan 8Observer8

View GitHub Profile
@8Observer8
8Observer8 / CMakeLists.txt
Last active October 10, 2024 10:24
Set a background color using OpenGL, SDL3, and C++
# mkdir dist\win
# cmake -G "MinGW Makefiles" -S . -B dist/win -DSDL3_DIR=E:/libs/sdl3-desktop-prefix/lib/cmake/SDL3
# cmake -G "MinGW Makefiles" -S . -B dist/win -DSDL3_DIR=E:/libs/sdl3-libs/SDL3-devel-3.1.3-mingw/SDL3-3.1.3/x86_64-w64-mingw32/lib/cmake/SDL3
# cd dist/win
# mingw32-make
# app
cmake_minimum_required(VERSION 3.20)
project(background_color_opengl_sdl3_cpp)
@8Observer8
8Observer8 / main.py
Created September 6, 2024 09:26
How to enable WebGL in QWebEngineView
import sys
import os
from PyQt6.QtCore import QUrl
from PyQt6.QtWebEngineCore import QWebEngineSettings
from PyQt6.QtWebEngineWidgets import QWebEngineView
from PyQt6.QtWidgets import QApplication, QVBoxLayout, QWidget
class Widget(QWidget):
@8Observer8
8Observer8 / fbo.py
Last active August 16, 2024 12:11
Shadow mapping using Pygame, PyOpenGL, and PyGLM
from OpenGL.GL import *
def initFBO(offscreenWidth, offscreenHeight):
# Create a texture object and set its size and parameters
shadowMapTexture = glGenTextures(1)
glBindTexture(GL_TEXTURE_2D, shadowMapTexture)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, offscreenWidth, offscreenHeight,
@8Observer8
8Observer8 / main.cpp
Created July 6, 2024 21:23 — forked from nus/main.cpp
An example of emscripten with WebSocket.
// $ em++ -lwebsocket.js -o index.html main.cpp
#include <emscripten/emscripten.h>
#include <emscripten/websocket.h>
#include <stdio.h>
EM_BOOL onopen(int eventType, const EmscriptenWebSocketOpenEvent *websocketEvent, void *userData) {
puts("onopen");
EMSCRIPTEN_RESULT result;
@8Observer8
8Observer8 / main.cpp
Created December 29, 2023 18:56
Qt 6.6.1 Android Build Error: use of undeclared identifier 'GL_DRAW_FRAMEBUFFER'
#include <QtGui/QOpenGLExtraFunctions>
#include <QtGui/QSurfaceFormat>
#include <QtGui/QVector3D>
#include <QtOpenGL/QOpenGLFramebufferObject>
#include <QtWidgets/QApplication>
#include <QtWidgets/QLabel>
#include <QtWidgets/QWidget>
#include <QtWidgets/QVBoxLayout>
#include <QtOpenGLWidgets/QOpenGLWidget>
@8Observer8
8Observer8 / main.cpp
Created December 29, 2023 18:33
Qt 6.6.1 WebAssembly Error. WebGL: INVALID_ENUM: bindFramebuffer: invalid target
#include <QtGui/QOpenGLExtraFunctions>
#include <QtGui/QSurfaceFormat>
#include <QtGui/QVector3D>
#include <QtOpenGL/QOpenGLFramebufferObject>
#include <QtWidgets/QApplication>
#include <QtWidgets/QLabel>
#include <QtWidgets/QWidget>
#include <QtWidgets/QVBoxLayout>
#include <QtOpenGLWidgets/QOpenGLWidget>
@8Observer8
8Observer8 / format.cjs
Last active May 23, 2023 14:29
Format files recursively with js-beautify
const jsBeautify = require('js-beautify')['js_beautify'];
const fs = require('fs');
const glob = require('glob');
const options = {
indent_size: 4,
indent_char: ' ',
indent_with_tabs: false,
eol: '\n',
end_with_newline: true,
@8Observer8
8Observer8 / main.cpp
Created March 29, 2023 18:05
Keeping User Data for Box2D
// https://coliru.stacked-crooked.com/a/7765d15fe603a3d9
// https://gamedev.stackexchange.com/a/196955/115807
#include <iostream>
#include <string>
#include <vector>
#include <memory>
#include <map>
struct b2Fixture;
@8Observer8
8Observer8 / empty-window-qt6-cpp.pro
Created March 27, 2023 05:05
empty-window-qt6-cpp
QT += core gui widgets
SOURCES += main.cpp
TARGET = app
@8Observer8
8Observer8 / hello.s
Created February 13, 2023 03:23 — forked from mcandre/hello.s
64-bit GNU assembler Hello World for Windows
# Build:
#
# as -o hello.obj
# ld -o hello.exe hello.obj -L C:\\tools\\mingw64\\x86_64-w64-mingw32\\lib -lkernel32
#
# Requires MinGW
.extern GetStdHandle
.extern WriteFile
.extern ExitProcess