Skip to content

Instantly share code, notes, and snippets.

@Noxalus
Noxalus / gist:6466060
Created September 6, 2013 16:10
Lidgren cut the disconnect string.
NetIncomingMessage incMsg;
NetConnection sender;
while ((incMsg = server.ReadMessage()) != null)
{
sender = incMsg.SenderConnection;
Client t_client = clients.GetClientFromConnection(sender);
switch (incMsg.MessageType)
{
case NetIncomingMessageType.StatusChanged:
if (sender.Status == NetConnectionStatus.Connected)
@Noxalus
Noxalus / Refraction.fx
Created January 2, 2014 00:31
HLSL refraction shader.
float4x4 World;
float4x4 View;
float4x4 Projection;
Texture2D Texture;
float4 ClippingPlane;
sampler2D SampleType = sampler_state
{
Texture = <Texture>;
MinFilter = LINEAR;
@Noxalus
Noxalus / gist:8213607
Created January 2, 2014 01:14
DrawRefraction C# method.
private void DrawRefractionMap()
{
_device.SetRenderTarget(_refractionRenderTarget);
_device.Clear(ClearOptions.Target, Color.CornflowerBlue, 1.0f, 1);
DrawSkybox(_viewMatrix, _projectionMatrix, _cameraPosition);
DrawTerrain(_refractionEffect, _viewMatrix);
_device.SetRenderTarget(null);
@Noxalus
Noxalus / main.cpp
Created March 25, 2014 17:27
Multiple camera rendering problem with render target
#include "minko/Minko.hpp"
#include "minko/MinkoSDL.hpp"
#include "minko/MinkoPNG.hpp"
using namespace minko;
using namespace minko::math;
using namespace minko::component;
const uint WINDOW_WIDTH = 800;
const uint WINDOW_HEIGHT = 600;
@Noxalus
Noxalus / gist:0b991c99cc122b031dd5
Created May 28, 2014 08:48
Add UIWebView to SDLwindow*
SDLwindow* sdlWindow = getWindow();
SDL_SysWMinfo info;
window* window;
SDL_VERSION(&info.version);
if (SDL_GetWindowWMInfo(sdlWindow, &info))
{
window = (info.info.uikit.window);
@Noxalus
Noxalus / gist:37a4e7a40ac70037f6b2
Last active August 29, 2015 14:14
Take 4 random values in an array with no duplicate entry
<?php
$array = array(
'42' => 'COUCOU1',
'87' => 'COUCOU2',
'38' => 'COUCOU3',
'98' => 'COUCOU4',
'74' => 'COUCOU5',
'16' => 'COUCOU6'
);
@Noxalus
Noxalus / gist:a36e52f62cb45585cdf7
Last active August 29, 2015 14:21
OpenCV draw a simple circle
void proccessImage(std::vector<unsigned char>& imageData, int width, int height)
{
// Create cv::Mat from std::vector<unsigned char>
Mat src(width, height, CV_8UC4, const_cast<unsigned char*>(imageData.data()));
Mat final;
// Draw a circle at position (300, 200) with a radius of 30
cv::Point center(300, 200);
circle(src, center, 30.f, CV_RGB(0, 0, 255), 3, 8, 0);
@Noxalus
Noxalus / gist:a51af67ba868730ae3bc
Created May 26, 2015 17:13
Use GaussianBlur with OpenCV
void proccessImage(std::vector<unsigned char>& imageData, int width, int height)
{
Mat src(width, height, CV_8UC4, const_cast<unsigned char*>(imageData.data()));
Mat src_gray, final;
// Convert the source image to gray
cvtColor(src, src_gray, CV_BGRA2GRAY);
// Apply gaussian blur on the gray image
GaussianBlur(src_gray, src_gray, cv::Size(9, 9), 2, 2);
@Noxalus
Noxalus / gist:18de2603812e31e687de
Created May 29, 2015 08:41
Detect red circles with OpenCV 2.4.11
Mat src(height, width, CV_8UC4, const_cast<unsigned char*>(imageData.data()));
Mat src_gray, hsv, final;
// Create the final image to display
cvtColor(src, final, CV_BGRA2RGBA);
// Remove useless alpha canal
cvtColor(src, src, CV_BGRA2BGR);
// Convert image to HSV
@Noxalus
Noxalus / test.cpp
Last active May 23, 2017 23:35
GearVR intergration with SDL
// Setup the Java references.
ovrJava java;
auto jniEnv = (JNIEnv*)SDL_AndroidGetJNIEnv();
JavaVM* javaVm;
jniEnv->GetJavaVM(&javaVm);
auto activity = (jobject)SDL_AndroidGetActivity();