void NVPTextBox::render() { /* Query spacing information for example's message. */ mMessageLen = strlen ( mText.c_str() ); if ( xtranslate != NULL ) { free ( xtranslate ); xtranslate = NULL; } xtranslate = ( GLfloat* ) malloc ( sizeof ( GLfloat ) * mMessageLen ); if ( !xtranslate ) { ci::app::console() << " malloc of xtranslate failed" << endl; exit ( 1 ); } xtranslate[0] = 0.0; /* Initial xtranslate is zero. */ GLfloat advanceScale = 1.0f * mKerningFactor, kerningScale = 1.0f * mKerningFactor; /* Set this to zero to ignore kerning. */ glGetPathSpacingNV ( GL_ACCUM_ADJACENT_PAIRS_NV, ( GLsizei ) mMessageLen, GL_UNSIGNED_BYTE, mText.c_str(), mFont->getGlyphs(), advanceScale, kerningScale, GL_TRANSLATE_X_NV, &xtranslate[1] ); /* messageLen-1 accumulated translates are written here. */ /* Total advance is accumulated spacing plus horizontal advance of the last glyph */ float lastX = xtranslate[mMessageLen - 1]; const unsigned char* message_ub = ( const unsigned char* ) mText.c_str(); int charIndex = message_ub[mMessageLen - 1]; float totalLen = mFont->getGlyphMetrics()->mHorizontalAdvance[charIndex]; mTotalAdvance = lastX + totalLen; mXBorder = mTotalAdvance / mMessageLen; mInitialOffset = mFont->getGlyphMetrics()->mHorizontalBearingX[mText.c_str() [0]]; mInvalid = false; }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_NVPathRendering_nglGetPathSpacingNV(JNIEnv *env, jclass clazz, jint pathListMode, jint numPaths, jint pathNameType, jlong paths, jint pathBase, jfloat advanceScale, jfloat kerningScale, jint transformType, jlong returnedSpacing, jlong function_pointer) { const GLvoid *paths_address = (const GLvoid *)(intptr_t)paths; GLfloat *returnedSpacing_address = (GLfloat *)(intptr_t)returnedSpacing; glGetPathSpacingNVPROC glGetPathSpacingNV = (glGetPathSpacingNVPROC)((intptr_t)function_pointer); glGetPathSpacingNV(pathListMode, numPaths, pathNameType, paths_address, pathBase, advanceScale, kerningScale, transformType, returnedSpacing_address); }