60 assert(i < MAX_GL_FRAMEBUFFERS);
83 screenBuffer.
depth = 0;
98 unsigned int filters[2];
99 filters[0] = GL_NEAREST;
100 filters[1] = GL_LINEAR_MIPMAP_LINEAR;
109 filters[0] = GL_LINEAR;
129 qglDeleteRenderbuffersEXT(1, &buf->
depth);
140 qglDeleteFramebuffersEXT(1, &buf->
fbo);
158 frameBufferObjectCount = 0;
181 Com_Printf(
"Warning: framebuffer creation failed; framebuffers not initialized!\n");
186 Com_Printf(
"Warning: framebuffer creation failed; already created too many framebuffers!\n");
194 Com_Printf(
"Couldn't allocate requested number of drawBuffers in R_SetupFramebuffer!\n");
207 #ifdef GL_VERSION_ES_CM_1_0
211 buf->
pixelFormat = halfFloat ? GL_RGBA16F_ARB : GL_RGBA8;
212 buf->
byteFormat = halfFloat ? GL_HALF_FLOAT_ARB : GL_UNSIGNED_BYTE;
218 if (qglRenderbufferStorageMultisampleEXT && qglBlitFramebuffer) {
230 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filters[i]);
231 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
232 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
GL_CLAMP);
233 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
GL_CLAMP);
234 glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
235 qglGenerateMipmapEXT(GL_TEXTURE_2D);
244 qglGenFramebuffersEXT(1, &buf->
fbo);
250 qglGenRenderbuffersEXT(1, &buf->
depth);
265 unsigned colorbuffer;
266 qglGenRenderbuffersEXT(1, &colorbuffer);
273 qglGenFramebuffersEXT(1, &buf->
proxyFBO);
304 #ifndef GL_VERSION_ES_CM_1_0
308 qglBlitFramebuffer(0, 0, buf->
width, buf-> height, 0, 0, buf->
width, buf->
height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
329 Com_Printf(
"Can't bind framebuffer: framebuffers not initialized\n");
348 glClear(GL_COLOR_BUFFER_BIT | (buf->
depth ? GL_DEPTH_BUFFER_BIT : 0));
415 qglDrawBuffers(n, attachments);
void R_SetupViewport(r_framebuffer_t *buf, int x, int y, int width, int height)
Sets the framebuffer dimensions of the viewport.
bool R_EnableRenderbuffer(bool enable)
Enable the render to the framebuffer.
static r_framebuffer_t frameBufferObjects[MAX_GL_FRAMEBUFFERS]
#define Mem_AllocTypeN(type, n)
void R_UseFramebuffer(const r_framebuffer_t *buf)
bind specified framebuffer object so we render to it
void glBindTexture(GLenum target, GLuint id)
void R_ShutdownFBObjects(void)
Delete all registered framebuffer and render buffer objects, clear memory.
r_framebuffer_t * buffers2[DOWNSAMPLE_PASSES]
static GLuint frameBufferTextures[MAX_GL_FRAMEBUFFERS]
r_framebuffer_t * renderBuffer
#define GL_RENDERBUFFER_EXT
local graphics definitions
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
void Com_Printf(const char *const fmt,...)
#define GL_DEPTH_ATTACHMENT_EXT
bool renderbuffer_enabled
const GLuint *typedef GLuint *typedef GLenum
void Com_Error(int code, const char *fmt,...)
static r_framebuffer_t screenBuffer
const r_framebuffer_t * activeFramebuffer
#define GL_DEPTH_COMPONENT
bool R_RenderbufferEnabled(void)
r_framebuffer_t * R_CreateFramebuffer(int width, int height, int ntextures, bool depth, bool halfFloat, unsigned int *filters)
create a new framebuffer object
#define DOWNSAMPLE_PASSES
void R_DeleteFBObject(r_framebuffer_t *buf)
Delete framebuffer object along with attached render buffer.
bool frameBufferObjectsInitialized
#define GL_READ_FRAMEBUFFER_EXT
static GLuint R_GetFreeFBOTexture(void)
void R_InitFBObjects(void)
static void R_FreeFBOTexture(int texnum)
void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *texels)
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
static int frameBufferObjectCount
#define GL_FRAMEBUFFER_EXT
void R_DrawBuffers(unsigned int drawBufferNum)
Activate draw buffer(s)
r_framebuffer_t * buffers0[DOWNSAMPLE_PASSES]
static GLenum * colorAttachments
#define GL_COLOR_ATTACHMENT0_EXT
void glGenTextures(GLsizei n, GLuint *textures)
void R_BindColorAttachments(unsigned int n, unsigned int *attachments)
Activate draw buffer(s)
#define GL_DRAW_FRAMEBUFFER_EXT
r_framebuffer_t * buffers1[DOWNSAMPLE_PASSES]
void R_ResolveMSAA(const r_framebuffer_t *buf)
Forces multisample antialiasing resolve on given framebuffer, if needed.
void R_UseViewport(const r_framebuffer_t *buf)
Set the viewport to the dimensions of the given framebuffer.
#define MAX_GL_FRAMEBUFFERS