mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 05:41:45 +00:00
Merge branch 'master' of https://github.com/jewalky/UltimateDoomBuilder
This commit is contained in:
commit
54fb563a9a
5 changed files with 28 additions and 25 deletions
|
@ -195,42 +195,42 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
|
||||
public void SetUniform(UniformName uniform, bool value)
|
||||
{
|
||||
RenderDevice_SetUniform(Handle, uniform, new float[] { value ? 1.0f : 0.0f }, 1);
|
||||
RenderDevice_SetUniform(Handle, uniform, new float[] { value ? 1.0f : 0.0f }, 1, sizeof(float));
|
||||
}
|
||||
|
||||
public void SetUniform(UniformName uniform, float value)
|
||||
{
|
||||
RenderDevice_SetUniform(Handle, uniform, new float[] { value }, 1);
|
||||
RenderDevice_SetUniform(Handle, uniform, new float[] { value }, 1, sizeof(float));
|
||||
}
|
||||
|
||||
public void SetUniform(UniformName uniform, Vector2 value)
|
||||
{
|
||||
RenderDevice_SetUniform(Handle, uniform, new float[] { value.X, value.Y }, 2);
|
||||
RenderDevice_SetUniform(Handle, uniform, new float[] { value.X, value.Y }, 1, sizeof(float) * 2);
|
||||
}
|
||||
|
||||
public void SetUniform(UniformName uniform, Vector3 value)
|
||||
{
|
||||
RenderDevice_SetUniform(Handle, uniform, new float[] { value.X, value.Y, value.Z }, 3);
|
||||
RenderDevice_SetUniform(Handle, uniform, new float[] { value.X, value.Y, value.Z }, 1, sizeof(float) * 3);
|
||||
}
|
||||
|
||||
public void SetUniform(UniformName uniform, Vector4 value)
|
||||
{
|
||||
RenderDevice_SetUniform(Handle, uniform, new float[] { value.X, value.Y, value.Z, value.W }, 4);
|
||||
RenderDevice_SetUniform(Handle, uniform, new float[] { value.X, value.Y, value.Z, value.W }, 1, sizeof(float) * 4);
|
||||
}
|
||||
|
||||
public void SetUniform(UniformName uniform, Color4 value)
|
||||
{
|
||||
RenderDevice_SetUniform(Handle, uniform, new float[] { value.Red, value.Green, value.Blue, value.Alpha }, 4);
|
||||
RenderDevice_SetUniform(Handle, uniform, new float[] { value.Red, value.Green, value.Blue, value.Alpha }, 1, sizeof(float) * 4);
|
||||
}
|
||||
|
||||
public void SetUniform(UniformName uniform, Matrix matrix)
|
||||
{
|
||||
RenderDevice_SetUniform(Handle, uniform, ref matrix, 16);
|
||||
RenderDevice_SetUniform(Handle, uniform, ref matrix, 1, sizeof(float) * 16);
|
||||
}
|
||||
|
||||
public void SetUniform(UniformName uniform, ref Matrix matrix)
|
||||
{
|
||||
RenderDevice_SetUniform(Handle, uniform, ref matrix, 16);
|
||||
RenderDevice_SetUniform(Handle, uniform, ref matrix, 1, sizeof(float) * 16);
|
||||
}
|
||||
|
||||
public void SetVertexBuffer(VertexBuffer buffer)
|
||||
|
@ -504,10 +504,10 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
static extern bool RenderDevice_SetShader(IntPtr handle, ShaderName name);
|
||||
|
||||
[DllImport("BuilderNative", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void RenderDevice_SetUniform(IntPtr handle, UniformName name, float[] data, int count);
|
||||
static extern void RenderDevice_SetUniform(IntPtr handle, UniformName name, float[] data, int count, int bytesize);
|
||||
|
||||
[DllImport("BuilderNative", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void RenderDevice_SetUniform(IntPtr handle, UniformName name, ref Matrix data, int count);
|
||||
static extern void RenderDevice_SetUniform(IntPtr handle, UniformName name, ref Matrix data, int count, int bytesize);
|
||||
|
||||
[DllImport("BuilderNative", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void RenderDevice_SetVertexBuffer(IntPtr handle, IntPtr buffer);
|
||||
|
|
|
@ -92,9 +92,9 @@ extern "C"
|
|||
device->SetShader(name);
|
||||
}
|
||||
|
||||
void RenderDevice_SetUniform(RenderDevice* device, UniformName name, const void* values, int count)
|
||||
void RenderDevice_SetUniform(RenderDevice* device, UniformName name, const void* values, int count, int bytesize)
|
||||
{
|
||||
device->SetUniform(name, values, count);
|
||||
device->SetUniform(name, values, count, bytesize);
|
||||
}
|
||||
|
||||
void RenderDevice_SetVertexBuffer(RenderDevice* device, VertexBuffer* buffer)
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
virtual void DeclareUniform(UniformName name, const char* glslname, UniformType type) = 0;
|
||||
virtual void DeclareShader(ShaderName index, const char* name, const char* vertexshader, const char* fragmentshader) = 0;
|
||||
virtual void SetShader(ShaderName name) = 0;
|
||||
virtual void SetUniform(UniformName name, const void* values, int count) = 0;
|
||||
virtual void SetUniform(UniformName name, const void* values, int count, int bytesize) = 0;
|
||||
virtual void SetVertexBuffer(VertexBuffer* buffer) = 0;
|
||||
virtual void SetIndexBuffer(IndexBuffer* buffer) = 0;
|
||||
virtual void SetAlphaBlendEnable(bool value) = 0;
|
||||
|
|
|
@ -698,12 +698,16 @@ void GLRenderDevice::SetShader(ShaderName name)
|
|||
}
|
||||
}
|
||||
|
||||
void GLRenderDevice::SetUniform(UniformName name, const void* values, int count)
|
||||
void GLRenderDevice::SetUniform(UniformName name, const void* values, int count, int bytesize)
|
||||
{
|
||||
float* dest = mUniformData.data() + mUniformInfo[(int)name].Offset;
|
||||
if (memcmp(dest, values, sizeof(float) * count) != 0)
|
||||
// "count" should be in bytes now
|
||||
UniformInfo& info = mUniformInfo[(int)name];
|
||||
info.Count = count;
|
||||
info.Data.resize(bytesize);
|
||||
uint8_t* dest = info.Data.data();
|
||||
if (memcmp(dest, values, bytesize) != 0)
|
||||
{
|
||||
memcpy(dest, values, sizeof(float) * count);
|
||||
memcpy(dest, values, bytesize);
|
||||
mUniformInfo[(int)name].LastUpdate++;
|
||||
mNeedApply = true;
|
||||
mUniformsChanged = true;
|
||||
|
@ -840,9 +844,6 @@ void GLRenderDevice::DeclareUniform(UniformName name, const char* glslname, Unif
|
|||
UniformInfo& info = mUniformInfo[index];
|
||||
info.Name = glslname;
|
||||
info.Type = type;
|
||||
info.Offset = (int)mUniformData.size();
|
||||
|
||||
mUniformData.resize(mUniformData.size() + (type == UniformType::Mat4 ? 16 : 4));
|
||||
}
|
||||
|
||||
bool GLRenderDevice::ApplyUniforms()
|
||||
|
@ -854,9 +855,11 @@ bool GLRenderDevice::ApplyUniforms()
|
|||
int count = (int)mUniformInfo.size();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (lastupdates[i] != mUniformInfo.data()[i].LastUpdate)
|
||||
UniformInfo& info = mUniformInfo.data()[i];
|
||||
if (lastupdates[i] != info.LastUpdate)
|
||||
{
|
||||
float* data = mUniformData.data() + mUniformInfo[i].Offset;
|
||||
float* data = (float*)info.Data.data();
|
||||
int* idata = (int*)info.Data.data();
|
||||
GLuint location = locations[i];
|
||||
switch (mUniformInfo[i].Type)
|
||||
{
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
void DeclareUniform(UniformName name, const char* glslname, UniformType type) override;
|
||||
void DeclareShader(ShaderName index, const char* name, const char* vertexshader, const char* fragmentshader) override;
|
||||
void SetShader(ShaderName name) override;
|
||||
void SetUniform(UniformName name, const void* values, int count) override;
|
||||
void SetUniform(UniformName name, const void* values, int count, int bytesize) override;
|
||||
void SetVertexBuffer(VertexBuffer* buffer) override;
|
||||
void SetIndexBuffer(IndexBuffer* buffer) override;
|
||||
void SetAlphaBlendEnable(bool value) override;
|
||||
|
@ -159,12 +159,12 @@ public:
|
|||
{
|
||||
std::string Name;
|
||||
UniformType Type = {};
|
||||
int Offset = 0;
|
||||
int LastUpdate = 0;
|
||||
int Count = 0;
|
||||
std::vector<uint8_t> Data;
|
||||
};
|
||||
|
||||
std::vector<UniformInfo> mUniformInfo;
|
||||
std::vector<float> mUniformData;
|
||||
|
||||
GLuint mStreamVertexBuffer = 0;
|
||||
GLuint mStreamVAO = 0;
|
||||
|
|
Loading…
Reference in a new issue