Skip to content

Instantly share code, notes, and snippets.

static void test_tilde_api(TB_System system, TB_Arch arch, const char* file_path)
{
TB_Arena arena = {};
tb_arena_create(&arena, 16 * 1024 * 1024);
TB_FeatureSet features = {};
TB_Module* module = tb_module_create(
arch,
system,
@code-disaster
code-disaster / win32_console_out.cpp
Last active November 2, 2021 08:21
An existing console printing *something* for windowed applications
// To output stderr/stdout to an existing console for windowed applications. It works.
// Sometimes. Even with UTF-8 and terminal colors, if you are lucky.
void conout_initialize()
{
if (!IsDebuggerPresent()) {
// Win32 console output is awful! This tries to rewire stdout so that we
// get to see *something* in the CMD prompt.
/*
A hack found at stackoverflow.com to raise a compiler warning if a non-boolean
expression is silently converted to bool in conditional statements.
*/
struct not_a_bool {};
template< typename T >
not_a_bool ERROR_CONDITIONAL_EXPRESSION_IS_NOT_BOOL(T /*value*/)
{
@code-disaster
code-disaster / fullscreen-quad-libgdx.glsl
Created August 3, 2016 07:36
simple scanline shader
/* post-fx pass by blending a solid white fullscreen quad, no texture required */
/*uniform*/ float fmin = 0.7;
void main(void)
{
float fmod = mod(gl_FragCoord.y, 2.0);
float fstep = fmin + (1.0 - fmin) * fmod;
gl_FragColor = vec4(1.0, 1.0, 1.0, fstep);
}
@code-disaster
code-disaster / description.md
Last active February 10, 2016 12:18
Shader bug(?) on Windows w/Intel GPU

This is a custom shader we are using right now to render flat shaded geometry into a deferred render buffer. Please ignore the custom made stuff (#pragma), it shouldn't be of relevance in this case.

Now, this shader works. Most of the time.

On some particular systems, namely a Surface Pro 4 and a Surface Pro 3 with Intel Iris 540 / HD 5000 GPUs, both running Windows 10, the following "optimization" breaks rendering.

  • vertex shader:
    • line 13: remove unused out attribute, out vec3 v_position;
    • line 20: change into local var, vec3 _position = a_position;
  • line 23: change to use local var, vec4 position = vec4(_position, 1.0);
@code-disaster
code-disaster / VoxelFileReader.java
Created October 23, 2015 22:56
MagicaVoxel file reader
package com.robotality.game.graphics.voxel;
import com.badlogic.gdx.files.FileHandle;
import com.robotality.game.GameRuntimeException;
import java.io.BufferedInputStream;
import java.io.IOException;
class VoxelFileReader {