mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
and more boring moving and cleanup ...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1661 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -1,130 +0,0 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// 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/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "IndexGenerator.h"
|
||||
|
||||
/*
|
||||
*
|
||||
QUAD simulator
|
||||
|
||||
0 2 4 6
|
||||
1 3 5 7
|
||||
021231 243453
|
||||
*/
|
||||
|
||||
|
||||
void IndexGenerator::Start(unsigned short *startptr)
|
||||
{
|
||||
ptr=startptr;
|
||||
index=0;
|
||||
numPrims=0;
|
||||
}
|
||||
|
||||
void IndexGenerator::AddList(int numVerts)
|
||||
{
|
||||
int numTris = numVerts/3;
|
||||
if (numTris<=0) return;
|
||||
for (int i=0; i<numTris; i++)
|
||||
{
|
||||
*ptr++ = index+i*3;
|
||||
*ptr++ = index+i*3+1;
|
||||
*ptr++ = index+i*3+2;
|
||||
}
|
||||
index += numVerts;
|
||||
numPrims += numTris;
|
||||
}
|
||||
|
||||
void IndexGenerator::AddStrip(int numVerts)
|
||||
{
|
||||
int numTris = numVerts-2;
|
||||
if (numTris<=0) return;
|
||||
bool wind = false;
|
||||
for (int i=0; i<numTris; i++)
|
||||
{
|
||||
*ptr++ = index+i;
|
||||
*ptr++ = index+i+(wind?2:1);
|
||||
*ptr++ = index+i+(wind?1:2);
|
||||
wind = !wind;
|
||||
}
|
||||
index += numVerts;
|
||||
numPrims += numTris;
|
||||
}
|
||||
|
||||
void IndexGenerator::AddLineList(int numVerts)
|
||||
{
|
||||
int numLines= numVerts/2;
|
||||
if (numLines<=0) return;
|
||||
for (int i=0; i<numLines; i++)
|
||||
{
|
||||
*ptr++ = index+i*2;
|
||||
*ptr++ = index+i*2+1;
|
||||
}
|
||||
index += numVerts;
|
||||
numPrims += numLines;
|
||||
}
|
||||
|
||||
void IndexGenerator::AddLineStrip(int numVerts)
|
||||
{
|
||||
int numLines = numVerts-1;
|
||||
if (numLines<=0) return;
|
||||
for (int i=0; i<numLines; i++)
|
||||
{
|
||||
*ptr++ = index+i;
|
||||
*ptr++ = index+i+1;
|
||||
}
|
||||
index += numVerts;
|
||||
numPrims += numLines;
|
||||
}
|
||||
|
||||
|
||||
void IndexGenerator::AddFan(int numVerts)
|
||||
{
|
||||
int numTris = numVerts-2;
|
||||
if (numTris<=0) return;
|
||||
for (int i=0; i<numTris; i++)
|
||||
{
|
||||
*ptr++ = index;
|
||||
*ptr++ = index+i+1;
|
||||
*ptr++ = index+i+2;
|
||||
}
|
||||
index += numVerts;
|
||||
numPrims += numTris;
|
||||
}
|
||||
|
||||
void IndexGenerator::AddQuads(int numVerts)
|
||||
{
|
||||
int numTris = (numVerts/4)*2;
|
||||
if (numTris<=0) return;
|
||||
for (int i=0; i<numTris/2; i++)
|
||||
{
|
||||
*ptr++=index+i*4;
|
||||
*ptr++=index+i*4+1;
|
||||
*ptr++=index+i*4+3;
|
||||
*ptr++=index+i*4+1;
|
||||
*ptr++=index+i*4+2;
|
||||
*ptr++=index+i*4+3;
|
||||
}
|
||||
index += numVerts;
|
||||
numPrims += numTris;
|
||||
}
|
||||
|
||||
|
||||
void IndexGenerator::AddPointList(int numVerts)
|
||||
{
|
||||
index += numVerts;
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// 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/
|
||||
|
||||
#pragma once
|
||||
|
||||
class IndexGenerator
|
||||
{
|
||||
unsigned short *ptr;
|
||||
int numPrims;
|
||||
int index;
|
||||
public:
|
||||
void Start(unsigned short *startptr);
|
||||
void AddList(int numVerts);
|
||||
void AddStrip(int numVerts);
|
||||
void AddLineList(int numVerts);
|
||||
void AddPointList(int numVerts); //dummy for counting vertices
|
||||
void AddLineStrip(int numVerts);
|
||||
void AddFan(int numVerts);
|
||||
void AddQuads(int numVerts);
|
||||
int GetNumPrims() {return numPrims;} //returns numprimitives
|
||||
int GetNumVerts() {return index;} //returns numprimitives
|
||||
};
|
@ -37,6 +37,14 @@ using namespace D3D;
|
||||
namespace VertexManager
|
||||
{
|
||||
|
||||
enum Collection
|
||||
{
|
||||
C_NOTHING=0,
|
||||
C_TRIANGLES=1,
|
||||
C_LINES=2,
|
||||
C_POINTS=3
|
||||
};
|
||||
|
||||
static IndexGenerator indexGen;
|
||||
static Collection collection;
|
||||
|
||||
@ -65,6 +73,23 @@ const D3DVERTEXELEMENT9 decl[] =
|
||||
D3DDECL_END()
|
||||
};
|
||||
|
||||
const Collection collectionTypeLUT[8] =
|
||||
{
|
||||
C_TRIANGLES,//quads
|
||||
C_NOTHING, //nothing
|
||||
C_TRIANGLES,//triangles
|
||||
C_TRIANGLES,//strip
|
||||
C_TRIANGLES,//fan
|
||||
C_LINES, //lines
|
||||
C_LINES, //linestrip
|
||||
C_POINTS //guess :P
|
||||
};
|
||||
|
||||
|
||||
D3DVertex *vbufferwrite;
|
||||
|
||||
void CreateDeviceObjects();
|
||||
void DestroyDeviceObjects();
|
||||
|
||||
bool Init()
|
||||
{
|
||||
@ -105,12 +130,11 @@ void DestroyDeviceObjects()
|
||||
vDecl = 0;
|
||||
}
|
||||
|
||||
|
||||
void AddIndices(int _primitive, int _numVertices)
|
||||
{
|
||||
switch(_primitive) {
|
||||
case GX_DRAW_QUADS: indexGen.AddQuads(_numVertices); return;
|
||||
case GX_DRAW_TRIANGLES: indexGen.AddList(_numVertices); return;
|
||||
switch (_primitive) {
|
||||
case GX_DRAW_QUADS: indexGen.AddQuads(_numVertices); return;
|
||||
case GX_DRAW_TRIANGLES: indexGen.AddList(_numVertices); return;
|
||||
case GX_DRAW_TRIANGLE_STRIP: indexGen.AddStrip(_numVertices); return;
|
||||
case GX_DRAW_TRIANGLE_FAN: indexGen.AddFan(_numVertices); return;
|
||||
case GX_DRAW_LINE_STRIP: indexGen.AddLineStrip(_numVertices); return;
|
||||
@ -119,20 +143,6 @@ void AddIndices(int _primitive, int _numVertices)
|
||||
}
|
||||
}
|
||||
|
||||
const Collection collectionTypeLUT[8] =
|
||||
{
|
||||
C_TRIANGLES,//quads
|
||||
C_NOTHING, //nothing
|
||||
C_TRIANGLES,//triangles
|
||||
C_TRIANGLES,//strip
|
||||
C_TRIANGLES,//fan
|
||||
C_LINES, //lines
|
||||
C_LINES, //linestrip
|
||||
C_POINTS //guess :P
|
||||
};
|
||||
|
||||
D3DVertex *vbufferwrite;
|
||||
|
||||
void AddVertices(int _primitive, int _numVertices, const DecodedVArray *varray)
|
||||
{
|
||||
if (_numVertices <= 0) //This check is pretty stupid...
|
||||
|
@ -18,13 +18,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CPStructs.h"
|
||||
#include "CPMemory.h"
|
||||
#include "VertexLoader.h"
|
||||
#include "DecodedVArray.h"
|
||||
|
||||
struct UV
|
||||
{
|
||||
float u,v,w;
|
||||
float u, v, w;
|
||||
};
|
||||
|
||||
struct D3DVertex {
|
||||
@ -34,27 +34,14 @@ struct D3DVertex {
|
||||
UV uv[8];
|
||||
};
|
||||
|
||||
enum Collection
|
||||
{
|
||||
C_NOTHING=0,
|
||||
C_TRIANGLES=1,
|
||||
C_LINES=2,
|
||||
C_POINTS=3
|
||||
};
|
||||
|
||||
namespace VertexManager
|
||||
{
|
||||
|
||||
extern const Collection collectionTypeLUT[8];
|
||||
|
||||
bool Init();
|
||||
void Shutdown();
|
||||
|
||||
void BeginFrame();
|
||||
|
||||
void CreateDeviceObjects();
|
||||
void DestroyDeviceObjects();
|
||||
|
||||
void AddVertices(int _primitive, int _numVertices, const DecodedVArray *varray);
|
||||
void Flush();
|
||||
|
||||
|
Reference in New Issue
Block a user