Exemple #1
0
void Canvas::setOperation(GLOperation const& op)
{
	if( op != glOperation_ ){
		flushGL();
		this->glOperation_ = op;
	}
}
Exemple #2
0
void Canvas::drawTexture(unsigned int texId, std::vector<float> const& pts, std::vector<float> const texCoords, Color const& color)
{
	this->bindTexture(texId);
	this->setColor(color);
	this->setOperation(Texture);
	this->texCoords_.insert(texCoords_.end(), texCoords.begin(), texCoords.end());
	this->vertexs_.insert(vertexs_.end(), pts.begin(), pts.end());
	flushGL();
}
Exemple #3
0
void Canvas::scissor(geom::Area const& area)
{
	flushGL();
	glScissor(area.x(), this->height_-area.height()-area.y(),area.width(), area.height());
#ifdef DEBUG
	const GLenum err = glGetError();
	if(err != GL_NO_ERROR){
		CINAMO_EXCEPTION(Exception, "[BUG] Failed to exec glScissor: 0x%08x", err);
	}
#endif
}
Exemple #4
0
void Canvas::bindTexture(GLuint texId)
{
	if(nowTexId_ != texId){
		flushGL();
		glBindTexture(GL_TEXTURE_2D, this->nowTexId_ = texId);
	#ifdef DEBUG
		const GLenum err = glGetError();
		if(err != GL_NO_ERROR){
			CINAMO_EXCEPTION(Exception, "[BUG] Failed to flush texture: 0x%08x", err);
		}
	#endif
	}
}
Exemple #5
0
void Canvas::drawLines(const float width, Color const& color, std::vector<geom::Point> const& pts, const float depth)
{
	if(color.isInvalid() || !(width > 0)){
		return;
	}
	this->setLineWidth(width);
	this->setColor(color);
	this->setOperation(LineStrip);
	for(geom::Point const& pt : pts){
		pushVertex(pt.x(), pt.y(), depth);
	}
	flushGL();
}
void DisplayOzone::presentScreen()
{
    if (!mCRTC)
    {
        // no monitor
        return;
    }

    // see if pending flip has finished, without blocking
    int fd = gbm_device_get_fd(mGBM);
    if (mPending)
    {
        pollfd pfd;
        pfd.fd     = fd;
        pfd.events = POLLIN;
        if (poll(&pfd, 1, 0) < 0)
        {
            std::cerr << "poll failed: " << errno << " " << strerror(errno) << std::endl;
        }
        if (pfd.revents & POLLIN)
        {
            drmEventContext event;
            event.version           = DRM_EVENT_CONTEXT_VERSION;
            event.page_flip_handler = pageFlipHandler;
            drmHandleEvent(fd, &event);
        }
    }

    // if pending flip has finished, schedule next one
    if (!mPending && mDrawing)
    {
        flushGL();
        if (mSetCRTC)
        {
            if (drmModeSetCrtc(fd, mCRTC->crtc_id, mDrawing->getDRMFB(), 0, 0,
                               &mConnector->connector_id, 1, mMode))
            {
                std::cerr << "set crtc failed: " << errno << " " << strerror(errno) << std::endl;
            }
            mSetCRTC = false;
        }
        if (drmModePageFlip(fd, mCRTC->crtc_id, mDrawing->getDRMFB(), DRM_MODE_PAGE_FLIP_EVENT,
                            this))
        {
            std::cerr << "page flip failed: " << errno << " " << strerror(errno) << std::endl;
        }
        mPending = mDrawing;
        mDrawing = nullptr;
    }
}
Exemple #7
0
void Canvas::setColor(Color const& color)
{
	if( color != nowColor_ ){
		flushGL();
		this->nowColor_ = color;
		glColor4f(nowColor_.red(), nowColor_.green(), nowColor_.blue(), nowColor_.alpha());
	#ifdef DEBUG
		const GLenum err = glGetError();
		if(err != GL_NO_ERROR){
			CINAMO_EXCEPTION(Exception, "[BUG] Failed to flush color: 0x%08x", err);
		}
	#endif
	}
}
Exemple #8
0
void Canvas::setLineWidth( float const& lineWidth )
{

	if( std::fabs(nowLineWidth_-lineWidth) >= 1.0f ) {
		flushGL();
		this->nowLineWidth_ = lineWidth;
		glLineWidth(nowLineWidth_);
	#ifdef DEBUG
		const GLenum err = glGetError();
		if(err != GL_NO_ERROR){
			CINAMO_EXCEPTION(Exception, "[BUG] Failed to flush line width: 0x%08x", err);
		}
	#endif
	}
}
Exemple #9
0
void Canvas::drawTexture(unsigned int texId, geom::Area const& areaInRoot, geom::Area const& coordinateInSprite, const float depth, Color const& color)
{
	const float x=areaInRoot.x();
	const float y=areaInRoot.y();
	const float width = areaInRoot.width();
	const float height = areaInRoot.height();

	const float top = coordinateInSprite.y();
	const float left = coordinateInSprite.x();
	const float right = coordinateInSprite.x()+coordinateInSprite.width();
	const float bottom = coordinateInSprite.y()+coordinateInSprite.height();
	this->bindTexture(texId);
	this->setColor(color);
	this->setOperation(Texture);
	pushTexCoord(left ,top   );pushVertex(x      , y       , depth);
	pushTexCoord(left ,bottom);pushVertex(x      , y+height, depth);
	pushTexCoord(right,top   );pushVertex(x+width, y       , depth);

	pushTexCoord(right,top   );pushVertex(x+width, y       , depth);
	pushTexCoord(left ,bottom);pushVertex(x      , y+height, depth);
	pushTexCoord(right,bottom);pushVertex(x+width, y+height, depth);
	flushGL();
}
Exemple #10
0
void Canvas::flush()
{
	flushGL();
}