Skip to content

Instantly share code, notes, and snippets.

View 8Observer8's full-sized avatar

Ivan 8Observer8

View GitHub Profile
@8Observer8
8Observer8 / main.cpp
Last active October 9, 2022 14:36
Very Simple Triangle using OpenGL2, Qt6, and C++
// To run on laptops:
#ifdef _WIN32
#include <windows.h>
extern "C" __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
extern "C" __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001;
#endif
#include <QtGui/QOpenGLFunctions>
#include <QtGui/QSurfaceFormat>
#include <QtOpenGL/QOpenGLBuffer>
@8Observer8
8Observer8 / sdl2_opengl_skeleton.py
Created September 3, 2022 19:56 — forked from kiwwisk/sdl2_opengl_skeleton.py
Skeleton for SDL2/OpenGL application in Python 3. Game loop has fixed time step, rendering is going at full speed.
#
# Skeleton for SDL2/OpenGL application in Python
# with fixed logic time step, rendering is going still at full speed.
#
# To turn debug logging messages on, run with -v parameter:
# python <script_name.py> -v
#
import argparse
import logging
@8Observer8
8Observer8 / makefile
Created March 13, 2022 19:03
MinGW makefile for SDL2 and Box2D
CC = g++
INC = -I"E:\Libs\SDL2-2.0.12-mingw-32bit\include" -I"E:\Libs\box2d-2.4.0-mingw-32bit\include"
LIB = -L"E:\Libs\SDL2-2.0.12-mingw-32bit\lib" -L"E:\Libs\box2d-2.4.0-mingw-32bit\lib"
FLAGS = -c
all: main.o
$(CC) main.o $(LIB) -lSDL2.dll -lbox2d -o app
main.o: main.cpp
$(CC) $(FLAGS) $(INC) main.cpp
@8Observer8
8Observer8 / Float32_Base64_Encoding_Decoding.js
Created December 13, 2021 22:19 — forked from sketchpunk/Float32_Base64_Encoding_Decoding.js
Encode Float32Array to base64 , then decode it back
let verts = new Float32Array( [ 0, 2, 0, -1, 0.2, 0, 1, 0.2, 0 ] );
let v = base64_test( verts );
function base64_test( fary ){
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ENCODING TEST
console.log("Origin Data", fary );
let uint = new Uint8Array( fary.buffer );
console.log( "Convert F32 to Uint8 : Byte Length Test", fary.length * 4, uint.length );
@8Observer8
8Observer8 / SfmlNetAndOpenTK4DotNetCore.cs
Created June 14, 2020 10:32
The example shows how to use OpenGL 3.1 graphics inside SFML.NET window using OpenTK4 and .NET Core
using SFML.Window;
using SFML.Graphics;
using SFML.System;
using OpenToolkit.Graphics.OpenGL;
using OpenToolkit.Windowing.Desktop;
using System.IO;
using System;
namespace SfmlNetAndOpenTK4DotNetCore
{
@8Observer8
8Observer8 / Program.cs
Last active June 14, 2020 10:08
ColoredTriangleVaoOpenTK4OpenGL31 (Added shaders to Program.cs)
using OpenToolkit.Graphics.OpenGL;
using OpenToolkit.Windowing.Desktop;
using OpenToolkit.Mathematics;
using System.IO;
using System;
namespace ColoredTriangleVaoOpenTK4OpenGL31
{
class Program
{
@8Observer8
8Observer8 / Main.py
Created May 27, 2020 20:18
Port a console app example to PySide2 from the theme: https://stackoverflow.com/questions/10641055
from PySide2 import QtCore
class Console(QtCore.QObject):
def __init__(self, msg):
super(Console, self).__init__()
self.msg = msg
self.timer = QtCore.QBasicTimer()
self.timer.start(500, self)
grid = [
[" ", " ", " "],
[" ", " ", " "],
[" ", " ", " "]]
def is_winner(player):
return (
# Rows
grid[0][0] == player and grid[0][1] == player and grid[0][2] == player or
grid[1][0] == player and grid[1][1] == player and grid[1][2] == player or
import unittest
from grid import grid, is_winner
# python -m unittest discover tests
class TestGridWinner(unittest.TestCase):
def test_first_row_is_winner(self):
grid[0][0] = "x"
grid[0][1] = "x"
@8Observer8
8Observer8 / main.py
Last active February 23, 2020 14:25
Exception in OOP version of First Triangle in Python, OpenGL 1.5, GLFW
import glfw
from OpenGL.GL import *
import numpy as np
class Window:
def __init__(self, width: int, height: int, title: str):
# Initializing glfw library
if not glfw.init():
raise Exception("glfw can not be initialized!")