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);
}