Skip to content

Instantly share code, notes, and snippets.

//==================================================================
/// VoxelList.cpp
///
/// Created by Davide Pasca - 2012/7/4
/// See the file "license.txt" that comes with this project for
/// copyright info.
//==================================================================
#include "stdafx.h"
#include "VoxelList.h"
@dpasca
dpasca / gist:3332652
Created August 12, 2012 16:28
Windows OpenGL 3.0 context creation to enable multi-sampling
//==================================================================
class DummyWin32OGLContext
{
HWND mHWND;
HGLRC mHGLRC;
public:
PFNWGLCHOOSEPIXELFORMATARBPROC mpWglChoosePixelFormatARB;
PFNWGLCREATECONTEXTATTRIBSARBPROC mpWglCreateContextAttribsARB;
@dpasca
dpasca / .vimrc
Created September 27, 2012 08:30
Vim configuration
set runtimepath=$HOME/Dropbox/Settings/vimfiles,$VIM,$VIMRUNTIME
source $HOME/Dropbox/Settings/vimrc
//====================================
// with exception handling
//====================================
BitMap *LoadBMP( const char *fname )
{
File file(fname);
U32 id = file.ReadVal();
int w = file.ReadVal();
int h = file.ReadVal();
int bpp = file.ReadVal();
@dpasca
dpasca / gist:4231099
Created December 7, 2012 06:01
Compact normals
//==================================================================
#if defined(DE3_NORMAL_SHORT)
//==================================================================
typedef Vec4<short> Normal;
static const u_int GL_NOR_TYPE = GL_SHORT;
static const u_int GL_NOR_NORMALIZED = GL_TRUE;
static const u_int GL_NOR_STRIDE = sizeof(short) * 4;
DFORCEINLINE Normal MakeNormal( float xf, float yf, float zf )
@dpasca
dpasca / gist:4242855
Created December 9, 2012 01:02
Some UI logic
// are we waiting for the introduction to go away ?
if ( mStater[STATE_IN_COMM_INTRODUCTION].IsActive() )
{
if NOT( moCharDlgWin->IsActive() ) // is finally the dialog gone ?
{
mStater[STATE_IN_COMM_INTRODUCTION].Deactivate(); // the wait has ended
updateHomeButtonsState(); // set the fighters button on hover
}
}
else
@dpasca
dpasca / gist:4332700
Created December 18, 2012 22:32
Vector with objects ownership
//==================================================================
template <class _T>
class VecOwn
{
DVec<_T> mVec;
public:
~VecOwn()
{
clear_free();
//==================================================================
class RandPool
{
DVec<U32> mVals;
size_t mIterIdx;
public:
RandPool( size_t size, U32 seed=0 )
: mIterIdx(0)
{
namespace DGLUT
{
//==================================================================
void CheckGLErr( const char *pFileName, int line )
{
GLenum err = glGetError();
while (err != GL_NO_ERROR)
{
const char *pErr = NULL;
// "const auto" is just too common not to have an alias
#define c_auto const auto
class Type; // forward declaration if possible
//==================================================================
class ClassName
{
size_t mMember = 0; // 'm' prefix for member variable
U8 *mpPointer {}; // 'mp' prefix for member pointer