From 14026e6f08aa58bf1bcaa8d1b87298498c09d6ac Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 9 Sep 2013 23:39:18 +0200 Subject: [PATCH] Set params from storage --- .../driver/opengl/driver_opengl_uniform.cpp | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_uniform.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_uniform.cpp index 3ba97efd3..a8434b3bc 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_uniform.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_uniform.cpp @@ -389,7 +389,41 @@ bool CDriverGL::setUniformMaterialInternal(TProgram program, CMaterial &material void CDriverGL::setUniformParams(TProgram program, const CGPUProgramParams ¶ms) { - // todo + IGPUProgram *prog = NULL; + switch (program) + { + case VertexProgram: + prog = _LastSetuppedVP; + break; + case PixelProgram: + prog = _LastSetuppedPP; + break; + } + if (!prog) return; + + size_t offset = params.getBegin(); + while (offset != params.getEnd()) + { + uint size = params.getSizeByOffset(offset); + uint count = params.getCountByOffset(offset); + + nlassert(size == 4 || count == 1); // only support float4 arrays + nlassert(params.getTypeByOffset(offset) == CGPUProgramParams::Float); // only support float + + uint index = params.getIndexByOffset(offset); + if (index == ~0) + { + const std::string &name = params.getNameByOffset(offset); + nlassert(!name.empty() /* missing both parameter name and index, code error */); + uint index = prog->getUniformIndex(name); + nlassert(index != ~0 /* invalid parameter name */); + params.map(index, name); + } + + setUniform4fv(program, index, count, params.getPtrFByOffset(offset)); + + offset = params.getNext(offset); + } } #ifdef NL_STATIC