void BWLCD::OnPaint( wxPaintEvent& event ) { if (state == NULL) return; wxPaintDC dc(displayPanel); dc.SetPen(wxNullPen); wxColour oncolor(on); wxColour offcolor(off); wxBrush onBrush(oncolor); wxBrush offBrush(offcolor); int cw, ch; displayPanel->GetSize(&cw, &ch); int tw = cw / width; int th = ch / height; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { if (state->mem[startaddr + j + i * width]) dc.SetBrush(onBrush); else dc.SetBrush(offBrush); dc.DrawRectangle(j * tw, i * th, tw, th); } } }
void MapReader::createBrush(const size_t startLine, const size_t lineCount, const ExtraAttributes& extraAttributes) { try { // sort the faces by the weight of their plane normals like QBSP does Model::BrushFace::sortFaces(m_faces); Model::Brush* brush = m_factory->createBrush(m_worldBounds, m_faces); setFilePosition(brush, startLine, lineCount); setExtraAttributes(brush, extraAttributes); onBrush(m_brushParent, brush); m_faces.clear(); } catch (GeometryException& e) { if (logger() != NULL) logger()->error("Error parsing brush at line %u: %s", startLine, e.what()); m_faces.clear(); // the faces will have been deleted by the brush's constructor } }