Ejemplo n.º 1
0
void RenderState::StateBlock::setState(const char* name, const char* value)
{
    GP_ASSERT(name);

    if (strcmp(name, "blend") == 0)
    {
        setBlend(parseBoolean(value));
    }
    else if (strcmp(name, "blendSrc") == 0 || strcmp(name, "srcBlend") == 0 )   // Leaving srcBlend for backward compat.
    {
        setBlendSrc(parseBlend(value));
    }
    else if (strcmp(name, "blendDst") == 0 || strcmp(name, "dstBlend") == 0)    // // Leaving dstBlend for backward compat.
    {
        setBlendDst(parseBlend(value));
    }
    else if (strcmp(name, "cullFace") == 0)
    {
        setCullFace(parseBoolean(value));
    }
    else if (strcmp(name, "depthTest") == 0)
    {
        setDepthTest(parseBoolean(value));
    }
    else if (strcmp(name, "depthWrite") == 0)
    {
        setDepthWrite(parseBoolean(value));
    }
    else
    {
        GP_ERROR("Unsupported render state string '%s'.", name);
    }
}
Ejemplo n.º 2
0
void OpenGLRenderer::setDrawState(const glm::mat4& model, DrawBuffer* draw,
                                  const Renderer::DrawParameters& p) {
    useDrawBuffer(draw);

    for (GLuint u = 0; u < p.textures.size(); ++u) {
        useTexture(u, p.textures[u]);
    }

    setBlend(p.blendMode);
    setDepthWrite(p.depthWrite);
    setDepthMode(p.depthMode);

    ObjectUniformData objectData{model,
                             glm::vec4(p.colour.r / 255.f, p.colour.g / 255.f,
                                       p.colour.b / 255.f, p.colour.a / 255.f),
                             1.f, 1.f, p.visibility};
    uploadUBO(UBOObject, objectData);

    drawCounter++;
#ifdef RW_GRAPHICS_STATS
    if (currentDebugDepth > 0) {
        profileInfo[currentDebugDepth - 1].draws++;
        profileInfo[currentDebugDepth - 1].primitives += p.count;
    }
#endif
}
Ejemplo n.º 3
0
GLRender::GLRender(GLint clientWidth, GLint clientHeight) throw(const char*)
: GLCore(clientWidth, clientHeight)
{
	textures = new GLTextures(this);
	shaders = new GLShaders(this);
	sprites = new GLSprites(this);
	scenes = new GLScenes(this);
	cameras = new GLCameras(this);
	models = new GLModels(this);
	particles = new GLParticles(this);
	drawings = new GLDrawings(this);
	funcs = new GLFuncs(this);
	mixer = new GLSoundMixer(this);
	
	cameras->createCamera(L"gui")->size(clientWidth, clientHeight)->layer(0, 0);
	cameras->createCamera(L"background")->size(clientWidth, clientHeight)->background();
	lightsMaxCount = 6;
	
	setDepth(1.0, 0.0, 1.0, GL_LEQUAL);
	setBlend(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_FUNC_ADD);
	glClearColor(0.0, 0.0, 0.0, 1.0);
	glClear(GL_COLOR_BUFFER_BIT);
	
	glGenBuffers(1, &m_squareBuffer);
	glGenBuffers(1, &m_textureBuffer);
	glGenBuffers(1, &m_normalBuffer);
	glGenBuffers(1, &m_indexBuffer);
	
	light.set(1.0);
	LOG("GLRender Create");
}
Ejemplo n.º 4
0
void OpenGLRenderer::invalidate() {
    currentDbuff = nullptr;
    currentProgram = nullptr;
    currentTextures.clear();
    currentUBO = 0;
    setBlend(BlendMode::BLEND_NONE);
    setDepthMode(DepthMode::OFF);
}
Ejemplo n.º 5
0
void RenderSystem::setBlendMode(
    RenderSystem::BlendMode mode
) {
    if (mode == BlendMode::NONE) {
        setBlend(false);
    } else if (mode == BlendMode::ADD) {
        setBlend(true);
        setBlendFunctionType(
            BlendFunctionType::TYPE_SRC_ALPHA,
            BlendFunctionType::TYPE_ONE
        );
    } else {
        setBlend(true);
        setBlendFunctionType(
            BlendFunctionType::TYPE_SRC_ALPHA,
            BlendFunctionType::TYPE_ONE_MINUS_SRC_ALPHA
        );
    }
    
}
Ejemplo n.º 6
0
void
ControlPanel::initPoseParameters()
{
	CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr();
	if (hdr)
	{
		for (int i = 0; i < hdr->GetNumPoseParameters(); i++)
		{
			setBlend( i, 0.0 );
		}
	}
}
Ejemplo n.º 7
0
// ***************************************************************************
void			CMaterial::initUnlit()
{
	setShader(Normal);
	setLighting(false);
	setColor(CRGBA(255,255,255,255));
	for(uint32 i=0;i<IDRV_MAT_MAXTEXTURES;i++)
		setTexture((uint8)i ,NULL);
	setZBias(0);
	setZFunc(lessequal);
	setZWrite(true);
	setBlend(false);
	setAlphaTestThreshold(0.5f);
}
Ejemplo n.º 8
0
void the::object::orderSort()
{
    bool blend = false;
    for (auto & s : surfaces) blend = blend || s.getBlending();
    setBlend(blend);    
    if(blend)
    {    
        for (auto & s : surfaces) s.unbind();
        std::sort(surfaces.begin(), surfaces.end(),[&](the::surface l, the::surface r) 
        {
            return (l.getRenderOrder() < r.getRenderOrder());
        });
        for (auto & s : surfaces) s.bind();
    } 
    for(auto &ch : childs) ch->orderSort(); 
    remap();  
}
Ejemplo n.º 9
0
void State::setEnableFeature(GLenum feature, bool enabled)
{
    switch (feature)
    {
      case GL_CULL_FACE:                     setCullFace(enabled);              break;
      case GL_POLYGON_OFFSET_FILL:           setPolygonOffsetFill(enabled);     break;
      case GL_SAMPLE_ALPHA_TO_COVERAGE:      setSampleAlphaToCoverage(enabled); break;
      case GL_SAMPLE_COVERAGE:               setSampleCoverage(enabled);        break;
      case GL_SCISSOR_TEST:                  setScissorTest(enabled);           break;
      case GL_STENCIL_TEST:                  setStencilTest(enabled);           break;
      case GL_DEPTH_TEST:                    setDepthTest(enabled);             break;
      case GL_BLEND:                         setBlend(enabled);                 break;
      case GL_DITHER:                        setDither(enabled);                break;
      case GL_PRIMITIVE_RESTART_FIXED_INDEX: UNIMPLEMENTED();                   break;
      case GL_RASTERIZER_DISCARD:            setRasterizerDiscard(enabled);     break;
      default:                               UNREACHABLE();
    }
}
CTransitionPostProc::CTransitionPostProc( IPostProc* follow1, IPostProc* follow2, DIMENSION2D sOut, irr::video::ITexture* m ) : IPostProc( follow1, sOut ) {
    irr::video::IVideoDriver* driver = smgr->getVideoDriver( );
    irr::video::IGPUProgrammingServices* gpu = driver->getGPUProgrammingServices( );

    tmap = m;
    ps = 0.0f;

    if( supported ) {
        scTrans = CShaderCallback( );
        scTrans.usesnum = 1u;

        irr::s32 matid, matidFast;
        switch( driver->getDriverType( ) ) {
        case irr::video::EDT_OPENGL:
            matid = gpu->addHighLevelShaderMaterial( GL_V_FULLSCREEN, "main", irr::video::EVST_VS_1_1, GL_TRANSMAP, "main", irr::video::EPST_PS_1_1, &scTrans, irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL, 2 );
            matidFast = gpu->addHighLevelShaderMaterial( GL_V_FULLSCREEN, "main", irr::video::EVST_VS_1_1, GL_TRANSMAPFAST, "main", irr::video::EPST_PS_1_1, &scTrans, irr::video::EMT_SOLID, 2 );
            break;
        case irr::video::EDT_DIRECT3D9:
            matid = gpu->addHighLevelShaderMaterial( DX_V_FULLSCREEN, "main", irr::video::EVST_VS_1_1, DX_TRANSMAP, "main", irr::video::EPST_PS_2_0, &scTrans, irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL, 0 );
            matidFast = gpu->addHighLevelShaderMaterial( DX_V_FULLSCREEN, "main", irr::video::EVST_VS_1_1, DX_TRANSMAPFAST, "main", irr::video::EPST_PS_1_4, &scTrans, irr::video::EMT_SOLID, 0 );
            break;
        }

        mat = irr::video::SMaterial( );
        mat.MaterialType = (irr::video::E_MATERIAL_TYPE) matid;
        mat.Wireframe = false;
        mat.Lighting = false;
        mat.FogEnable = false;
        mat.ZBuffer = 0;
        mat.setTexture( 1u, tmap );
        mat.TextureLayer[ 0u ].TextureWrapU = irr::video::ETC_CLAMP_TO_EDGE;
        mat.TextureLayer[ 0u ].TextureWrapV = irr::video::ETC_CLAMP_TO_EDGE;
        mat.TextureLayer[ 1u ].TextureWrapU = irr::video::ETC_CLAMP_TO_EDGE;
        mat.TextureLayer[ 1u ].TextureWrapV = irr::video::ETC_CLAMP_TO_EDGE;
        mat.TextureLayer[ 0u ].BilinearFilter = false;

        mat = irr::video::SMaterial( mat );
        matFast.MaterialType = (irr::video::E_MATERIAL_TYPE) matidFast;
        matFast.TextureLayer[ 1u ].BilinearFilter = false;
    }
    setInput( 0u, follow1 );
    setInput( 1u, follow2 );
    setBlend( 0.0f );
}
Ejemplo n.º 11
0
void RenderState::StateBlock::setState(const std::string& name, const std::string& value)
{
    if (name.compare("blend") == 0)
    {
        setBlend(parseBoolean(value));
    }
    else if (name.compare("blendSrc") == 0)
    {
        setBlendSrc(parseBlend(value));
    }
    else if (name.compare("blendDst") == 0)
    {
        setBlendDst(parseBlend(value));
    }
    else if (name.compare("cullFace") == 0)
    {
        setCullFace(parseBoolean(value));
    }
    else if (name.compare("cullFaceSide") == 0)
    {
        setCullFaceSide(parseCullFaceSide(value));
    }
    else if (name.compare("frontFace") == 0)
    {
        setFrontFace(parseFrontFace(value));
    }
    else if (name.compare("depthTest") == 0)
    {
        setDepthTest(parseBoolean(value));
    }
    else if (name.compare("depthWrite") == 0)
    {
        setDepthWrite(parseBoolean(value));
    }
    else if (name.compare("depthFunc") == 0)
    {
        setDepthFunction(parseDepthFunc(value));
    }
    else if (name.compare("stencilTest") == 0)
    {
        setStencilTest(parseBoolean(value));
    }
    else if (name.compare("stencilWrite") == 0)
    {
        setStencilWrite(parseUInt(value));
    }
    else if (name.compare("stencilFunc") == 0)
    {
        setStencilFunction(parseStencilFunc(value), _stencilFunctionRef, _stencilFunctionMask);
    }
    else if (name.compare("stencilFuncRef") == 0)
    {
        setStencilFunction(_stencilFunction, parseInt(value), _stencilFunctionMask);
    }
    else if (name.compare("stencilFuncMask") == 0)
    {
        setStencilFunction(_stencilFunction, _stencilFunctionRef, parseUInt(value));
    }
    else if (name.compare("stencilOpSfail") == 0)
    {
        setStencilOperation(parseStencilOp(value), _stencilOpDpfail, _stencilOpDppass);
    }
    else if (name.compare("stencilOpDpfail") == 0)
    {
        setStencilOperation(_stencilOpSfail, parseStencilOp(value), _stencilOpDppass);
    }
    else if (name.compare("stencilOpDppass") == 0)
    {
        setStencilOperation(_stencilOpSfail, _stencilOpDpfail, parseStencilOp(value));
    }
    else
    {
        CCLOG("Unsupported render state string '%s'.", name.c_str());
    }
}
Ejemplo n.º 12
0
void poOpenGLState::popBlendState() {
	setBlend(blendStack.top());
	blendStack.pop();
}
Ejemplo n.º 13
0
int
ControlPanel::handleEvent (mxEvent *event)
{
	MDLCACHE_CRITICAL_SECTION_( g_pMDLCache );

	int iret = 0;
	
	if ( HandleToolEvent( event ) )
	{
		return iret;
	}

	switch ( event->event )
	{
	case mxEvent::Size:
		{
			PositionControls( event->width, event->height );
			iret = 1;
		}
		break;
	case mxEvent::Action:
		{
			iret = 1;
			switch (event->action)
			{
			case IDC_TOOLSDRIVEMOUTH:
				{
					g_viewerSettings.faceposerToolsDriveMouth = ((mxCheckBox *)event->widget)->isChecked();
				}
				break;
			case IDC_TAB:
				{
					g_viewerSettings.showTexture = (tab->getSelectedIndex() == 3);
				}
				break;
				
			case IDC_RENDERMODE:
				{
					int index = cRenderMode->getSelectedIndex();
					if (index >= 0)
					{
						setRenderMode (index);
					}
				}
				break;
				
			case IDC_GROUND:
				setShowGround (((mxCheckBox *) event->widget)->isChecked());
				break;
				
			case IDC_MOVEMENT:
				setShowMovement (((mxCheckBox *) event->widget)->isChecked());
				break;
				
			case IDC_BACKGROUND:
				setShowBackground (((mxCheckBox *) event->widget)->isChecked());
				break;
				
			case IDC_HITBOXES:
				g_viewerSettings.showHitBoxes = ((mxCheckBox *) event->widget)->isChecked();
				break;
				
			case IDC_PHYSICSMODEL:
				g_viewerSettings.showPhysicsModel = ((mxCheckBox *) event->widget)->isChecked();
				break;
				
			case IDC_BONES:
				g_viewerSettings.showBones = ((mxCheckBox *) event->widget)->isChecked();
				break;
				
			case IDC_ATTACHMENTS:
				g_viewerSettings.showAttachments = ((mxCheckBox *) event->widget)->isChecked();
				break;
				
			case IDC_SEQUENCE:
				{
					int index = cSequence->getSelectedIndex();
					if (index >= 0)
					{
						setSequence ( index );
					}
				}
				break;
			
			case IDC_SPEEDSCALE:
				{
					g_viewerSettings.speedScale = ((mxSlider *) event->widget)->getValue();
					lSpeedScale->setLabel( va( "Speed scale %.2f", g_viewerSettings.speedScale ) );
				}
				break;
				
			case IDC_PRIMARYBLEND:
				{
					setBlend( 0, ((mxSlider *) event->widget)->getValue() );
				}
				break;
				
			case IDC_SECONDARYBLEND:
				{
					setBlend( 1, ((mxSlider *) event->widget)->getValue() );
				}
				break;
				
			case IDC_BODYPART:
				{
					int index = cBodypart->getSelectedIndex();
					if (index >= 0)
					{
						setBodypart (index);
						
					}
				}
				break;
				
			case IDC_SUBMODEL:
				{
					int index = cSubmodel->getSelectedIndex();
					if (index >= 0)
					{
						setSubmodel (index);
						
					}
				}
				break;
				
			case IDC_CONTROLLER:
				{
					int index = cController->getSelectedIndex();
					if (index >= 0)
						setBoneController (index);
				}
				break;
				
			case IDC_CONTROLLERVALUE:
				{
					int index = cController->getSelectedIndex();
					if (index >= 0)
						setBoneControllerValue (index, slController->getValue());
				}
				break;
				
			case IDC_SKINS:
				{
					int index = cSkin->getSelectedIndex();
					if (index >= 0)
					{
						models->GetActiveStudioModel()->SetSkin (index);
						g_viewerSettings.skin = index;
						g_pMatSysWindow->redraw();
					}
				}
				break;
			default:
				iret = 0;
				break;
			}
		}
	}

	return iret;
}