7#include "ps2gl/dlist.h"
8#include "ps2gl/glcontext.h"
9#include "ps2gl/immgmanager.h"
41 for (
int i = 0; i < NumRenderPackets; i++)
42 delete RenderPackets[i];
52 if (VertexBuf == NULL)
53 VertexBuf =
new CDmaPacket(kBufferMaxQwordLength, DMAC::Channels::vif1,
54 Core::MemMappings::UncachedAccl);
61 if (NormalBuf == NULL)
62 NormalBuf =
new CDmaPacket(kBufferMaxQwordLength, DMAC::Channels::vif1,
63 Core::MemMappings::UncachedAccl);
68CDList::GetTexCoordBuf()
70 if (TexCoordBuf == NULL)
71 TexCoordBuf =
new CDmaPacket(kBufferMaxQwordLength, DMAC::Channels::vif1,
72 Core::MemMappings::UncachedAccl);
80 ColorBuf =
new CDmaPacket(kBufferMaxQwordLength, DMAC::Channels::vif1,
81 Core::MemMappings::UncachedAccl);
89void CDListManager::SwapBuffers()
91 CurBuffer = 1 - CurBuffer;
92 for (
int i = 0; i < NumListsToBeFreed[CurBuffer]; i++)
93 delete ListsToBeFreed[CurBuffer][i];
94 NumListsToBeFreed[CurBuffer] = 0;
97bool CDListManager::ListsAreFree(
int firstListID,
int numLists)
99 bool listsAreFree =
true;
100 for (
int i = 0; i < numLists; i++)
101 if (Lists[firstListID + i] != NULL)
102 listsAreFree =
false;
107CDListManager::GenLists(
int numLists)
110 int firstID = NextFreeListID;
112 mErrorIf(!ListsAreFree(NextFreeListID, numLists),
113 "Uh-oh.. time to write some real display list management code.");
115 NextFreeListID += numLists;
118 if (NextFreeListID == kMaxListID - 1)
121 mErrorIf(NextFreeListID >= kMaxListID,
"Ran out of lists.. time to rewrite this code.");
126void CDListManager::DeleteLists(
unsigned int firstListID,
int numLists)
128 for (
int i = 0; i < numLists; i++) {
129 if (Lists[firstListID + i]) {
131 AddListToBeFreed(Lists[firstListID + i]);
132 Lists[firstListID + i] = NULL;
137void CDListManager::NewList(
unsigned int listID, GLenum mode)
139 mWarnIf(mode == GL_COMPILE_AND_EXECUTE,
140 "GL_COMPILE_AND_EXECUTE is not yet supported");
147void CDListManager::EndList()
149 mErrorIf(OpenListID == 0,
"There is no list to end!");
151 if (Lists[OpenListID])
152 AddListToBeFreed(Lists[OpenListID]);
153 Lists[OpenListID] = OpenList;
154 Lists[OpenListID]->End();
169 pGLContext->GetDListManager().CallList(ListID);
170 return CDListCmd::GetNextCmd(
this);
174void CDListManager::CallList(
unsigned int listID)
176 if (OpenListID != 0) {
180 mErrorIf(Lists[listID] == NULL,
"List does not exist.");
181 pGLContext->GetImmGeomManager().Flush();
182 Lists[listID]->Play();
190GLuint glGenLists(GLsizei range)
192 GL_FUNC_DEBUG(
"%s(%d)\n", __FUNCTION__, range);
194 return pGLContext->GetDListManager().GenLists(range);
197void glDeleteLists(GLuint list, GLsizei range)
199 GL_FUNC_DEBUG(
"%s(%d,%d)\n", __FUNCTION__, list, range);
201 pGLContext->GetDListManager().DeleteLists(list, range);
204void glNewList(GLuint listID, GLenum mode)
206 GL_FUNC_DEBUG(
"%s(%d,%d)\n", __FUNCTION__, listID, mode);
208 pGLContext->BeginDListDef(listID, mode);
213 GL_FUNC_DEBUG(
"%s()\n", __FUNCTION__);
215 pGLContext->EndDListDef();
218void glCallList(GLuint listID)
220 GL_FUNC_DEBUG(
"%s(%d)\n", __FUNCTION__, listID);
222 pGLContext->GetDListManager().CallList(listID);