私は数日間私を "悩ませている"面白いバグを持っています。GLStippleを使用すると、OGLFTがテキストを描画します
現在、OpenGLを使用して画面にテキストを描画しています。 OGLFTライブラリを利用して図面を支援しています。このライブラリは実際にfreetype2ライブラリを使用します。私は実際にテキストで特別なことをしていません。私は単色のテキストだけを探しています。
とにかく、ライブラリを実装した後、glStippleを有効にしたときにテキストが正しく描かれていることに気付きました。私はOGLFTライブラリと私が可能にしているものとの間にいくつかの干渉問題があると信じています。
OGLFTライブラリの使用経験がある方がいらっしゃいますか?
(私のglCanvasのズーム係数とカメラの位置に使用されるいくつかの変数があり、これが唯一のものであることに注意してください2Dの場合)
double _zoomX = 1.0;
double _zoomY = 1.0;
double _cameraX = 0;
double _cameraY = 0;
/* This function gets called everytime a draw routine is needed */
void modelDefinition::onPaintCanvas(wxPaintEvent &event)
{
wxGLCanvas::SetCurrent(*_geometryContext);// This will make sure the the openGL commands are routed to the wxGLCanvas object
wxPaintDC dc(this);// This is required for drawing
glMatrixMode(GL_MODELVIEW);
glClear(GL_COLOR_BUFFER_BIT);
updateProjection();
OGLFT::Monochrome *testface = new OGLFT::Monochrome("/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf", 8);
testface->draw(0, 0, "test");
glEnable(GL_LINE_STIPPLE);// WHen I comment out this line, the text is unable to be drawn
glLineStipple(1, 0b0001100011000110);
glBegin(GL_LINES);
glVertex2d(_startPoint.x, _startPoint.y);
glVertex2d(_endPoint.x, _endPoint.y);
glEnd();
glDisable(GL_LINE_STIPPLE);
SwapBuffers();
}
void modelDefinition::updateProjection()
{
// First, load the projection matrix and reset the view to a default view
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-_zoomX, _zoomX, -_zoomY, _zoomY, -1.0, 1.0);
//Reset to modelview matrix
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0, 0, (double)this->GetSize().GetWidth(), (double)this->GetSize().GetHeight());
/* This section will handle the translation (panning) and scaled (zooming).
* Needs to be called each time a draw occurs in order to update the placement of all the components */
if(_zoomX < 1e-9 || _zoomY < 1e-9)
{
_zoomX = 1e-9;
_zoomY = _zoomX;
}
if(_zoomX > 1e6 || _zoomY > 1e6)
{
_zoomX = 1e6;
_zoomY = _zoomX;
}
glTranslated(-_cameraX, -_cameraY, 0.0);
}
また、glEnable(GL_LINE_STIPPLE);
以下のコードが必要です。これは、テキストが正しく表示されるようにglStippleを正しく描画する必要があるかのようです。
はい!それはそれだった、すべて今働く。どうもありがとうございます! – codingDude