//[-------------------------------------------------------] //[ Private virtual PLRenderer::Resource functions ] //[-------------------------------------------------------] void FragmentShaderGLSL::BackupDeviceData(uint8 **ppBackup) { // Get the length of the shader source, including the null termination character GLint nShaderSourceLength = 0; glGetObjectParameterivARB(m_nOpenGLFragmentShader, GL_OBJECT_SHADER_SOURCE_LENGTH_ARB, &nShaderSourceLength); if (nShaderSourceLength > 1) { *ppBackup = new uint8[nShaderSourceLength]; glGetShaderSourceARB(m_nOpenGLFragmentShader, nShaderSourceLength, nullptr, reinterpret_cast<GLcharARB*>(*ppBackup)); glDeleteObjectARB(m_nOpenGLFragmentShader); m_nOpenGLFragmentShader = 0; } else { *ppBackup = nullptr; } }
String FragmentShaderGLSL::GetSourceCode() const { // Get the length of the shader source, including the null termination character GLint nShaderSourceLength = 0; glGetObjectParameterivARB(m_nOpenGLFragmentShader, GL_OBJECT_SHADER_SOURCE_LENGTH_ARB, &nShaderSourceLength); if (nShaderSourceLength > 1) { // The string class takes over the control of the string memory and also deletes it char *pszSourceCode = new char[nShaderSourceLength]; glGetShaderSourceARB(m_nOpenGLFragmentShader, nShaderSourceLength, nullptr, pszSourceCode); return String(pszSourceCode, false, nShaderSourceLength-1); // -1 = excluding the null termination character } // Error! return ""; }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBShaderObjects_nglGetShaderSourceARB(JNIEnv *env, jclass clazz, jint obj, jint maxLength, jobject length, jint length_position, jobject source, jint source_position, jlong function_pointer) { GLsizei *length_address = ((GLsizei *)safeGetBufferAddress(env, length)) + length_position; GLcharARB *source_address = ((GLcharARB *)(*env)->GetDirectBufferAddress(env, source)) + source_position; glGetShaderSourceARBPROC glGetShaderSourceARB = (glGetShaderSourceARBPROC)((intptr_t)function_pointer); glGetShaderSourceARB(obj, maxLength, length_address, source_address); }