GL_ARB_shadow

Code

Here is the template that we will be filling in:

#include "GLWindow.h"
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/OglExt.h>

#define SIZE 512

class DepthTexture : public GLWindow
{
public:
	GLuint texture; // shadow map
	float rotation; // animation

	bool init()
	{
		return true;
	}

	void update(DWORD val)
	{

	}

	void drawShadowCasters(bool color)
	{

	}

	void drawShadowRecievers()
	{

	}

	// draws the shadow casters from the light view's
	// location and saves depth values to a texture
	void getShadowMap()
	{

	}

	// load bias, light projection and light
	// modelview into GL_TEXTURE_MATRIX
	// Setup texture coordinate generation
	// for inverse of camera modelview
	void setupMatrices()
	{

	}

	void draw()
	{
		// clear buffers and load indentity matrix
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		glLoadIdentity();

		getShadowMap();

		gluLookAt(
			-5.0, 3.0, 5.0,
			0.0, 0.0, -1.0,
			0.0, 0.0, 1.0);

		setupMatrices();

		drawShadowCasters(true);
		drawShadowRecievers();
	}
};

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	DepthTexture* window = new DepthTexture();

	window->starting_width = SIZE;
	window->starting_height = SIZE;

	window->redirectIOToConsole();
	window->mainLoop(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
}

Pages: 1 2 3 4 5 6

2 Comments »

24

Pingback by BitwiseOR » GL_ARB_shadow_funcs

January 10, 2006 @ 3:10 pm

[...] The GL_ARB_shadow_funcs extension requires GL_ARB_shadow and GL_ARB_depth_texture in order to have any effect. In the GL_ARB_shadow example on this site we use GL_LEQUAL when setting the GL_TEXTURE_COMPARE_FUNC_ARB texture parameter. GL_ARB_shadow allows this comparison function to be GL_GEQUAL as well, but not any of the other comparison functions. [...]

25

Pingback by » OpenGL Transforms and the Inverse Model View

August 14, 2006 @ 9:46 am

[...] It is important to realise that OpenGL’s Model View matrix is actually M * C, so, if we want to get the position of the vertex in world space, we will have to use the modelview matrix to go to camera space, then multiply by C-1 (the inverse of the camera matrix). This gives us V * M * C * C-1 = V * gl_ModelViewMatrix * C-1 = V * M. And world space is exactly what we need to do shadow mapping, refraction, reflectiona and a plethora of other things. OpenGL took care of this for us with the GL_ARB_Shadow extension. By using glTexGen, OpenGL computes the inverse camera matrix and applies it without us having to fuss with inverses. But, now we’ll need to do an inverse ourselves. [...]

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>