• Create Account

We're offering banner ads on our site from just \$5!

Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!

# Naked Shooter

Member Since 05 Sep 2007
Offline Last Active Oct 23 2012 09:50 PM

### Need to obtain frustum corners coordinates

21 October 2012 - 03:39 PM

Hi. I'm trying to get the frustum vertices by using the perspective projection matrix's inverse. I'm trying to take a cube with the vertices { (-1,-1,-1), (1,-1,-1) ... } and multiply each vertex by the inverse of the perspective matrix, hoping to get the frustum. This isn't working, however. I am aware that there's a lighthouse3d tutorial, and I just might bite the bullet and go through it, but I'm just curious why this isn't working.

```glm::mat4 projection(0);
glm::mat4 projectionInv(0);
//the frustum in normalized coordinates
vector<glm::vec4> NDCCube;
NDCCube.push_back(glm::vec4(-1.0f, -1.0f, -1.0f, 1.0f));
NDCCube.push_back(glm::vec4(1.0f, -1.0f, -1.0f, 1.0f));
NDCCube.push_back(glm::vec4(1.0f, -1.0f, 1.0f, -0.0f));
NDCCube.push_back(glm::vec4(-1.0f, -1.0f, 1.0f, -0.0f));
NDCCube.push_back(glm::vec4(-1.0f, 1.0f, -1.0f, 1.0f));
NDCCube.push_back(glm::vec4(1.0f, 1.0f, -1.0f, 1.0f));
NDCCube.push_back(glm::vec4(1.0f, 1.0f, 1.0f, -0.0f));
NDCCube.push_back(glm::vec4(-1.0f, 1.0f, 1.0f, -0.0f));
/* Get the current PROJECTION from OpenGL */
glGetFloatv(GL_PROJECTION_MATRIX, (GLfloat*)(glm::value_ptr(projection)));
//calculate the inverse of projection matrix. Hopefully, this'll get us the frustum when multiplied
//by coords of a cube.
projectionInv = glm::inverse(projection);

//push back vertices
for(int i = 0; i < 8; i++)
{
glm::vec4 tempvec;
tempvec = projectionInv * NDCCube.at(i); //multiply by projection matrix inverse to obtain frustum vertex
frustumVertices.push_back(Vector3(tempvec.x, tempvec.y, tempvec.z));
}
```

20 September 2012 - 10:58 AM

Hey guys! I'm looking for a GLSL authoring tool, and I heard people recommend Render Monkey. Unfortunately, the website http://developer.amd.com/archive/gpu/rendermonkey/pages/default.aspx
is bugging out when I go, and I can't for the life of me find any legitimate mirrors. Does anyone know where I can get this tool or an alternative?

### Problem initializing object

15 September 2012 - 10:54 PM

Hi! I have an abstract GameOS object, and a windows implementation in WindowsOS.

```class GameOS
{
private:
bool fullScreen;
public:
virtual void showWindow() = 0;
virtual void resize(U32 width, U32 height) = 0;
virtual void initialize() = 0;
virtual void processOSMessages()=0;
virtual void shutdown()=0;
virtual void setFullScreen(bool value) = 0;
};
```

I also have a platform detection class, where I try to allocate an OS object. For each platform, the platform detection class would use different cpp files. I was playing around with a custom stack allocator, trying to allocate the OS from a big stack that's passed in:

```class PlatformDetection
{
private:

public:
PlatformDetection();
~PlatformDetection(void);

static GameOS* initAndReturnOS(StackAllocator& subsystemStack);
};
```

The windows implementation of the the initAndReturn function looks like this:

```GameOS* PlatformDetection::initAndReturnOS(StackAllocator& subsystemStack)
{
WindowsOS* ret = (WindowsOS*)subsystemStack.allocateAligned(sizeof(WindowsOS), __alignof(WindowsOS));
memset(ret, 0, sizeof(WindowsOS));
ret->initialize();
return (GameOS*)ret;
}
```

The program crashes on ret->initialize(). The thing is, when I comment out "virtual void initialize() = 0;" in GameOS.h, it behaves normally, so it looks like it's trying to call an undefined function of GameOS rather than WindowsOS's function, even though the point is of type WindowsOS*...

Does anyone know why this is?

### NeHe samples building, but no exe found.

16 August 2012 - 08:43 AM

I'm going through the Beginning OpenGL Game Programming book, and I downloaded the samples from the NeHe website because I'm missing the CD.

I'm using VS. I tried to create a new solution, import the vc++ projects and build them. The build works, but the apps cannot run because there is no .exe generated in the Debug folder. Does anyone know what might be causing this problem?

Edit: Sorry, never mind, I should have looked at build output more carefully. It gave me the following warning:

warning MSB8012: TargetPath(C:\Users\...\Visual Studio 2010\Projects\OpenGLSampleApp\Debug\simple.exe) does not match the Linker's OutputFile property value (D:\Tutorials\Beginning OpenGL Game Programming code\OpenGL 3.0\chapter_1\simple\simple.exe). This may cause your project to build incorrectly. To correct this, please make sure that \$(OutDir), \$(TargetName) and \$(TargetExt) property values match the value specified in %(Link.OutputFile).

Setting the Output File value in Linker settings to:

\$(SolutionDir)\$(Configuration)\\$(ProjectName)\$(TargetExt)

Seems to work. I wonder if this solution is ok/good practice?

### Can't have function prototype with 4 __m128 parameters?

22 July 2012 - 03:59 PM

Trying to copy code from Game Engine Architecture by Jason Gregory..

I have a .h file, SSEMatrixMultiplier, where I tried to put a function prototype:
`__m128 mulVectorMatrixAttempt2(__m128 v, __m128 Mrow1, __m128 Mrow2, __m128 Mrow3, __m128 Mrow4);`

and a .cpp file, where I try to implement the function:

```__m128 mulVectorMatrixAttempt2(__m128 v, __m128 Mrow1, __m128 Mrow2, __m128 Mrow3, __m128 Mrow4)
{
__m128 xMrow1 = _mm_mul_ps(_mm_replicate_x_ps(v), Mrow1);
__m128 yMrow2 = _mm_mul_ps(_mm_replicate_y_ps(v), Mrow2);
__m128 zMrow3 = _mm_mul_ps(_mm_replicate_z_ps(v), Mrow3);
__m128 wMrow4 = _mm_mul_ps(_mm_replicate_w_ps(v), Mrow4);

__m128 result = _mm_add_ps(xMrow1, yMrow2);
result = _mm_add_ps(result, zMrow3);
result = _mm_add_ps(result, wMrow4);
return result;
}
```

But the compiler gives me the following errors:

Error 1 error C2719: 'Mrow3': formal parameter with __declspec(align('16')) won't be aligned c:\...simd sse math test\simd sse math test\ssematrixmultiplier.h 20
Error 3 error C2719: 'Mrow3': formal parameter with __declspec(align('16')) won't be aligned c:\...simd sse math test\simd sse math test\ssematrixmultiplier.cpp 4
Error 2 error C2719: 'Mrow4': formal parameter with __declspec(align('16')) won't be aligned c:\...simd sse math test\simd sse math test\ssematrixmultiplier.h 20
Error 4 error C2719: 'Mrow4': formal parameter with __declspec(align('16')) won't be aligned c:\...simd sse math test\simd sse math test\ssematrixmultiplier.cpp 4

Anyone know what's up?

PARTNERS