2009-04-03 14:35:49 +00:00
|
|
|
// Copyright (C) 2003-2009 Dolphin Project.
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
2009-03-05 23:11:13 +00:00
|
|
|
|
2009-04-03 14:35:49 +00:00
|
|
|
// ---------------------------------------------------------------------------------------------
|
2009-03-05 23:11:13 +00:00
|
|
|
// GC graphics pipeline
|
2009-04-03 14:35:49 +00:00
|
|
|
// ---------------------------------------------------------------------------------------------
|
2009-03-05 23:11:13 +00:00
|
|
|
// 3d commands are issued through the fifo. The gpu draws to the 2MB EFB.
|
|
|
|
// The efb can be copied back into ram in two forms: as textures or as XFB.
|
|
|
|
// The XFB is the region in RAM that the VI chip scans out to the television.
|
|
|
|
// So, after all rendering to EFB is done, the image is copied into one of two XFBs in RAM.
|
|
|
|
// Next frame, that one is scanned out and the other one gets the copy. = double buffering.
|
2009-04-03 14:35:49 +00:00
|
|
|
// ---------------------------------------------------------------------------------------------
|
2008-12-25 15:56:36 +00:00
|
|
|
|
2009-04-03 14:35:49 +00:00
|
|
|
#ifndef _GCOGL_RENDER_H_
|
|
|
|
#define _GCOGL_RENDER_H_
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
#include "TextureMngr.h"
|
|
|
|
|
|
|
|
#include <Cg/cg.h>
|
|
|
|
#include <Cg/cgGL.h>
|
|
|
|
|
|
|
|
extern CGcontext g_cgcontext;
|
|
|
|
extern CGprofile g_cgvProf, g_cgfProf;
|
|
|
|
|
|
|
|
extern int frameCount;
|
|
|
|
|
|
|
|
class Renderer
|
|
|
|
{
|
2009-02-22 12:43:25 +00:00
|
|
|
private:
|
2008-12-08 04:46:09 +00:00
|
|
|
static void FlushZBufferAlphaToTarget();
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum RenderMode
|
|
|
|
{
|
2008-12-25 15:56:36 +00:00
|
|
|
RM_Normal=0, // normal target as color0, ztarget as color1
|
|
|
|
RM_ZBufferOnly, // zbuffer as color0
|
|
|
|
RM_ZBufferAlpha, // zbuffer as color0, also will dump alpha info to regular target once mode is switched
|
|
|
|
// use stencil buffer to indicate what pixels were written
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
2008-12-25 15:56:36 +00:00
|
|
|
static bool Init();
|
2008-12-08 04:46:09 +00:00
|
|
|
static void Shutdown();
|
|
|
|
|
|
|
|
// initialize opengl standard values (like viewport)
|
2008-12-25 15:56:36 +00:00
|
|
|
static bool InitializeGL();
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
static void ResetGLState();
|
|
|
|
static void RestoreGLState();
|
2009-02-21 13:11:49 +00:00
|
|
|
|
|
|
|
static void SwapBuffers();
|
|
|
|
|
|
|
|
static bool IsUsingATIDrawBuffers();
|
2008-12-08 04:46:09 +00:00
|
|
|
static bool HaveStencilBuffer();
|
|
|
|
|
|
|
|
static void SetColorMask();
|
2009-01-18 19:03:14 +00:00
|
|
|
static void SetBlendMode(bool forceUpdate);
|
2008-12-08 04:46:09 +00:00
|
|
|
static bool SetScissorRect();
|
|
|
|
|
|
|
|
static void SetRenderMode(RenderMode mode);
|
|
|
|
static RenderMode GetRenderMode();
|
|
|
|
|
2009-02-21 12:53:10 +00:00
|
|
|
// Render target management
|
|
|
|
static int GetTargetWidth();
|
|
|
|
static int GetTargetHeight();
|
|
|
|
|
2009-03-05 23:11:13 +00:00
|
|
|
// Multiply any 2D EFB coordinates by these when rendering.
|
2009-02-28 16:33:59 +00:00
|
|
|
static float GetTargetScaleX();
|
|
|
|
static float GetTargetScaleY();
|
|
|
|
|
2009-02-21 12:53:10 +00:00
|
|
|
static void SetFramebuffer(GLuint fb);
|
|
|
|
static void SetZBufferRender(); // sets rendering of the zbuffer using MRTs
|
2008-12-25 15:56:36 +00:00
|
|
|
static void SetRenderTarget(GLuint targ); // if targ is 0, sets to original render target
|
|
|
|
static void SetDepthTarget(GLuint targ);
|
|
|
|
|
2009-03-05 23:11:13 +00:00
|
|
|
// If in MSAA mode, this will perform a resolve of the specified rectangle, and return the resolve target as a texture ID.
|
|
|
|
// Thus, this call may be expensive. Don't repeat it unnecessarily.
|
|
|
|
// If not in MSAA mode, will just return the render target texture ID.
|
2009-03-08 19:19:51 +00:00
|
|
|
// After calling this, before you render anything else, you MUST bind the framebuffer you want to draw to.
|
2009-03-05 23:11:13 +00:00
|
|
|
static GLuint ResolveAndGetRenderTarget(const TRectangle &rect);
|
|
|
|
|
|
|
|
// Same as above but for the FakeZ Target.
|
2009-03-08 19:19:51 +00:00
|
|
|
// After calling this, before you render anything else, you MUST bind the framebuffer you want to draw to.
|
2009-03-05 23:11:13 +00:00
|
|
|
static GLuint ResolveAndGetFakeZTarget(const TRectangle &rect);
|
2009-03-08 19:19:51 +00:00
|
|
|
static bool UseFakeZTarget(); // This is used by some functions to check for Z target existence.
|
2009-02-21 12:53:10 +00:00
|
|
|
|
|
|
|
// Random utilities
|
|
|
|
static void RenderText(const char* pstr, int left, int top, u32 color);
|
2009-02-28 16:33:59 +00:00
|
|
|
static void DrawDebugText();
|
2009-02-27 03:56:34 +00:00
|
|
|
static void SetScreenshot(const char *filename);
|
2009-03-28 21:07:16 +00:00
|
|
|
static void FlipImageData(u8 *data, int w, int h);
|
2009-02-28 16:33:59 +00:00
|
|
|
static bool SaveRenderTarget(const char *filename, int w, int h);
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
// Finish up the current frame, print some stats
|
2009-02-21 20:59:30 +00:00
|
|
|
static void Swap(const TRectangle& rc);
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
2009-02-28 16:33:59 +00:00
|
|
|
void ComputeBackbufferRectangle(TRectangle *rc);
|
|
|
|
|
2009-04-03 14:35:49 +00:00
|
|
|
#endif // _GCOGL_RENDER_H_
|