/*----------------------------------------------------------------------------- Name : btgConvertVerts Description : transforms 2D BTG vertices into 3D Inputs : Outputs : btgTransVerts, btgTransStars are allocated and initialized Return : ----------------------------------------------------------------------------*/ void btgConvertVerts() { udword nVert, nPoly, index; btgTransVertex* pTransVert; btgTransStar* pTransStar; btgPolygon* pPoly; btgZip(); btgTransVerts = memAlloc(btgHead->numVerts * sizeof(btgTransVertex), "btg trans verts", NonVolatile); if (useVBO) glGenBuffers(1, &vboTransVerts); if (btgHead->numStars > 0) { btgTransStars = memAlloc(btgHead->numStars * sizeof(btgTransStar), "btg trans stars", NonVolatile); if (useVBO) glGenBuffers(1, &vboTransStars); } else { btgTransStars = NULL; } for (nVert = 0, pTransVert = btgTransVerts; nVert < btgHead->numVerts; nVert++, pTransVert++) { btgConvertVert(pTransVert, nVert); } for (nVert = 0, pTransStar = btgTransStars; nVert < btgHead->numStars; nVert++, pTransStar++) { btgConvertStar(pTransStar, nVert); } for (nPoly = 0, index = 0, pPoly = btgPolys; nPoly < btgHead->numPolys; nPoly++, pPoly++, index += 3) { btgIndices[index + 0] = pPoly->v0; btgIndices[index + 1] = pPoly->v1; btgIndices[index + 2] = pPoly->v2; } if (useVBO) { glBindBuffer(GL_ARRAY_BUFFER, vboTransStars); glBufferData(GL_ARRAY_BUFFER, btgHead->numStars * sizeof(btgTransStar), btgTransStars, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndices); glBufferData(GL_ELEMENT_ARRAY_BUFFER, btgHead->numPolys * 3 * sizeof(uword), btgIndices, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } }
/*----------------------------------------------------------------------------- Name : btgConvertVerts Description : transforms 2D BTG vertices into 3D Inputs : Outputs : btgTransVerts, btgTransStars are allocated and initialized Return : ----------------------------------------------------------------------------*/ void BtgBackground::btgConvertVerts() { udword nVert, nPoly, index; btgTransVertex* pTransVert; btgTransStar* pTransStar; BtgBackground::btgPolygon* pPoly; //btgZip(); btgTransVerts = (btgTransVertex *)malloc(btgHead->numVerts * sizeof(btgTransVertex)); if (btgHead->numStars > 0) { btgTransStars = (btgTransStar *)malloc(btgHead->numStars * sizeof(btgTransStar)); } else { btgTransStars = NULL; } for (nVert = 0, pTransVert = btgTransVerts; nVert < btgHead->numVerts; nVert++, pTransVert++) { btgConvertVert(pTransVert, nVert); } for (nVert = 0, pTransStar = btgTransStars; nVert < btgHead->numStars; nVert++, pTransStar++) { btgConvertStar(pTransStar, nVert); } for (nPoly = 0, index = 0, pPoly = btgPolys; nPoly < btgHead->numPolys; nPoly++, pPoly++, index += 3) { btgIndices[index + 0] = pPoly->v0; btgIndices[index + 1] = pPoly->v1; btgIndices[index + 2] = pPoly->v2; } }