Beispiel #1
0
void Device_OpenGL::Draw2DTextureFullViewport(Texture* texture)
{
    DisableDepthTest();
    PushMatrix();
    SetIdentityMatrix();
    UnbindVBO(VBO::VBO_TARGET_ARRAY_BUFFER);
    //-------------------------------------------
    float x = Screen::GetInstance()->GetRatio();
    float y = 1.0f;
    float z = -1.0f;
    float vertices[30] = { -x, y, z, 0.0f, 1.0f,
                           -x, -y, z, 0.0f, 0.0f,
                           x, -y, z, 1.0f, 0.0f,
                           -x, y, z, 0.0f, 1.0f,
                           x, -y, z, 1.0f, 0.0f,
                           x, y, z, 1.0f, 1.0f
                         };
    SetAttributePointer(ATTRIBUTE_FLOAT3_POSITION, vertices, sizeof(float) * 5);
    SetAttributePointer(ATTRIBUTE_FLOAT2_TEXCOORD_DIFFUSE, vertices + 3, sizeof(float) * 5);
    Device_Base::GetInstance()->UpdateVertexAttribPointer();
    Device_Base::GetInstance()->SetUniformTexture(UNIFORM_TEXTURE_DIFFUSE, texture);
    Device_Base::GetInstance()->SetUniformMatrix(UNIFORM_MATRIX_MODEL, Device_Base::GetInstance()->GetMatrixWorld());
    Device_Base::GetInstance()->SetUniformMatrix(UNIFORM_MATRIX_PROJECTION, m_MatrixProjection2DLogical);

    Device_Base::GetInstance()->DrawArray(Device_Base::PRIMITIVE_TRIANGLE_LIST, 0, 6);
    //-------------------------------------------
    EnableDepthTest();
    PopMatrix();

}
Beispiel #2
0
    void Graphics::ResetCachedState()
    {
        Program::Clear();

        viewport_ = Recti(0);

        glGetIntegerv(GL_FRAMEBUFFER_BINDING, &systemFbo_); // On IOS default FBO is not zero

        // Set up texture data read/write alignment
        glPixelStorei(GL_PACK_ALIGNMENT, 1);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

        VertexArrayObj::Clear();
        lastMesh_ = nullptr;
        lastProgram_ = nullptr;
        activeMesh_ = nullptr;
        activeWindow_ = nullptr;

        CHECK_GL_STATUS();

        SetClearColor(Color(0, 0, 0, 1));
        SetClearDepth(1);
        SetClearStencil(0);
        SetFrameBuffer(nullptr);
        SetStencilTest(DEFAULT_STENCIL_ENABLE, DEFAULT_STENCIL_WRITEMASK, DEFAULT_STENCIL_SFAIL,
                       DEFAULT_STENCIL_DPFAIL, DEFAULT_STENCIL_DPPASS, DEFAULT_STENCIL_FUNC, DEFAULT_STENCIL_REF, DEFAULT_STENCIL_COMPAREMASK);
        SetScissorTest();

        CHECK_GL_STATUS();

        SetColorMask(DEFAULT_COLOR_MASK);
        SetDepthMask(DEFAULT_DEPTH_MASK);
        SetDepthFunc(DepthFunc::LESS);
        SetStencilMask(DEFAULT_STENCIL_MASK);
        SetBlendModeTest(DEFAULT_BLEND_MODE);
        EnableDepthTest(DEFAULT_DEPTH_TEST_ENABLE);
        EnableCullFace(DEFAULT_CULL_FACE_ENABLE);
        SetCullFace(CullFaceMode::DEFAULT);
        SetFrontFace(FrontFaceMode::DEFAULT);
        CHECK_GL_STATUS();

        UnboundTextures();
        SetVertexArrayObj(nullptr);
        SetVertexBuffer(nullptr);
        SetIndexBuffer(nullptr);
        SetProgram(nullptr);
        SetSlopeScaledBias(0);

        CHECK_GL_STATUS();
    }
Beispiel #3
0
bool POD3DLayer::Initialize()
{
	RETURN_FALSE_IF_FALSE(BaseCaseLayer::Initialize());

	auto state = this->MutableRenderState().AllocState<RasterizerRenderState>();
	state->SetCullMode(GraphicsFace::Back);
	state->Enable(true);

	auto depthState = this->MutableRenderState().AllocState<DepthStencilRenderState>();
	depthState->EnableDepthTest(true);

	auto* shape1 = NodeFactory::Instance().CreatePODSprite("Scene.pod");
	//shape1->SetAnchor(0.5f, 0.5f);
	//shape1->SetDock(DockPoint::MiddleCenter);
	AddChild(shape1);

	return true;
}