Skip to content

Instantly share code, notes, and snippets.

@dpasca
dpasca / gist:10142521
Created April 8, 2014 15:26
indicized sphere from cylinder
//--------------------------
// setup geometry
const static u_int NDIV_PHI = 20;
const static u_int NDIV_THE = 20;
mPosBase.reserve( NDIV_PHI * NDIV_THE );
auto &geom = *moBaseMesh->mpGeom;
geom.mNor.reserve( mPosBase.size() );
@dpasca
dpasca / DArray.h
Last active August 29, 2015 14:20
template <class _T, size_t _SIZE>
class DArray
{
U32 mBuff[ (sizeof(_T) * _SIZE + 3) / 4 ];
size_t mSize = 0;
#if defined(_DEBUG) || defined(DEBUG)
_T *mpDbgPtr = (_T *)mBuff;
#endif
public:
@dpasca
dpasca / event_sample.cpp
Created August 17, 2015 08:26
Event recording
// sure cost
void GameMain::UIInputTouchBegan( void *id, float x, float y )
{
DASSERT( !mEventLock ); mEventLock = true;
mEventData.WriteValue<u_int>( EVT_TOUCH_BEGAN );
mEventData.WriteValue<void *>( id );
mEventData.WriteValue<float>( x );
mEventData.WriteValue<float>( y );
mEventLock = false;
}
//==================================================================
/// 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();