void testTooManyPoints() { FTGL_DOUBLE testPoint[3] = { 1, 2, 3}; FTGL_DOUBLE* testOutput[] = { 0, 0, 0, 0}; void *pOutput = (void *)testOutput; FTGL_DOUBLE* hole[] = { 0, 0, 0, 0}; void *pHole = (void *)hole; FTMesh mesh; unsigned int x; ftglBegin(GL_TRIANGLES, &mesh); ftglCombine(testPoint, NULL, NULL, &pOutput, &mesh); for(x = 0; x < 200; ++x) { ftglCombine(testPoint, NULL, NULL, &pHole, &mesh); } CPPUNIT_ASSERT(*testOutput == static_cast<const FTGL_DOUBLE*>(mesh.TempPointList().front())); for(x = 201; x < 300; ++x) { ftglCombine(testPoint, NULL, NULL, &pHole, &mesh); } ftglEnd(&mesh); CPPUNIT_ASSERT(*testOutput == static_cast<const FTGL_DOUBLE*>(mesh.TempPointList().front())); }
void FTExtrudeGlyphImpl::RenderBack() { vectoriser->MakeMesh(-1.0, 2, backOutset); glNormal3f(0.0, 0.0, -1.0); GLfloat colors[4]; const FTMesh *mesh = vectoriser->GetMesh(); for(unsigned int j = 0; j < mesh->TesselationCount(); ++j) { const FTTesselation* subMesh = mesh->Tesselation(j); unsigned int polygonType = subMesh->PolygonType(); glGetFloatv(GL_CURRENT_COLOR, colors); glBindTexture(GL_TEXTURE_2D, 0); ftglBegin(polygonType); ftglColor4f(colors[0], colors[1], colors[2], colors[3]); for(unsigned int i = 0; i < subMesh->PointCount(); ++i) { FTPoint pt = subMesh->Point(i); ftglTexCoord2f(subMesh->Point(i).Xf() / hscale, subMesh->Point(i).Yf() / vscale); ftglVertex3f(subMesh->Point(i).Xf() / 64.0f, subMesh->Point(i).Yf() / 64.0f, -depth); } ftglEnd(); } }
void FTTextureFontImpl::PreRender() { disableTexture2D = false; disableBlend = false; GLfloat colors[4]; preRendered = true; if (!glIsEnabled(GL_BLEND)) { glEnable(GL_BLEND); disableBlend = true; } else { glGetIntegerv(GL_BLEND_SRC, &originalBlendSfactor); glGetIntegerv(GL_BLEND_DST, &originalBlendDfactor); } if (!glIsEnabled(GL_TEXTURE_2D)) { glEnable(GL_TEXTURE_2D); disableTexture2D = true; } // FTTextureGlyphImpl::ResetActiveTexture(); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glGetFloatv(GL_CURRENT_COLOR, colors); ftglColor4f(colors[0], colors[1], colors[2], colors[3]); ftglBegin(GL_QUADS); }
void FTPolygonGlyphImpl::DoRender() { GLfloat colors[4]; const FTMesh *mesh = vectoriser->GetMesh(); for(unsigned int t = 0; t < mesh->TesselationCount(); ++t) { const FTTesselation* subMesh = mesh->Tesselation(t); unsigned int polygonType = subMesh->PolygonType(); glGetFloatv(GL_CURRENT_COLOR, colors); glBindTexture(GL_TEXTURE_2D, 0); ftglBegin(polygonType); ftglColor4f(colors[0], colors[1], colors[2], colors[3]); for(unsigned int i = 0; i < subMesh->PointCount(); ++i) { FTPoint point = subMesh->Point(i); ftglTexCoord2f(point.Xf() / hscale, point.Yf() / vscale); ftglVertex3f(point.Xf() / 64.0f, point.Yf() / 64.0f, 0.0f); } ftglEnd(); } }
void FTExtrudeGlyphImpl::RenderSide() { int contourFlag = vectoriser->ContourFlag(); //LOG_INFO("RenderSide %d", contourFlag); GLfloat colors[4]; for(size_t c = 0; c < vectoriser->ContourCount(); ++c) { const FTContour* contour = vectoriser->Contour(c); size_t n = contour->PointCount(); if(n < 2) { continue; } glGetFloatv(GL_CURRENT_COLOR, colors); ftglBegin(GL_QUADS); ftglColor4f(colors[0]/2, colors[1]/2, colors[2]/2, colors[3]/2); for(size_t j = 0; j < n; j++ ) { size_t cur = j % n; size_t next = (j + 1) % n; FTPoint frontPt = contour->FrontPoint(cur); FTPoint frontPt1 = contour->FrontPoint(next); FTPoint backPt = contour->BackPoint(cur); FTPoint backPt1 = contour->BackPoint(next); FTPoint normal = FTPoint(0.f, 0.f, 1.f) ^ (frontPt - frontPt1); if(normal != FTPoint(0.0f, 0.0f, 0.0f)) { const FTGL_DOUBLE* pD = static_cast<const FTGL_DOUBLE*>(normal.Normalise()); glNormal3f( pD[0], pD[1], pD[2]); } ftglTexCoord2f(frontPt.Xf() / hscale, frontPt.Yf() / vscale); if(contourFlag & ft_outline_reverse_fill) { ftglVertex3f(backPt.Xf() / 64.0f, backPt.Yf() / 64.0f, 0.0f); ftglVertex3f(frontPt.Xf() / 64.0f, frontPt.Yf() / 64.0f, -depth); ftglVertex3f(frontPt1.Xf() / 64.0f, frontPt1.Yf() / 64.0f, -depth); ftglVertex3f(backPt1.Xf() / 64.0f, backPt1.Yf() / 64.0f, 0.0f); } else { ftglVertex3f(backPt.Xf() / 64.0f, backPt.Yf() / 64.0f, -depth); ftglVertex3f(frontPt.Xf() / 64.0f, frontPt.Yf() / 64.0f, 0.0f); ftglVertex3f(frontPt1.Xf() / 64.0f, frontPt1.Yf() / 64.0f, 0.f); ftglVertex3f(backPt1.Xf() / 64.0f, backPt1.Yf() / 64.0f, -depth); } } ftglEnd(); } }
void testAddPoint() { FTGL_DOUBLE testPoint[3] = { 1, 2, 3 }; FTGL_DOUBLE* hole[] = { 0, 0, 0, 0 }; void *pHole = (void *)hole; FTMesh mesh; CPPUNIT_ASSERT(mesh.TesselationCount() == 0); ftglBegin(GL_TRIANGLES, &mesh); ftglVertex(&POINT_DATA[0], &mesh); ftglVertex(&POINT_DATA[3], &mesh); ftglVertex(&POINT_DATA[6], &mesh); ftglVertex(&POINT_DATA[9], &mesh); ftglEnd(&mesh); CPPUNIT_ASSERT(mesh.TesselationCount() == 1); CPPUNIT_ASSERT(mesh.Tesselation(0)->PolygonType() == GL_TRIANGLES); CPPUNIT_ASSERT(mesh.Tesselation(0)->PointCount() == 4); CPPUNIT_ASSERT(mesh.Error() == 0); ftglBegin(GL_QUADS, &mesh); ftglVertex(&POINT_DATA[12], &mesh); ftglVertex(&POINT_DATA[15], &mesh); ftglError(2, &mesh); ftglVertex(&POINT_DATA[18], &mesh); ftglCombine(testPoint, NULL, NULL, &pHole, &mesh); ftglVertex(&POINT_DATA[21], &mesh); ftglError(3, &mesh); ftglEnd(&mesh); CPPUNIT_ASSERT(mesh.TesselationCount() == 2); CPPUNIT_ASSERT(mesh.Tesselation(0)->PointCount() == 4); CPPUNIT_ASSERT(mesh.Tesselation(1)->PolygonType() == GL_QUADS); CPPUNIT_ASSERT(mesh.Tesselation(1)->PointCount() == 4); CPPUNIT_ASSERT(mesh.Error() == 3); CPPUNIT_ASSERT(mesh.TesselationCount() == 2); }
void testGetTesselation() { FTMesh mesh; CPPUNIT_ASSERT( mesh.Tesselation(0) == NULL); ftglBegin( GL_TRIANGLES, &mesh); ftglVertex( &POINT_DATA[0], &mesh); ftglVertex( &POINT_DATA[3], &mesh); ftglVertex( &POINT_DATA[6], &mesh); ftglVertex( &POINT_DATA[9], &mesh); ftglEnd( &mesh); CPPUNIT_ASSERT( mesh.Tesselation(0)); CPPUNIT_ASSERT( mesh.Tesselation(10) == NULL); }
void FTTextureFontImpl::PreRender() { disableTexture2D = false; disableBlend = false; GLfloat colors[4]; preRendered = true; if (!glIsEnabled(GL_BLEND)) { glEnable(GL_BLEND); disableBlend = true; } else { #ifdef FTGLES2 originalBlendSfactor = 1.0f; originalBlendDfactor = 1.0f; #else glGetIntegerv(GL_BLEND_SRC, &originalBlendSfactor); glGetIntegerv(GL_BLEND_DST, &originalBlendDfactor); #endif } if (!glIsEnabled(GL_TEXTURE_2D)) { glEnable(GL_TEXTURE_2D); disableTexture2D = true; } glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); #ifdef FTGLES2 colors[0] = 1.0f; colors[1] = 1.0f; colors[2] = 1.0f; colors[3] = 1.0f; #else glGetFloatv(GL_CURRENT_COLOR, colors); #endif ftglColor4f(colors[0], colors[1], colors[2], colors[3]); ftglBegin(GL_QUADS); }
void FTPolygonGlyphImpl::DoRender(const FTPoint& pen) { const FTMesh *mesh = vectoriser->GetMesh(); for (unsigned int t = 0; t < mesh->TesselationCount(); ++t) { const FTTesselation* subMesh = mesh->Tesselation(t); unsigned int polygonType = subMesh->PolygonType(); ftglBindTexture(0); ftglBegin(polygonType); for(unsigned int i = 0; i < subMesh->PointCount(); ++i) { FTPoint point = subMesh->Point(i); ftglColor4f(1.0f, 1.0f, 1.0f, 1.0f); ftglTexCoord2f(point.Xf() / hscale, point.Yf() / vscale); ftglVertex3f(pen.Xf() + point.Xf() / 64.0f, pen.Yf() + point.Yf() / 64.0f, 0.0f); } ftglEnd(); } }
const FTPoint& FTTextureGlyphImpl::RenderImpl(const FTPoint& pen, int renderMode) { float dx, dy; GLfloat colors[4]; if(activeTextureID != glTextureID) { glBindTexture(GL_TEXTURE_2D, (GLuint)glTextureID); activeTextureID = glTextureID; } dx = floor(pen.Xf() + corner.Xf()); dy = floor(pen.Yf() + corner.Yf()); glGetFloatv(GL_CURRENT_COLOR, colors); ftglBegin(GL_QUADS); //ftglColor4f(colors[0], colors[1], colors[2], colors[3]); ftglTexCoord2f(uv[0].Xf(), uv[0].Yf()); ftglVertex2f(dx, dy); ftglTexCoord2f(uv[0].Xf(), uv[1].Yf()); ftglVertex2f(dx, dy - destHeight); ftglTexCoord2f(uv[1].Xf(), uv[1].Yf()); ftglVertex2f(dx + destWidth, dy - destHeight); ftglTexCoord2f(uv[1].Xf(), uv[0].Yf()); ftglVertex2f(dx + destWidth, dy); ftglEnd(); return advance; }