Thin3d: Minor API change in prep for DX11

This commit is contained in:
Henrik Rydgard 2014-09-07 10:47:21 +02:00
parent 69bad8ba74
commit 588930dd66
4 changed files with 17 additions and 8 deletions

View File

@ -45,7 +45,10 @@ void DrawBuffer::Init(Thin3DContext *t3d) {
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));
vformat_ = t3d_->CreateVertexFormat(components, 24);
Thin3DShader *vshader = t3d_->GetVshaderPreset(VS_TEXTURE_COLOR_2D);
vformat_ = t3d_->CreateVertexFormat(components, 24, vshader);
}
void DrawBuffer::Shutdown() {

View File

@ -17,7 +17,8 @@ enum T3DBlendEquation : int {
ADD,
SUBTRACT,
REV_SUBTRACT,
// MIN, MAX,
MIN,
MAX,
};
enum T3DComparison : int {
@ -122,6 +123,7 @@ enum T3DTextureType : uint8_t {
};
enum T3DImageFormat : uint8_t {
IMG_UNKNOWN,
LUMINANCE,
RGBA8888,
RGBA4444,
@ -260,7 +262,7 @@ public:
virtual Thin3DBlendState *CreateBlendState(const T3DBlendStateDesc &desc) = 0;
virtual Thin3DBuffer *CreateBuffer(size_t size, uint32_t usageFlags) = 0;
virtual Thin3DShaderSet *CreateShaderSet(Thin3DShader *vshader, Thin3DShader *fshader) = 0;
virtual Thin3DVertexFormat *CreateVertexFormat(const std::vector<Thin3DVertexComponent> &components, int stride) = 0;
virtual Thin3DVertexFormat *CreateVertexFormat(const std::vector<Thin3DVertexComponent> &components, int stride, Thin3DShader *vshader) = 0;
virtual Thin3DTexture *CreateTexture() = 0; // To be later filled in by ->LoadFromFile or similar.
virtual Thin3DTexture *CreateTexture(T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels) = 0;

View File

@ -30,6 +30,9 @@ static const D3DCMPFUNC compareToD3D9[] = {
static const D3DBLENDOP blendEqToD3D9[] = {
D3DBLENDOP_ADD,
D3DBLENDOP_SUBTRACT,
D3DBLENDOP_REVSUBTRACT,
D3DBLENDOP_MIN,
D3DBLENDOP_MAX,
};
// Could be declared as u8
@ -357,7 +360,7 @@ public:
Thin3DBlendState *CreateBlendState(const T3DBlendStateDesc &desc) override;
Thin3DBuffer *CreateBuffer(size_t size, uint32_t usageFlags) override;
Thin3DShaderSet *CreateShaderSet(Thin3DShader *vshader, Thin3DShader *fshader) override;
Thin3DVertexFormat *CreateVertexFormat(const std::vector<Thin3DVertexComponent> &components, int stride) override;
Thin3DVertexFormat *CreateVertexFormat(const std::vector<Thin3DVertexComponent> &components, int stride, Thin3DShader *vshader) override;
Thin3DTexture *CreateTexture() override;
Thin3DTexture *CreateTexture(T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels) override;
@ -458,7 +461,7 @@ Thin3DDepthStencilState *Thin3DDX9Context::CreateDepthStencilState(bool depthTes
return ds;
}
Thin3DVertexFormat *Thin3DDX9Context::CreateVertexFormat(const std::vector<Thin3DVertexComponent> &components, int stride) {
Thin3DVertexFormat *Thin3DDX9Context::CreateVertexFormat(const std::vector<Thin3DVertexComponent> &components, int stride, Thin3DShader *vshader) {
Thin3DDX9VertexFormat *fmt = new Thin3DDX9VertexFormat(device_, components, stride);
return fmt;
}
@ -548,6 +551,7 @@ Thin3DDX9VertexFormat::Thin3DDX9VertexFormat(LPDIRECT3DDEVICE9 device, const std
if (FAILED(hr)) {
ELOG("Error creating vertex decl");
}
delete[] elements;
stride_ = stride;
}

View File

@ -52,7 +52,7 @@ static const char *glsl_fragment_prelude =
"precision mediump float;\n"
"#endif\n";
inline void Uint32ToFloat4(uint32_t u, float f[4]) {
static inline void Uint32ToFloat4(uint32_t u, float f[4]) {
f[0] = ((u >> 0) & 0xFF) * (1.0f / 255.0f);
f[1] = ((u >> 8) & 0xFF) * (1.0f / 255.0f);
f[2] = ((u >> 16) & 0xFF) * (1.0f / 255.0f);
@ -264,7 +264,7 @@ public:
Thin3DBlendState *CreateBlendState(const T3DBlendStateDesc &desc) override;
Thin3DBuffer *CreateBuffer(size_t size, uint32_t usageFlags) override;
Thin3DShaderSet *CreateShaderSet(Thin3DShader *vshader, Thin3DShader *fshader) override;
Thin3DVertexFormat *CreateVertexFormat(const std::vector<Thin3DVertexComponent> &components, int stride) override;
Thin3DVertexFormat *CreateVertexFormat(const std::vector<Thin3DVertexComponent> &components, int stride, Thin3DShader *vshader) override;
Thin3DTexture *CreateTexture(T3DTextureType type, T3DImageFormat format, int width, int height, int depth, int mipLevels) override;
Thin3DTexture *CreateTexture() override;
@ -336,7 +336,7 @@ Thin3DGLContext::Thin3DGLContext() {
Thin3DGLContext::~Thin3DGLContext() {
}
Thin3DVertexFormat *Thin3DGLContext::CreateVertexFormat(const std::vector<Thin3DVertexComponent> &components, int stride) {
Thin3DVertexFormat *Thin3DGLContext::CreateVertexFormat(const std::vector<Thin3DVertexComponent> &components, int stride, Thin3DShader *vshader) {
Thin3DGLVertexFormat *fmt = new Thin3DGLVertexFormat();
fmt->components_ = components;
fmt->stride_ = stride;