本文整理汇总了C++中GLSLProgram::sendUniform方法的典型用法代码示例。如果您正苦于以下问题:C++ GLSLProgram::sendUniform方法的具体用法?C++ GLSLProgram::sendUniform怎么用?C++ GLSLProgram::sendUniform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLSLProgram
的用法示例。
在下文中一共展示了GLSLProgram::sendUniform方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawActor
void Actor::drawActor(string sShader)
{
GLSLProgram *glslProgram = ShaderManager::getInstance()->getShader(sShader);
glslProgram->sendUniform("modelviewMatrix", &MatrixManager::getInstance()->getMatrix4(MODELVIEW)[0][0]);
if (sShader == "Basic" || sShader == "GBuffer" || sShader == "BuildVoxels")
{
glslProgram->sendUniform("normalMatrix", &MatrixManager::getInstance()->getMatrix3(NORMAL)[0][0],false,3);
MaterialManager::getInstance()->getMaterial(*m_psMaterial)->sendToShader(sShader);
}
ModelManager::getInstance()->getModel(*m_psModel)->draw();
}
示例2: voxelRender
void MainGraphicsWidget::voxelRender()
{
VoxelGrid::getInstance()->buildVoxels(m_lightBuffer->getLight());
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
MatrixManager::getInstance()->putMatrix4(MODELVIEW, glm::mat4(1.0f));
MatrixManager::getInstance()->putMatrix4(PROJECTION, glm::mat4(1.0f));
MatrixManager::getInstance()->putMatrix3(NORMAL, glm::mat3(1.0f));
view->viewport();
view->use3D(true);
camera->transform();
GLSLProgram *glslProgram = ShaderManager::getInstance()->getShader("Voxel");
glslProgram->use();
glBindFragDataLocation(glslProgram->getHandle(), 0, "fragColor");
glBindAttribLocation(glslProgram->getHandle(), 0, "v_vertex");
glslProgram->sendUniform("projectionMatrix", &MatrixManager::getInstance()->getMatrix4(PROJECTION)[0][0]);
glslProgram->sendUniform("modelviewMatrix", &MatrixManager::getInstance()->getMatrix4(MODELVIEW)[0][0]);
glm::mat4 cameraInverse = glm::mat4(1.0);
cameraInverse = camera->transformToMatrix(cameraInverse);
cameraInverse = glm::inverse(cameraInverse);
glslProgram->sendUniform("invCameraMatrix", &cameraInverse[0][0]);
glslProgram->sendUniform("worldSize", WORLD_SIZE);
//glslProgram->sendUniform("numVoxels", VOXEL_SIZE);
//glslProgram->sendUniform("mipLevel", VoxelGrid::getInstance()->getMipLevel());
int mipFactor = pow(2.0, VoxelGrid::getInstance()->getMipLevel());
glActiveTexture(GL_TEXTURE8);
glEnable(GL_TEXTURE_3D);
VoxelGrid::getInstance()->bind(VoxelGrid::getInstance()->getMipLevel());
glslProgram->sendUniform("voxelmap", 8);
//glEnable(GL_POINT_SMOOTH);
glPointSize(10.0f*mipFactor);
float voxelWidth = (float)WORLD_SIZE / (float)VOXEL_SIZE * mipFactor;
glBegin(GL_POINTS);
for (float x=-(WORLD_SIZE/2.0)+(voxelWidth/2.0); x<(WORLD_SIZE/2.0); x+=voxelWidth)
{
for (float y=-(WORLD_SIZE/2.0)+(voxelWidth/2.0); y<(WORLD_SIZE/2.0); y+=voxelWidth)
{
for (float z=-(WORLD_SIZE/2.0)+(voxelWidth/2.0); z<(WORLD_SIZE/2.0); z+=voxelWidth)
{
glVertex3f(x,y,z);
}
}
}
glEnd();
glslProgram->disable();
}
示例3: sendToShader
void CascadedShadowMap::sendToShader(string sShader)
{
GLSLProgram *glslProgram = ShaderManager::getInstance()->getShader(sShader);
glActiveTexture(GL_TEXTURE4);
glBindTexture(GL_TEXTURE_2D,m_shadowMaps[0]->getTexture());
glslProgram->sendUniform("shadowMap[0]",4);
glActiveTexture(GL_TEXTURE5);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,m_shadowMaps[1]->getTexture());
glslProgram->sendUniform("shadowMap[1]",5);
glActiveTexture(GL_TEXTURE6);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,m_shadowMaps[2]->getTexture());
glslProgram->sendUniform("shadowMap[2]",6);
glActiveTexture(GL_TEXTURE7);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,m_shadowMaps[3]->getTexture());
glslProgram->sendUniform("shadowMap[3]",7);
glslProgram->sendUniform("slices[0]",m_nSlices[0]);
glslProgram->sendUniform("slices[1]",m_nSlices[1]);
glslProgram->sendUniform("slices[2]",m_nSlices[2]);
m_m4LightMatrix[0] = glm::translate(glm::mat4(1.0f),glm::vec3(0.5f,0.5f,0.5f)) * glm::scale(glm::mat4(1.0f),glm::vec3(0.5f,0.5f,0.5f)) * m_m4LightMatrix[0];
m_m4LightMatrix[1] = glm::translate(glm::mat4(1.0f),glm::vec3(0.5f,0.5f,0.5f)) * glm::scale(glm::mat4(1.0f),glm::vec3(0.5f,0.5f,0.5f)) * m_m4LightMatrix[1];
m_m4LightMatrix[2] = glm::translate(glm::mat4(1.0f),glm::vec3(0.5f,0.5f,0.5f)) * glm::scale(glm::mat4(1.0f),glm::vec3(0.5f,0.5f,0.5f)) * m_m4LightMatrix[2];
m_m4LightMatrix[3] = glm::translate(glm::mat4(1.0f),glm::vec3(0.5f,0.5f,0.5f)) * glm::scale(glm::mat4(1.0f),glm::vec3(0.5f,0.5f,0.5f)) * m_m4LightMatrix[3];
glslProgram->sendUniform("lightMatrix[0]", &m_m4LightMatrix[0][0][0]);
glslProgram->sendUniform("lightMatrix[1]", &m_m4LightMatrix[1][0][0]);
glslProgram->sendUniform("lightMatrix[2]", &m_m4LightMatrix[2][0][0]);
glslProgram->sendUniform("lightMatrix[3]", &m_m4LightMatrix[3][0][0]);
}
示例4: buildShadowMaps
void CascadedShadowMap::buildShadowMaps(Camera *camera, View *view, DirectLight *light)
{
//Profiler::getInstance()->startProfile("Build Shadow Maps");
float nSlice[] = {0.0, m_nSlices[0], m_nSlices[1], m_nSlices[2], 1.0};
Frustum *frustum = new Frustum();
frustum->getFrustum(camera, view);
m_shadowMaps[3]->bind();
glClearDepth(1.0);
glClear(GL_DEPTH_BUFFER_BIT);
glDisable(GL_CULL_FACE);
for (int i=0; i<4; i++)
{
Camera *lightCamera = createLightCamera(nSlice[i],nSlice[i+1],camera,view,light);
View *lightView = createLightView(nSlice[i],nSlice[i+1],camera,lightCamera,view,frustum);
Frustum *lightFrustum = new Frustum();
lightFrustum->getOrthoFrustum(lightCamera,lightView);
MatrixManager::getInstance()->putMatrix4(MODELVIEW, glm::mat4(1.0f));
MatrixManager::getInstance()->putMatrix4(PROJECTION, glm::mat4(1.0f));
m_shadowMaps[i]->bind();
glClearDepth(1.0);
glEnable(GL_DEPTH_TEST);
glClear(GL_DEPTH_BUFFER_BIT);
glPushAttrib( GL_VIEWPORT_BIT );
glViewport( 0, 0, m_nSize, m_nSize);
lightView->use3D(false);
GLSLProgram *glslProgram = ShaderManager::getInstance()->getShader("DirectShadow");
glslProgram->use();
glm::mat4 cameraMat = glm::mat4(1.0f);
cameraMat = lightCamera->transformToMatrix(cameraMat);
m_m4LightMatrix[i] = MatrixManager::getInstance()->getMatrix4(PROJECTION) * cameraMat;
MatrixManager::getInstance()->putMatrix4(MODELVIEW, cameraMat);
glslProgram->sendUniform("projectionMatrix", &MatrixManager::getInstance()->getMatrix4(PROJECTION)[0][0]);
glBindAttribLocation(glslProgram->getHandle(), 0, "v_vertex");
SceneManager::getInstance()->draw("DirectShadow");
glslProgram->disable();
glPopAttrib();
m_shadowMaps[i]->unbind();
delete lightCamera;
delete lightView;
delete lightFrustum;
}
glEnable(GL_CULL_FACE);
//Profiler::getInstance()->endProfile();
}
示例5: forwardRender
void MainGraphicsWidget::forwardRender()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
MatrixManager::getInstance()->putMatrix4(MODELVIEW, glm::mat4(1.0f));
MatrixManager::getInstance()->putMatrix4(PROJECTION, glm::mat4(1.0f));
MatrixManager::getInstance()->putMatrix3(NORMAL, glm::mat3(1.0f));
view->viewport();
view->use3D(true);
camera->transform();
GLSLProgram *glslProgram = ShaderManager::getInstance()->getShader("Basic");
glslProgram->use();
glBindFragDataLocation(glslProgram->getHandle(), 0, "fragColor");
glBindAttribLocation(glslProgram->getHandle(), 0, "v_vertex");
glBindAttribLocation(glslProgram->getHandle(), 1, "v_texture");
glBindAttribLocation(glslProgram->getHandle(), 2, "v_normal");
glBindAttribLocation(glslProgram->getHandle(), 3, "v_tangent");
glBindAttribLocation(glslProgram->getHandle(), 4, "v_bitangent");
glslProgram->sendUniform("light.direction", 1.0f,-5.0f,2.0f);
glslProgram->sendUniform("light.color", 1.0f,1.0f,1.0f);
glslProgram->sendUniform("light.ambient", 0.7f);
glslProgram->sendUniform("light.diffuse", 0.6f);
glslProgram->sendUniform("projectionMatrix", &MatrixManager::getInstance()->getMatrix4(PROJECTION)[0][0]);
glslProgram->sendUniform("modelviewMatrix", &MatrixManager::getInstance()->getMatrix4(MODELVIEW)[0][0]);
glslProgram->sendUniform("curveGeometry", false);
glm::mat4 cameraInverse = glm::mat4(1.0);
cameraInverse = camera->transformToMatrix(cameraInverse);
cameraInverse = glm::inverse(cameraInverse);
glslProgram->sendUniform("inverseCameraMatrix", &cameraInverse[0][0]);
glslProgram->sendUniform("cameraPos", camera->getEyeX(), camera->getEyeY(), camera->getEyeZ());
MaterialManager::getInstance()->getMaterial("Default")->sendToShader("Basic");
myGrid->draw();
SceneManager::getInstance()->draw("Basic");
glslProgram->disable();
SceneManager::getInstance()->drawTransformers();
}
示例6: drawToBuffer
void IndirectBuffer::drawToBuffer(GLuint nDepthTex, GLuint nTangentTex, GLuint nBiangentTex, GLuint nNormalTex, GLuint nDiffuseTex, View *view, Camera *camera)
{
GLSLProgram *glslProgram = ShaderManager::getInstance()->getShader("Indirect");
glslProgram->use();
bind();
GLenum mrt[] = {GL_COLOR_ATTACHMENT0_EXT};
glDrawBuffers(1, mrt);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushAttrib( GL_VIEWPORT_BIT );
glViewport( 0, 0, getWidth(), getHeight());
MatrixManager::getInstance()->putMatrix4(MODELVIEW, glm::mat4(1.0f));
MatrixManager::getInstance()->putMatrix4(PROJECTION, glm::mat4(1.0f));
camera->transform();
view->use3D(true);
glm::mat4 m4InvMVP = MatrixManager::getInstance()->getMatrix4(PROJECTION) * MatrixManager::getInstance()->getMatrix4(MODELVIEW);
m4InvMVP = glm::inverse(m4InvMVP);
MatrixManager::getInstance()->putMatrix4(MODELVIEW, glm::mat4(1.0f));
MatrixManager::getInstance()->putMatrix4(PROJECTION, glm::mat4(1.0f));
view->use3D(false);
glBindFragDataLocation(glslProgram->getHandle(), 0, "glossyBuffer");
glBindAttribLocation(glslProgram->getHandle(), 0, "v_vertex");
glBindAttribLocation(glslProgram->getHandle(), 1, "v_texture");
glslProgram->sendUniform("projectionMatrix", &MatrixManager::getInstance()->getMatrix4(PROJECTION)[0][0]);
glslProgram->sendUniform("inverseMVPMatrix", &m4InvMVP[0][0]);
glslProgram->sendUniform("worldSize", WORLD_SIZE);
glslProgram->sendUniform("numVoxels", VOXEL_SIZE);
glActiveTexture(GL_TEXTURE8);
glEnable(GL_TEXTURE_3D);
VoxelGrid::getInstance()->bind(0);
glActiveTexture(GL_TEXTURE9);
glEnable(GL_TEXTURE_3D);
VoxelGrid::getInstance()->bind(1);
glActiveTexture(GL_TEXTURE10);
glEnable(GL_TEXTURE_3D);
VoxelGrid::getInstance()->bind(2);
glActiveTexture(GL_TEXTURE11);
glEnable(GL_TEXTURE_3D);
VoxelGrid::getInstance()->bind(3);
glslProgram->sendUniform("voxelmap[0]", 8);
glslProgram->sendUniform("voxelmap[1]", 9);
glslProgram->sendUniform("voxelmap[2]", 10);
glslProgram->sendUniform("voxelmap[3]", 11);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, nDepthTex);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, nTangentTex);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, nBiangentTex);
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, nNormalTex);
glActiveTexture(GL_TEXTURE4);
glBindTexture(GL_TEXTURE_2D, nDiffuseTex);
glslProgram->sendUniform("depthTex",0);
glslProgram->sendUniform("tanTex",1);
glslProgram->sendUniform("bitanTex",2);
glslProgram->sendUniform("normalTex",3);
glslProgram->sendUniform("diffuseTex",4);
drawScreenShader(0,0,1.0f,1.0f);
glFinish();
glslProgram->disable();
unbind();
}