Пример #1
0
void
Port::frameRect(const Quad& quad, Color rgba) {
	PortImpl& port = static_cast<PortImpl&>(*this); // get us access to our private data
	if (quad.getBounds().intersection(port.drawableRect()).empty()) return; // exit early if completely clipped
	port.setOpenGLModesForDrawing((rgba.alpha < 1.0f));  // sets up clip rect too

	glColor4f ( (float) rgba.red, rgba.green, rgba.blue, rgba.alpha);

	glBegin(GL_LINE_LOOP);
	glVertex2f( quad.points[lftBot].x, quad.points[lftBot].y );
	glVertex2f( quad.points[rgtBot].x, quad.points[rgtBot].y );
	glVertex2f( quad.points[rgtTop].x, quad.points[rgtTop].y );
	glVertex2f( quad.points[lftTop].x, quad.points[lftTop].y );
	glEnd();

/*	for some reason this mode generates a lot of flicker... possibly because it is drawing directly to the screen and not to the back buffer?
	GLshort thePoints[] = {
			rect.left, rect.top, // origin of the line
			rect.right, rect.top, // next line segment
			rect.right, rect.bottom, // next line segment
			rect.left, rect.bottom  // next line segment and back to first
	};
	glVertexPointer(2, GL_SHORT, 0, thePoints);
	glDrawArrays(GL_LINE_LOOP, 0, 4);
 */
	port.mNeedRedraw = true;
	gPortDirty = true;
}
Пример #2
0
void
Port::drawText(const char* text, const Quad& quad, int size, uint32 style, Color rgba) {
	if (text == 0) return;
	int len = std::strlen(text);
	if (len == 0) return;
	PortImpl& port = static_cast<PortImpl&>(*this); // get us access to our private data
	if (quad.getBounds().intersection(port.drawableRect()).empty()) return; // exit early if completely clipped
#ifdef PDG_DEBUG_TEXT_DRAWING
	port.frameRect(quad, PDG_MAGENTA_COLOR); // draw text bounding box
#endif
	graphics_drawText(port, text, len, quad, size, style, rgba);
	port.mNeedRedraw = true;
	gPortDirty = true;
}
Пример #3
0
void
Port::fillRect(const Quad& quad, Color rgba) {
	PortImpl& port = static_cast<PortImpl&>(*this); // get us access to our private data
	if (quad.getBounds().intersection(port.drawableRect()).empty()) return; // exit early if completely clipped
	port.setOpenGLModesForDrawing((rgba.alpha != 1.0f));  // sets up clip rect too

	glColor4f( rgba.red, rgba.green, rgba.blue, rgba.alpha );

	glBegin(GL_TRIANGLE_STRIP);
	glVertex2f( quad.points[lftBot].x, quad.points[lftBot].y );
	glVertex2f( quad.points[lftTop].x, quad.points[lftTop].y );
	glVertex2f( quad.points[rgtBot].x, quad.points[rgtBot].y );
	glVertex2f( quad.points[rgtTop].x, quad.points[rgtTop].y );
	glEnd();
	port.mNeedRedraw = true;
	gPortDirty = true;
}