8#include "ps2s/packet.h"
10#include "ps2gl/clear.h"
11#include "ps2gl/drawcontext.h"
12#include "ps2gl/glcontext.h"
13#include "ps2gl/immgmanager.h"
17 pDrawEnv =
new GS::CDrawEnv(GS::kContext2);
18 pDrawEnv->SetDepthTestPassMode(GS::ZTest::kAlways);
20 pSprite =
new CSprite(GS::kContext2, 0, 0, 0, 0);
21 pSprite->SetUseTexture(
false);
22 unsigned int clearColor[4] = { 0, 0, 0, 0 };
23 pSprite->SetColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
27CClearEnv::~CClearEnv()
33void CClearEnv::SetDimensions(
int width,
int height)
35 pDrawEnv->SetFrameBufferDim(width, height);
36 pSprite->SetVertices(0, 0, width, height);
39void CClearEnv::SetFrameBufPsm(GS::tPSM psm)
41 pDrawEnv->SetFrameBufferPSM(psm);
44void CClearEnv::SetDepthBufPsm(GS::tPSM psm)
46 pDrawEnv->SetDepthBufferPSM(psm);
49void CClearEnv::ClearBuffers(
unsigned int bitMask)
51 if (bitMask & GL_DEPTH_BUFFER_BIT)
52 pDrawEnv->EnableDepthTest();
54 pDrawEnv->DisableDepthTest();
56 if (bitMask & GL_COLOR_BUFFER_BIT)
57 pDrawEnv->SetFrameBufferDrawMask(0);
59 pDrawEnv->SetFrameBufferDrawMask(0xffffffff);
61 CVifSCDmaPacket& packet = pGLContext->GetVif1Packet();
62 pGLContext->AddingDrawEnvToPacket((tU128*)pGLContext->GetVif1Packet().GetNextPtr() + 1);
63 pDrawEnv->SendSettings(packet);
64 pSprite->Draw(packet);
71void glClearColor(GLclampf red,
76 GL_FUNC_DEBUG(
"%s(%f,%f,%f,%f)\n", __FUNCTION__, red, green, blue, alpha);
78 CClearEnv& clearEnv = pGLContext->GetImmDrawContext().GetClearEnv();
81 clearEnv.SetClearColor(Clamp(red, 0.0f, 1.0f),
82 Clamp(green, 0.0f, 1.0f),
83 Clamp(blue, 0.0f, 1.0f),
84 Clamp(alpha, 0.0f, 1.0f));
87void glClearDepth(GLclampd depth)
89 GL_FUNC_DEBUG(
"%s(%f)\n", __FUNCTION__, depth);
91 CClearEnv& clearEnv = pGLContext->GetImmDrawContext().GetClearEnv();
93 clearEnv.SetClearDepth((
float)depth);
96void glClear(GLbitfield mask)
98 GL_FUNC_DEBUG(
"%s(0x%x)\n", __FUNCTION__, mask);
100 pGLContext->GetImmDrawContext().GetClearEnv().ClearBuffers(mask);