示例#1
0
void GLPrimitiveRenderer::drawRect(float x0, float y0, float x1, float y1, float color[4])
{
	assert(glGetError()==GL_NO_ERROR);
	glActiveTexture(GL_TEXTURE0);
	assert(glGetError()==GL_NO_ERROR);
	
	 glBindTexture(GL_TEXTURE_2D,m_data->m_texturehandle);
	assert(glGetError()==GL_NO_ERROR);
	drawTexturedRect(x0,y0,x1,y1,color,0,0,1,1);
	assert(glGetError()==GL_NO_ERROR);

}
示例#2
0
文件: UIContext.cpp 项目: Daivuk/onut
 void UIContext::renderScale9Component(const OUIControlRef& pControl, const Rect& rect, const UIScale9Component& scale9Component)
 {
     if (scale9Component.image.filename.empty())
     {
         drawRect(pControl, rect, scale9Component.image.color);
     }
     else if (scale9Component.isScaled9)
     {
         drawScale9Rect(pControl, rect, scale9Component);
     }
     else
     {
         drawTexturedRect(pControl, rect, scale9Component.image);
     }
 }
void StelQGLRenderer::drawWindow(StelViewportEffect* const effect)
{
	// At this point, FBOs have been released (if using FBOs), so we're drawing 
	// directly to the screen. The StelViewportEffect::drawToViewport call 
	// actually draws puts the rendered result onto the viewport.
	invariant();

	//Warn about any GL errors.
	checkGLErrors("drawWindow() start");
	
	//Effects are ignored when FBO is not supported.
	//That might be changed for some GPUs, but it might not be worth the effort.
	
	viewport.prepareToDrawViewport();

	if(NULL == effect)
	{
		// If using FBO, we still need to put it on the screen.
		if(viewport.useFBO())
		{
			StelTextureNew* screenTexture = getViewportTexture();
			const QSize size = screenTexture->getDimensions();

			glDisable(GL_BLEND);
			setGlobalColor(Vec4f(1.0f, 1.0f, 1.0f, 1.0f));
			screenTexture->bind();
			drawTexturedRect(0, 0, size.width(), size.height());
			delete screenTexture;
		}
		// If not using FBO, the result is already drawn to the screen.
	}
	else
	{
		effect->drawToViewport(this);
	}

	viewport.disablePainting();

	checkGLErrors("drawWindow() end");
	invariant();
}
示例#4
0
void TinyRendererSetup::stepSimulation(float deltaTime)
{
    m_internalData->updateTransforms();
    
    if (!m_useSoftware)
    {
        
        for (int i=0;i<m_internalData->m_transforms.size();i++)
        {
            m_guiHelper->getRenderInterface()->writeSingleInstanceTransformToCPU(m_internalData->m_transforms[i].getOrigin(),m_internalData->m_transforms[i].getRotation(),i);
        }
        m_guiHelper->getRenderInterface()->writeTransforms();
        m_guiHelper->getRenderInterface()->renderScene();
    } else
    {
        
        TGAColor clearColor;
        clearColor.bgra[0] = 200;
        clearColor.bgra[1] = 200;
        clearColor.bgra[2] = 200;
        clearColor.bgra[3] = 255;
        for(int y=0;y<m_internalData->m_height;++y)
        {
            for(int x=0;x<m_internalData->m_width;++x)
            {
                m_internalData->m_rgbColorBuffer.set(x,y,clearColor);
                m_internalData->m_depthBuffer[x+y*m_internalData->m_width] = -1e30f;
            }
        }


        ATTRIBUTE_ALIGNED16(btScalar modelMat2[16]);
        ATTRIBUTE_ALIGNED16(float viewMat[16]);
        ATTRIBUTE_ALIGNED16(float projMat[16]);
        CommonRenderInterface* render = this->m_app->m_renderer;
        render->getActiveCamera()->getCameraViewMatrix(viewMat);
        render->getActiveCamera()->getCameraProjectionMatrix(projMat);
            

        
        for (int o=0;o<this->m_internalData->m_renderObjects.size();o++)
        {
                
            const btTransform& tr = m_internalData->m_transforms[o];
            tr.getOpenGLMatrix(modelMat2);
            
                    
            for (int i=0;i<4;i++)
            {
                for (int j=0;j<4;j++)
                {
                    m_internalData->m_renderObjects[o]->m_modelMatrix[i][j] = float(modelMat2[i+4*j]);
                    m_internalData->m_renderObjects[o]->m_viewMatrix[i][j] = viewMat[i+4*j];
                    m_internalData->m_renderObjects[o]->m_projectionMatrix[i][j] = projMat[i+4*j];
                    
                    float eye[4];
                    float center[4];
                    render->getActiveCamera()->getCameraPosition(eye);
                    render->getActiveCamera()->getCameraTargetPosition(center);

                    m_internalData->m_renderObjects[o]->m_eye.setValue(eye[0],eye[1],eye[2]);
                    m_internalData->m_renderObjects[o]->m_center.setValue(center[0],center[1],center[2]);
                }
            }
            TinyRenderer::renderObject(*m_internalData->m_renderObjects[o]);
        }
        //m_app->drawText("hello",500,500);
        render->activateTexture(m_internalData->m_textureHandle);
        render->updateTexture(m_internalData->m_textureHandle,m_internalData->m_rgbColorBuffer.buffer());
        float color[4] = {1,1,1,1};
        m_app->drawTexturedRect(0,0,m_app->m_window->getWidth(), m_app->m_window->getHeight(),color,0,0,1,1,true);
    }
}
示例#5
0
void po::drawTexturedRect(poTexture *tex, poRect rect, poTextureFitOption fit, poAlignment align) {
	std::vector<poPoint> coords = textureFit(rect, tex, fit, align);
	poRect coords_rect(coords[0], coords[2]);
	drawTexturedRect(tex, rect, coords_rect);
}
示例#6
0
void po::drawTexturedRect(poTexture *tex, poRect rect) {
	drawTexturedRect(tex, rect, poRect(0,0,1,1));
}
示例#7
0
void po::drawTexturedRect(poTexture *tex, float x, float y, float w, float h) {
	drawTexturedRect(tex, poRect(x,y,w,h), poRect(0,0,1,1));
}
示例#8
0
void po::drawTexturedRect(poTexture *tex) {
	drawTexturedRect(tex, poRect(0,0,tex->getWidth(),tex->getHeight()), poRect(0,0,1,1));
}