void piglit_init(int argc, char **argv) { bool piglit_pass = true; GLuint vs, fs, prog; GLint loc; float vf[] = { 1.0, 2.0, 3.0 }; double vd[] = { 1.0, 2.0, 3.0, 4.0, 5.0}; piglit_require_extension("GL_ARB_gpu_shader_fp64"); vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_text); fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_text); prog = piglit_link_simple_program(vs, fs); glUseProgram(prog); // Setting different type should fail loc = glGetUniformLocation(prog, "d"); glUniform1i(loc, 3); piglit_pass = piglit_pass && piglit_check_gl_error(GL_INVALID_OPERATION); glUniform1f(loc, 3.0); piglit_pass = piglit_pass && piglit_check_gl_error(GL_INVALID_OPERATION); glUniform1d(loc, 3.0); piglit_pass = piglit_pass && piglit_check_gl_error(GL_NO_ERROR); loc = glGetUniformLocation(prog, "v"); glUniform3fv(loc, 1, vf); piglit_pass = piglit_pass && piglit_check_gl_error(GL_INVALID_OPERATION); glUniform3d(loc, vd[0], vd[1], vd[2]); piglit_pass = piglit_pass && piglit_check_gl_error(GL_NO_ERROR); // Setting different size should fail loc = glGetUniformLocation(prog, "v"); glUniform2d(loc, vd[0], vd[1]); piglit_pass = piglit_pass && piglit_check_gl_error(GL_INVALID_OPERATION); glUniform4d(loc, vd[0], vd[1], vd[2], vd[3]); piglit_pass = piglit_pass && piglit_check_gl_error(GL_INVALID_OPERATION); glUniform3d(loc, vd[0], vd[1], vd[2]); piglit_pass = piglit_pass && piglit_check_gl_error(GL_NO_ERROR); // Special case for booleans loc = glGetUniformLocation(prog, "b"); glUniform1d(loc, 1.0); piglit_pass = piglit_pass && piglit_check_gl_error(GL_INVALID_OPERATION); glUniform1f(loc, 1.0); piglit_pass = piglit_pass && piglit_check_gl_error(GL_NO_ERROR); piglit_report_result(piglit_pass ? PIGLIT_PASS : PIGLIT_FAIL); }
// CBoxProxyView 绘制 void CBoxProxyView::GetDepthMapFromView() { glEnable(GL_DEPTH_TEST); //glDepthFunc(GL_LEQUAL); gettingDepth=true; sd.setShaders(); ColorPos=sd.getAttrLocation("vColor"); VertexPos=sd.getAttrLocation("vVertex"); KRpos=sd.getUniformLocation("m_KR"); KTpos=sd.getUniformLocation("m_KT"); Matrix3d m_KR=cam.getKR(); Vector3d m_KT=cam.getKT(); float kr[9]; double kt[3]; for (int i = 0; i < 9; i++) { kr[i]=m_KR(i); } for (int i = 0; i < 3; i++) { kt[i]=m_KT(i); } glUniformMatrix3fvARB(KRpos,1,GL_FALSE,&kr[0]); glUniform3d(KTpos,kt[0],kt[1],kt[2]); setUpDepthCam(); CPaintDC dc(this); OnDraw(&dc); }
void ProgramManager::setUniform(const char *name, LFLOAT x, LFLOAT y, LFLOAT z) { int loc = getUniformLocation(name); if (loc >= 0) { #ifdef IADOUBLE glUniform3d(loc, x, y, z); #else glUniform3f(loc, x, y, z); #endif } else { cerr << "Uniform: " << name << " is not found." << endl; } }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL40_nglUniform3d(JNIEnv *__env, jclass clazz, jint location, jdouble x, jdouble y, jdouble z, jlong __functionAddress) { glUniform3dPROC glUniform3d = (glUniform3dPROC)(intptr_t)__functionAddress; UNUSED_PARAMS(__env, clazz) glUniform3d(location, x, y, z); }