Skip to content

Instantly share code, notes, and snippets.

Mārtiņš Možeiko mmozeiko

  • San Jose, CA
Block or report user

Report or block mmozeiko

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mmozeiko
mmozeiko / floor.c
Last active Nov 7, 2019
various floor functions with SSE1 or SSE2
View floor.c
// various SSE1 and SSE2 floor function for float
// assumes only normal input values
// does not handle NAN or INF - they may or may not work
// only guarantee is that 0, subnormal or normal float values will work
#include <emmintrin.h>
#ifdef _MSC_VER
#include <intrin.h>
#define NOINLINE __declspec(noinline)
@mmozeiko
mmozeiko / main.cpp
Created Feb 13, 2019
Windows drag & drop example
View main.cpp
/*
Minimal Drag and Drop Application for Windows
Copright (C) Alexandre LHUILLIER - 2019
===
This application creates an application window and a console window.
Whenever you drag a file or a set of files from the Windows explorer
to the application window, the absolute paths of the dropped files
are printed in the console window.
@mmozeiko
mmozeiko / test.c
Last active Oct 8, 2019
gtk widget from x11 window
View test.c
// gcc test.c `pkg-config --cflags --libs gtk+-3.0 gdk-3.0` -lX11 && ./a.out
#include <X11/Xlib.h>
#include <unistd.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
static void my_gtk_realize(GtkWidget* widget, gpointer user)
@mmozeiko
mmozeiko / webcam_capture.c
Created Aug 28, 2019
Capture webcam device with Media Foundation API
View webcam_capture.c
#define COBJMACROS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mfapi.h>
#include <mfidl.h>
#include <mfreadwrite.h>
#include <stdio.h>
#include <intrin.h>
@mmozeiko
mmozeiko / win32_crt_float.cpp
Last active Sep 13, 2019
Visual C/C++ CRT functionality
View win32_crt_float.cpp
extern "C"
{
int _fltused;
#ifdef _M_IX86 // following functions are needed only for 32-bit architecture
__declspec(naked) void _ftol2()
{
__asm
{
@mmozeiko
mmozeiko / build.bat
Created Dec 18, 2016
build.bat with caching
View build.bat
@echo off
setlocal EnableDelayedExpansion
set ARCH=amd64
set BUILD_CACHE=%~dp0\_build_cache.cmd
if exist "!BUILD_CACHE!" (
call "!BUILD_CACHE!"
) else (
call "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" !ARCH!
@mmozeiko
mmozeiko / raspbian_buster.txt
Last active Jul 20, 2019
OpenGL info on Raspberry Pi 4
View raspbian_buster.txt
EGL_VENDOR = Mesa Project
EGL_VERSION = 1.4
EGL_CLIENT_APIS = OpenGL OpenGL_ES
EGL_EXTENSIONS = EGL_EXT_buffer_age EGL_EXT_image_dma_buf_import EGL_EXT_image_dma_buf_import_modifiers EGL_KHR_cl_event2 EGL_KHR_config_attribs EGL_KHR_create_context EGL_KHR_create_context_no_error EGL_KHR_fence_sync EGL_KHR_get_all_proc_addresses EGL_KHR_gl_colorspace EGL_KHR_gl_renderbuffer_image EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_3D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_no_config_context EGL_KHR_reusable_sync EGL_KHR_surfaceless_context EGL_EXT_pixel_format_float EGL_KHR_wait_sync EGL_MESA_configless_context EGL_MESA_drm_image EGL_MESA_image_dma_buf_export
// GLES API
GL_VENDOR = Broadcom
GL_RENDERER = V3D 4.2
GL_VERSION = OpenGL ES 3.0 Mesa 19.1.2
@mmozeiko
mmozeiko / win32_handmade.cpp
Created Dec 13, 2014
win32_handmade.cpp with WASAPI from Day 19
View win32_handmade.cpp
/* ========================================================================
$File: $
$Date: $
$Revision: $
$Creator: Casey Muratori $
$Notice: (C) Copyright 2014 by Molly Rocket, Inc. All Rights Reserved. $
======================================================================== */
/*
TODO(casey): THIS IS NOT A FINAL PLATFORM LAYER!!!
@mmozeiko
mmozeiko / test.c
Last active Jun 25, 2019
SetForegroundWindow
View test.c
#include <windows.h>
#include <stdio.h>
LRESULT CALLBACK WindowProc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
if (msg == WM_TIMER)
{
printf("press SPACE now\n");
DWORD tid = GetWindowThreadProcessId(wnd, NULL);
@mmozeiko
mmozeiko / test.c
Last active Jun 4, 2019
switch vs computed goto
View test.c
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#define HALT 0
#define LOAD 1
#define INC 2
#define DEC 3
#define ADD_7 4
#define SUB_7 5
You can’t perform that action at this time.