Skip to content

Instantly share code, notes, and snippets.

@Miouyouyou
Miouyouyou / Linux_DRM_OpenGLES.c
Last active April 18, 2024 07:34
An example, inspired by Rob Clark "kmscube.c" that uses Linux Direct Rendering Manager ( DRM ) and EGL to create an OpenGL ES 2 context. This is a standalone example, that just clears the screen with a blueish color. Usable with Rockchip DRM drivers and Mali Wayland/DRM userspace drivers.
// gcc -o drmgl Linux_DRM_OpenGLES.c `pkg-config --cflags --libs libdrm` -lgbm -lEGL -lGLESv2
/*
* Copyright (c) 2012 Arvin Schnell <arvin.schnell@gmail.com>
* Copyright (c) 2012 Rob Clark <rob@ti.com>
* Copyright (c) 2017 Miouyouyou <Myy> <myy@miouyouyou.fr>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
@Miouyouyou
Miouyouyou / init_window.c
Created December 15, 2016 07:55
A very ugly Wayland EGL OpenGL example
// gcc -o test init_window.c -I. -lwayland-client -lwayland-server -lwayland-client-protocol -lwayland-egl -lEGL -lGLESv2
#include <wayland-client.h>
#include <wayland-server.h>
#include <wayland-client-protocol.h>
#include <wayland-egl.h> // Wayland EGL MUST be included before EGL headers
#include "init_window.h"
#include "log.h"
#include <string.h>
@Miouyouyou
Miouyouyou / Makefile
Last active December 24, 2023 10:14
Sample Makefile for cross-compiled ARM Linux kernel module
# Set this variable with the path to your kernel.
# Don't use /usr/src/linux if you're cross-compiling...
MYY_KERNEL_DIR ?= ../linux
# If you're compiling for ARM64, this will be arm64
ARCH ?= arm
# This is the prefix attached to your cross-compiling gcc/ld/... tools
# In my case, gcc is armv7a-hardfloat-linux-gnueabi-gcc
# If you've installed cross-compiling tools and don't know your
@Miouyouyou
Miouyouyou / drm-prime-dumb-kms.c
Last active October 24, 2023 06:28
Simple example showing how to use DRM to : allocate a Dumb buffer on the GPU, use it as a framebuffer, use this CRTC on the currently connected screen (expecting 1 connected screen), export the buffer, reimport it implicitly with mmap and write in it.
// This will works on Embedded GPU that implements .gem_prime_mmap like Rockchip ones.
// This will fail on most DRM drivers for GPU with dedicated memory as they tend to NOT implement .gem_prime_mmap.
#include <stdio.h>
#include <libdrm/drm.h>
#include <stdint.h>
#include <sys/mman.h>
#include <string.h>
@Miouyouyou
Miouyouyou / Documentation.md
Last active May 14, 2023 15:42
Boot on SDCard, mount NVMe root partition and use it for the whole system, on a NanoPC T4

Moving most of the system (but not the kernel) onto a NVME disk

This document describes how to make the system :

  • boot on a SDCARD
  • load the kernel from the SDCARD
  • mount a NVMe partition as /
  • use / for the whole system and applications

In this document folder and directory mean the same thing.

@Miouyouyou
Miouyouyou / codepoint_to_utf8_seq.c
Last active May 2, 2023 17:28
A very dull UTF32 codepoint to UTF8 sequence converter (UTF-32 to UTF-8)
/* UTF-32 codepoint to UTF-8 sequence converter by Miouyouyou
*
* To the extent possible under law, the person who associated CC0 with
* this content has waived all copyright and related or neighboring
* rights to this content.
*
* You should have received a copy of the CC0 legalcode along with this
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*
*/
@Miouyouyou
Miouyouyou / steam-idler.c
Last active September 14, 2022 16:59
SteamIdler
/* A really dumb Steam Idler in C for Linux systems.
* Might work on Mac OS too but I never tested it.
*
* /!\ You need to have Steam currently running on the computer
* ⁻⁻⁻ executing this software.
*
* Short version :
* gcc -o SteamIdler steam-idler.c libsteam_api.so
*
* Long version :
@Miouyouyou
Miouyouyou / elf_linker.c
Last active March 23, 2022 10:37
Quick and very dirty ARM64 ( AARCH64 ) ELF linker
#include <stdint.h>
#include <elf.h>
#include <sections/data.h>
#include <string.h>
#include <assert.h>
#define INSTRUCTION_SIZE 9*4
#define DATA_SIZE 16
@Miouyouyou
Miouyouyou / command.sh
Created April 13, 2021 21:24
armbian build command
sudo bash ./compile.sh docker REPOSITORY_INSTALL="u-boot,kernel,armbian-config,armbian-firmware" KERNEL_ONLY=no KERNEL_CONFIGURE=no BOARD=nanopct4 KERNEL_TARGET=current BRANCH=current BUILD_DESKTOP=yes DESKTOP_ENVIRONMENT="xfce" RELEASE="focal" DESKTOP_ENVIRONMENT_CONFIG_NAME=config_base DESKTOP_APPGROUPS_SELECTED="browsers editors programming 3dsupport"
@Miouyouyou
Miouyouyou / gltf_to_glb.gd
Last active March 11, 2021 10:13
Convert GLTF to GLB files in Godot ( GDScript )
extends Node
func align_buffer_on_4_bytes(buffer:PoolByteArray):
var buffer_size:int = buffer.size()
for i in range(0, buffer_size & 3):
buffer.append(0)
func convert_gltf_to_glb_working(gltf_filepath:String, glb_out_filepath:String):
var f:File = File.new()
var err_ret = f.open(gltf_filepath, File.READ)