Skip to content

Instantly share code, notes, and snippets.

View vaiorabbit's full-sized avatar
🎮
busy playing video games

vaiorabbit

🎮
busy playing video games
View GitHub Profile
@vaiorabbit
vaiorabbit / test.rb
Created January 4, 2024 17:01
Testing Ruby bindings for Blend2D ( https://blend2d.com )
require_relative '../lib/blend2d.rb'
require_relative 'util'
include Blend2D
if __FILE__ == $PROGRAM_NAME
load_blend2d_lib()
img = BLImageCore.new
r = blImageInitAs(img.pointer, 480, 480, BL_FORMAT_PRGB32)
require 'raylib'
include Raylib
####################################################################################################
class Game
attr_reader :high_score, :config, :current_score, :state_timer
STATES = [:Ready, :Playing, :GameOver]
/*
[Usage]
$ clang -I`brew --prefix mruby`/include -Iraylib/include raylib_mrb.c `brew --prefix mruby`/lib/libmruby.a raylib/lib/libraylib.a -lm -framework IOKit -framework Cocoa -framework OpenGL -o raylib_mrb
$ ./raylib_mrb
*/
#include <mruby.h>
#include <mruby/class.h>
#include <mruby/compile.h>
#include <mruby/data.h>
#include <mruby/string.h>
require 'uri'
google_link = ARGV[0]
encoded_url = /.+url=(.+)&.+/.match(google_link)[1]
decoded_url = URI.decode_www_form(encoded_url)
puts decoded_url
require 'ffi'
module UI
extend FFI::Library
class InitOptions < FFI::Struct
layout(
:Size, :size_t
)
end
# CMakeLists for pocketlang (https://github.com/ThakeeNathees/pocketlang)
# - put this file in cli/ directory
file( GLOB POCKETCLI_HDRS "${CMAKE_CURRENT_LIST_DIR}/*.h" )
file( GLOB POCKETCLI_SRCS "${CMAKE_CURRENT_LIST_DIR}/*.c" )
add_executable(pocketcli ${POCKETCLI_SRCS} ${POCKETCLI_HDRS})
target_include_directories(pocketcli
PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../src/include
)
@vaiorabbit
vaiorabbit / TLSLeakCheck.cpp
Last active March 27, 2021 12:41
SDL memory leak check (tested on v2.0.14)
// Ref.: https://stackoverflow.com/questions/4790564/finding-memory-leaks-in-a-c-application-with-visual-studio
#include "windows.h"
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#include <SDL.h>
class Application
{
public:
{
// Place your GLOBAL snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
// "Print to console": {
// "scope": "javascript,typescript",
# coding: utf-8
#
# Ref.: bgfx/examples/06-bump/bump.cpp
# https://github.com/vaiorabbit/sdl2-bindings
#
require 'rmath3d/rmath3d'
require 'sdl2'
require_relative '../../bindings/ruby/bgfx.rb'
require_relative './logo.rb'
require_relative './utils.rb'
# coding: utf-8
#
# Ref.: bgfx/examples/06-bump/bump.cpp
# https://github.com/vaiorabbit/ruby-opengl/tree/master/sample
#
require 'rmath3d/rmath3d'
require 'opengl'
require 'glfw'
require_relative '../../bindings/ruby/bgfx.rb'
require_relative './utils.rb'