Subversion Repositories gelsvn

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
666 janba 1
/*
2
 *  ShadowBuffer.h
3
 *  02564_Framework
4
 *
5
 *  Created by J. Andreas Bærentzen on 01/02/11.
6
 *  Copyright 2011 __MyCompanyName__. All rights reserved.
7
 *
8
 */
9
 
10
#ifndef __SHADOWBUFFER_H__
11
#define __SHADOWBUFFER_H__
12
 
13
#include <GL/glew.h>
14
#include <GLGraphics/glsl_shader.h>
15
 
16
/** This class represents a shadow buffer. Essentially, this is just a texture
17
 and a framebuffer object wrapped in a class. Note that the shadow is a depth 
18
 texture */
19
class ShadowBuffer
20
{
21
	const int dim; // Size
22
	GLuint fbo, rb; // The framebuffer object and the render buffer
23
	GLuint dtex; // The depth texture 
24
 
25
	/// Let go of resources 
26
	void relinquish();
27
public:
28
 
29
	/// Construct with default size 1024
30
    ShadowBuffer(int _dim = 1024);
31
 
32
	/// Destroy, releasing resources
33
	~ShadowBuffer() {relinquish();}
34
 
35
	/// Initialize: Acquire resources. 
36
	void initialize();
37
 
38
	/** Enable the framebuffer object. There is no disable(). This seems unsymmetrical, but 
39
	 we do not necessarily switch back to the framebuffer we had prior to enable. So switching 
40
	 back might incur an unnecessary FBO switch. */
41
	int enable();
42
 
43
	/// Bind the depth map texture to specified tex unit.
44
	void bind_textures(int dtex_unit);
45
};
46
 
47
#endif