Ejemplo n.º 1
0
SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Thin3DContext *_thin3D)
	: gfxCtx_(gfxCtx), thin3d(_thin3D)
{
	fbTex = thin3d->CreateTexture(LINEAR2D, RGBA8888, 480, 272, 1, 1);

	std::vector<Thin3DVertexComponent> components;
	components.push_back(Thin3DVertexComponent("Position", SEM_POSITION, FLOATx3, 0));
	components.push_back(Thin3DVertexComponent("TexCoord0", SEM_TEXCOORD0, FLOATx2, 12));
	components.push_back(Thin3DVertexComponent("Color0", SEM_COLOR0, UNORM8x4, 20));

	Thin3DShader *vshader = thin3d->GetVshaderPreset(VS_TEXTURE_COLOR_2D);
	vformat = thin3d->CreateVertexFormat(components, 24, vshader);

	vdata = thin3d->CreateBuffer(24 * 4, T3DBufferUsage::DYNAMIC | T3DBufferUsage::VERTEXDATA);
	idata = thin3d->CreateBuffer(sizeof(int) * 6, T3DBufferUsage::DYNAMIC | T3DBufferUsage::INDEXDATA);
	depth = thin3d->CreateDepthStencilState(false, false, T3DComparison::LESS);

	fb.data = Memory::GetPointer(0x44000000); // TODO: correct default address?
	depthbuf.data = Memory::GetPointer(0x44000000); // TODO: correct default address?

	framebufferDirty_ = true;
	// TODO: Is there a default?
	displayFramebuf_ = 0;
	displayStride_ = 512;
	displayFormat_ = GE_FORMAT_8888;
}
Ejemplo n.º 2
0
void DrawBuffer::Init(Thin3DContext *t3d) {
	if (inited_)
		return;

	t3d_ = t3d;
	inited_ = true;

	std::vector<Thin3DVertexComponent> components;
	components.push_back(Thin3DVertexComponent("Position", SEM_POSITION, FLOATx3, 0));
	components.push_back(Thin3DVertexComponent("TexCoord0", SEM_TEXCOORD0, FLOATx2, 12));
	components.push_back(Thin3DVertexComponent("Color0", SEM_COLOR0, UNORM8x4, 20));

	Thin3DShader *vshader = t3d_->GetVshaderPreset(VS_TEXTURE_COLOR_2D);

	vformat_ = t3d_->CreateVertexFormat(components, 24, vshader);
	if (vformat_->RequiresBuffer()) {
		vbuf_ = t3d_->CreateBuffer(MAX_VERTS * sizeof(Vertex), T3DBufferUsage::DYNAMIC | T3DBufferUsage::VERTEXDATA);
	} else {
		vbuf_ = nullptr;
	}
}