Skip to content

Instantly share code, notes, and snippets.

View newvertex's full-sized avatar
🌵

newvertex newvertex

🌵
View GitHub Profile
@newvertex
newvertex / symlink.md
Last active February 3, 2022 21:52
Create Symlink directory in windows
@newvertex
newvertex / render_text.c
Last active January 14, 2022 22:36
Render Persian RTL Text in SDL2 with SDL_ttf
SDL_Texture *renderText(const char *text, bool isUTF8, const char *fontPath, SDL_Color color, int fontSize, SDL_Renderer *renderer)
{
TTF_Font *font = TTF_OpenFont(fontPath, fontSize);
if (font == NULL)
{
//logErrorSDL("Failed to Open Font!");
return NULL;
}
SDL_Surface *surface;
@newvertex
newvertex / glfw_opengl_window.cpp
Created September 9, 2021 19:23
basic GLFW window with opengl context
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
#include <glad/glad.h>
#include <iostream>
constexpr float R = 0.2f;
constexpr float G = 0.4f;
constexpr float B = 0.9f;
constexpr float A = 1.0f;
@newvertex
newvertex / sdl_opengl_window.cpp
Created September 9, 2021 18:37
basic SDL window with opengl context
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
#include <iostream>
constexpr float R = 0.2f;
constexpr float G = 0.4f;
constexpr float B = 0.9f;
constexpr float A = 1.0f;
@newvertex
newvertex / sfml_opengl_window.cpp
Created September 9, 2021 14:32
basic SFML window with opengl context
#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#include <iostream>
constexpr float R = 0.2f;
constexpr float G = 0.4f;
constexpr float B = 0.9f;
constexpr float A = 1.0f;
@newvertex
newvertex / opengl_triangle.rs
Created August 5, 2021 12:54
Basic triangle in Rust lang with GLFW and OpenGL
use std::convert::TryInto;
use glfw;
use glfw::Context;
use gl;
const WIDTH: u32 = 480;
const HEIGHT: u32 = 320;
const TITLE: &str = "Hello From OpenGL World!";
@newvertex
newvertex / glfw_opengl.rs
Created August 3, 2021 15:03
Basic setup OpenGL with GLFW in Rust lang
// Cargo.toml
// ------------------------
// [dependencies]
// glfw = "0.41.0"
// gl = "0.14.0"
use glfw::{self, Context};
use gl;
const WIDTH: u32 = 480;
@newvertex
newvertex / gl_get_string.rs
Last active August 3, 2021 15:00
Simple Helper function to get string (&str) from *const u8 for using with gl in Rust Lang
// get OpenGL version in rust
fn gl_get_string<'a>(name: gl::types::GLenum) -> &'a str {
let v: *const u8 = unsafe { gl::GetString(name) };
let v: &std::ffi::CStr = unsafe { std::ffi::CStr::from_ptr(v as *const i8) };
v.to_str().unwrap()
}
@newvertex
newvertex / sfml_basic.rs
Created August 3, 2021 14:54
Basic setup for SFML in Rust lang
// Cargo.toml
// ------------------------
// [dependencies]
// # on Windows OS don't forget to copy native CSFML *.dll & *.lib files next to your project Cargo.toml file
// sfml = "0.16.0"
// I did not find any way to use OpenGL with SFML,
// if you know a way I will be happy to hear it ;-)
// But you can still use the library with the same template
@newvertex
newvertex / sdl_opengl.rs
Created August 3, 2021 14:12
Basic setup OpenGL with SDL2 in Rust lang
// Cargo.toml
// -----------------------
// [dependencies]
// gl = "0.14.0"
// [dependencies.sdl2]
// version = "0.34.5"
// features = ["bundled", "static-link"]
use std::thread;