void CCJSPrimitiveFBX::renderVertices(const bool textured) { CCRenderer::CCSetRenderStates( true ); for( int subModelIndex=0; subModelIndex<submodels.length; ++subModelIndex ) { Submodel &submodel = *submodels.list[subModelIndex]; if( submodel.adjustedUVs != NULL ) { CCSetTexCoords( submodel.adjustedUVs ); } else if( submodel.modelUVs ) { CCSetTexCoords( submodel.modelUVs ); } GLVertexPointer( 3, GL_FLOAT, 0, submodel.skinnedVertices, submodel.vertexCount ); if( submodel.indices != NULL ) { for( int i=0; i<submodel.submeshes.length; ++i ) { Submesh &submesh = *submodel.submeshes.list[i]; gRenderer->GLDrawElements( GL_TRIANGLES, submesh.count, GL_UNSIGNED_SHORT, &submodel.indices[submesh.offset] ); } } } }
void CCTextureManager::invalidateAllTextureHandles() { currentGLTexture = NULL; totalTexturesLoaded = 0; totalUsedTextureSpace = 0; for( int i=0; i<textureHandles.length; ++i ) { CCTextureHandle *handle = textureHandles.list[i]; if( handle->texture != NULL ) { totalUsedTextureSpace -= handle->texture->getBytes(); delete handle->texture; handle->texture = NULL; } } // Load in a 1x1 white texture to use for untextured draws assignTextureIndex( "transparent.png", Resource_Packaged, false, true, true ); assignTextureIndex( "white.png", Resource_Packaged, false, true, true ); setTextureIndex( 0 ); CCSetTexCoords( NULL ); CCDefaultTexCoords(); }
void CCPrimitiveObj::renderVertices(const bool textured) { CCSetViewMatrix(); GLVertexPointer( 3, GL_FLOAT, 0, vertices ); CCSetVertexAttribute( ATTRIB_NORMAL, 3, GL_FLOAT, 0, normals, true ); CCSetTexCoords( textureUVs != NULL ? textureUVs : modelUVs ); glDrawArrays( GL_TRIANGLES, 0, vertexCount ); }
void CCPrimitiveObj::renderVertices(const bool textured) { CCRenderer::CCSetRenderStates( true ); GLVertexPointer( 3, GL_FLOAT, 0, vertices, vertexCount ); CCSetVertexAttribute( ATTRIB_NORMAL, 3, GL_FLOAT, 0, normals, true, vertexCount ); CCSetTexCoords( adjustedUVs != NULL ? adjustedUVs : modelUVs ); GLDrawArrays( GL_TRIANGLES, 0, vertexCount ); }
void CCInverseTexCoords() { static const float texCoords[] = { 0.0f, -1.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f }; CCSetTexCoords( texCoords ); }
void CCDefaultTexCoords() { static const float texCoords[] = { 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f }; CCSetTexCoords( texCoords ); }
void CCTextureManager::invalidateAllTextureHandles() { for( int i=0; i<textureHandles.length; ++i ) { CCTextureHandle *handle = textureHandles.list[i]; if( handle->texture != NULL ) { totalUsedTextureSpace -= handle->texture->getBytes(); delete handle->texture; handle->texture = NULL; } } setTextureIndex( 0 ); CCSetTexCoords( NULL ); CCDefaultTexCoords(); }
void CCPrimitiveSquare::renderVertices(const bool textured) { #if defined PROFILEON CCProfiler profile( "CCPrimitiveSquare::renderVertices()" ); #endif if( customUVs != NULL ) { CCSetTexCoords( customUVs->uvs ); } else { CCDefaultTexCoords(); } CCSetViewMatrix(); GLVertexPointer( 3, GL_FLOAT, 0, vertices ); glDrawArrays( GL_TRIANGLE_STRIP, 0, 4 ); }
const bool CCWidgetBase::render(const bool foreground) { if( inView && enabled && foreground == renderForeground ) { if( colour == NULL ) { static CCColour colour( 1.0f, 1.0f, 1.0f, 0.75f ); CCSetColour( colour ); } else { CCSetColour( *colour ); } if( renderButton ) { if( textureIndex != 0 ) { gEngine->textureManager->setTextureIndex( textureIndex ); if( customUVs != NULL ) { CCSetTexCoords( customUVs->uvs ); } else { CCDefaultTexCoords(); } } else { gEngine->textureManager->setTextureIndex( 0 ); } CCRenderRectanglePoint( position, size.width, -size.height ); if( renderOutline ) { if( colour == NULL ) { static CCColour colour( 0.5f, 0.5f, 0.5f, 0.75f ); CCSetColour( colour ); } else { CCColour colourObject( colour->red * 0.5f, colour->green * 0.5f, colour->blue * 0.5f, colour->alpha ); CCSetColour( colourObject ); } CCRenderRectanglePoint( position, size.width, -size.height, true ); } if( distortEffect ) { static CCColour colour( 1.0f, 1.0f, 1.0f, 0.5f ); CCSetColour( colour ); CCRenderRectanglePoint( position, size.width + distortTarget.x, size.height + distortTarget.y ); } } return true; } return false; }
void CCTextureFontPage::renderText(const char *text, const uint length, const float x, const float y, const bool centeredX, const bool centeredY, const float size) const { ASSERT( length < MAX_TEXT_LENGTH ); bindTexturePage(); // Find out our width so we can center the text CCPoint lineSize[MAX_TEXT_LINES]; CCPoint charSize[MAX_TEXT_LENGTH]; uint numberOfLines = 0; for( uint i=0; i<length; ++i ) { const Letter *letter = getLetter( text[i] ); if( letter != NULL ) { charSize[i].x = letter->size.width * size; charSize[i].y = letter->size.height * size; // New line if( text[i] == 10 ) { numberOfLines++; ASSERT( numberOfLines < MAX_TEXT_LINES ); } lineSize[numberOfLines].x += charSize[i].x; lineSize[numberOfLines].y = MAX( lineSize[numberOfLines].y, charSize[i].y ); } } CCPoint max( lineSize[0].x, lineSize[0].y ); for( uint i=1; i<numberOfLines; ++i ) { max.x = MAX( max.x, lineSize[i].x ); max.y += lineSize[i].y; } CCPoint start = CCPoint( x, y ); if( centeredX ) { start.x -= max.x * 0.5f; } if( centeredY ) { start.y -= max.y * gEngine->renderer->aspectRatio; } CCPoint currentStart = start; CCPoint currentEnd; CCSetTexCoords( texCoords ); uint lineNumber = 0; for( uint i=0; i<length; ++i ) { const Letter *letter = getLetter( text[i] ); if( letter != NULL ) { // Calculate end point currentEnd.x = currentStart.x + charSize[i].x; currentEnd.y = currentStart.y + charSize[i].y; // New line if( text[i] == 10 ) { currentStart.y += lineSize[lineNumber++].y; //currentStart.x = lineStart[lineNumber]; } else { texCoords[0] = letter->start.x; texCoords[1] = letter->start.y; texCoords[2] = letter->end.x; texCoords[3] = letter->start.y; texCoords[4] = letter->start.x; texCoords[5] = letter->end.y; texCoords[6] = letter->end.x; texCoords[7] = letter->end.y; CCRenderSquare2D( currentStart, currentEnd, false ); currentStart.x += charSize[i].x; } } } }
void CCTextureFontPage::renderText3D(const char *text, const uint length, const float x, const float y, const float z, const float height, const bool centeredX) const { #if defined PROFILEON CCProfiler profile( "CCTextureFontPage::renderText3D()" ); #endif // TODO: I draw these wrong, please fix me to work with back face culling glCullFace( GL_FRONT ); ASSERT( length < MAX_TEXT_LENGTH ); bindTexturePage(); // Find out our width so we can center the text int lineIndex = 0; CCPoint lineSize[MAX_TEXT_LINES]; static CCPoint charSize[MAX_TEXT_LINES][MAX_TEXT_LENGTH]; int characterIndex = 0; for( uint i=0; i<length; ++i ) { char character = text[i]; if( character == '\n' ) { lineIndex++; characterIndex = 0; ASSERT( lineIndex < MAX_TEXT_LINES ); } else { const Letter *letter = getLetter( character ); if( letter != NULL ) { CCPoint &size = charSize[lineIndex][characterIndex]; size.x = letter->size.width * height; size.y = letter->size.height * height; lineSize[lineIndex].x += size.x; lineSize[lineIndex].y = MAX( lineSize[lineIndex].y, size.y ); characterIndex++; } } } CCPoint start( x, y ); if( centeredX ) { start.x -= lineSize[0].x * 0.5f; } start.y += lineSize[0].y * 0.5f; static CCVector3 currentStart, currentEnd; currentStart.x = start.x; currentStart.y = start.y; currentStart.z = -z; currentEnd.z = z; CCSetTexCoords( texCoords ); lineIndex = 0; characterIndex = 0; for( uint i=0; i<length; ++i ) { char character = text[i]; if( character == '\n' ) { currentStart.x = start.x; currentStart.y -= lineSize[lineIndex].y; lineIndex++; characterIndex = 0; } else { const Letter *letter = getLetter( character ); if( letter != NULL ) { CCPoint &size = charSize[lineIndex][characterIndex]; // Calculate end point currentEnd.x = currentStart.x + size.x; currentEnd.y = currentStart.y - size.y; texCoords[0] = letter->start.x; texCoords[1] = letter->start.y; texCoords[2] = letter->end.x; texCoords[3] = letter->start.y; texCoords[4] = letter->start.x; texCoords[5] = letter->end.y; texCoords[6] = letter->end.x; texCoords[7] = letter->end.y; CCRenderSquare( currentStart, currentEnd ); currentStart.x += size.x; characterIndex++; } } } glCullFace( GL_BACK ); }