viernes, 12 de diciembre de 2014

Iterator debug level

Today I got this link error: LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL' WTF? Hopefully someone created StackOverflow: http://stackoverflow.com/questions/7668200/error-lnk2038-mismatch-detected-for-iterator-debug-level-value-0-doesnt Another happy ending story :)

jueves, 11 de diciembre de 2014

A waste of time (Screen coordinates to world coordinates)

Today I wasted some time by doing this simple task. I was following this article: http://www.mvps.org/directx/articles/rayproj.htm There are several odd things here: void calcRay(int x,int y,D3DVECTOR &p1,D3DVECTOR &p2) { float dx,dy; D3DMATRIX invMatrix,viewMatrix; dx=tanf(FOV*0.5f)*(x/WIDTH_DIV_2-1.0f)/ASPECT; dy=tanf(FOV*0.5f)*(1.0f-y/HEIGHT_DIV_2); lpDevice->GetTransform(D3DTRANSFORMSTATE_VIEW,&viewMatrix); D3DMath_MatrixInvert(invMatrix,viewMatrix); p1=D3DVECTOR(dx*NEAR,dy*NEAR,NEAR); p2=D3DVECTOR(dx*FAR,dy*FAR,FAR); D3DMath_VectorMatrixMultiply(p1,p1,invMatrix); D3DMath_VectorMatrixMultiply(p2,p2,invMatrix); } Basically it's about the tanf and the ASPECT division: It's supposed I want to get a value between 0..1 in dx and dy, but tanf was messing the stuff... I think the aspect is assuming the width is bigger than height, which is not my case, since I am developing for mobile phones... Well, now it's working so it's time to relax... :D

lunes, 1 de diciembre de 2014

Java Style Enumerations in C++

Here you have an interesting discussion about Java Style Enumerations in C++, by Insomaniac's developer Ron Pieket:

http://www.itshouldjustworktm.com/?p=32

domingo, 30 de noviembre de 2014

Bitsquid's game development blog

This is a really nice blog about videogame development, I totally recommend it:

http://bitsquid.blogspot.com.es/

sábado, 15 de marzo de 2014

Forward declarations with namespaces :S

To forward declare class type a in a namespace ns1 (ns1::a):
namespace ns1
{
    class a;
}

For nested namespaces: ns1::ns2::a:

namespace ns1
{
     namespace ns2
     {
             class a;
     } }

lunes, 13 de enero de 2014

Compile-Time Assertions

From Modern C++ Design, S. Alexandrescu

It's a technique that relies in the fact that a zero-length array is ilegal:

#define STATIC_CHECK(expr) { char unnamed[(expr) ? 1 : 0]; }

To safe_reinterpret_cast(From from)
{
STATIC_CHECK(sizeof(From) <= sizeof(To));
return reinterpret_cast<To>(from);
}
...
void* somePointer = ...;
char c = safe_reinterpret_cast<char>(somePointer);
template <class To, class From>
Cons: The error message you receive is not terribly informative "Cannot create array of size zero"