Skip to content

Instantly share code, notes, and snippets.

@FelixK15
FelixK15 / find_visual_studio_installation.bat
Last active June 18, 2018 11:14
Find Visual Studio installation path with visual studio
@echo off
echo Searching for Visual Studio installation...
setlocal enableextensions enabledelayedexpansion
set FOUND_PATH=0
set VS_PATH=
::check whether this is 64bit windows or not
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OS=32BIT || set OS=64BIT
IF %OS%==64BIT set REG_FOLDER=HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7
@FelixK15
FelixK15 / print_stacktrace_win32.c
Created August 15, 2016 20:30
Print Stacktrace on Win32
//once on init
HANDLE process = GetCurrentProcess();
SymInitialize( process, NULL, TRUE );
//create stacktrace
HANDLE process = GetCurrentProcess();
PVOID addresses[256];
unsigned short framesCaptures = CaptureStackBackTrace(1, 256, addresses, 0);
for (unsigned short i = 0; i < framesCaptures; ++i)
@FelixK15
FelixK15 / shader_processing_thoughts.txt
Created August 15, 2016 20:31
Shader processing (non API specific)
Shader file (e.g. vertex shader):
----
float4 TransformVertex(in float4 pos : POSITION,
in float2 uvIn : TEXCOORD0,
in float4x4 worldMatrix : WORLDMATRIX,
in float4x4 projMatrix : PROJECTIONMATRIX,
in float4x4 viewMatrix : VIEWMATRIX,
out float2 uvOut : TEXCOORD0)
{
@FelixK15
FelixK15 / get_opengl_extension.c
Created August 15, 2016 20:32
OpenGL get extension function
//kglGetProcAddress = (wglGetProcAddress/glxGetProcAddress/eglGetProcAddress)
/*********************************************************************************/
/* - p_GLExtensionFunctionName = The name of the function whose pointer you want to retrieve. e.g. glGenVertexArray)
- p_ReviewBoardAbbreveration = Abbreveration of the review board that implemented the extension (e.g. ARB, KHR, INTEL, etc.)
- p_Buffer = An external buffer we can write stuff into
*/
char* ConstructGLExtensionFunctionString(const char* p_GLExtensionFunctionName,
@FelixK15
FelixK15 / msvc_cmd.bat
Created August 15, 2016 20:32
Launch command prompt with msvc tools
cmd.exe /K "CALL "%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\vcvarsall.bat""
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
bool isDebuggerAttached()
{
char buf[128] = {};
bool debugger_present = false;
@FelixK15
FelixK15 / .clang_format
Last active July 30, 2019 20:07
.clang_format for private projects
# General
TabWidth: 4
Language: Cpp
BreakStringLiterals: true
PointerAlignment: Left
NamespaceIndentation: All
Cpp11BracedListStyle: false
# Spacing
SpaceAfterCStyleCast: false
@FelixK15
FelixK15 / find_microcode_in_registry.cpp
Last active August 22, 2024 09:27
Read microcode version using win32 registry
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdint.h>
#pragma comment(lib, "Advapi32.lib")
bool tryToFindMicrocodeVersionInRegistry(uint32_t* pOutMicrocodeVersion)
{
bool success = false;
HKEY pProcessorRegistryKey = nullptr;