Beispiel #1
0
//-------------------------------------------------------------
void XSurfaceOpenGL::DrawLocal( float x, float y, float lx, float ly )
{
    if( GetDrawMode() != xDM_NONE )
    {
        glPushMatrix();

        if( GetDrawMode() == xDM_NORMAL )
            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        else if( GetDrawMode() == xDM_SCREEN )
            glBlendFunc(GL_SRC_ALPHA, GL_ONE );
        glTranslatef( x, y, 0);
        glTranslatef( m_fAdjustAxisX, m_fAdjustAxisY, 0 );
        if( m_fRotX )
            glRotatef( m_fRotX, 1.0f, 0, 0 );
        if( m_fRotY )
            glRotatef( m_fRotY, 0, 1.0f, 0 );
        if( m_fRotZ )
            glRotatef( m_fRotZ, 0, 0, 1.0f );
        if( m_fScaleX != 1.0f || m_fScaleY != 1.0f || m_fScaleZ != 1.0f )
            glScalef( m_fScaleX, m_fScaleY, m_fScaleZ );
        glTranslatef( -m_fAdjustAxisX, -m_fAdjustAxisY, 0 );		// 좌표축을 돌린 후 움직인다
        glTranslatef( lx, ly, 0);
        if( m_fAlpha < 1.0f )
            DrawCoreAlpha();
        else
            DrawCore();

        glPopMatrix();
    }
    m_fRotX = m_fRotY = m_fRotZ = 0;
    m_fScaleX = m_fScaleY = 1.0f;
    m_fAdjustAxisX = m_fAdjustAxisY = 0;
    m_ColorR = m_ColorG = m_ColorB = 1.0f;
} // draw local
void Renderer::DrawVBO_PCUTB(unsigned int vboID, int numVerts, DrawMode drawMode /*= QUADS*/, Texture* texture /*= nullptr*/)
{
	if (!texture)
	{
		texture = m_defaultTexture;
	}
	BindTexture(*texture);
	glBindBuffer(GL_ARRAY_BUFFER, vboID);

	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_COLOR_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);

	glVertexPointer(3, GL_FLOAT, sizeof(Vertex_PCUTB), (const GLvoid*)offsetof(Vertex_PCUTB, pos));
	glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex_PCUTB), (const GLvoid*)offsetof(Vertex_PCUTB, color));
	glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex_PCUTB), (const GLvoid*)offsetof(Vertex_PCUTB, texCoords));
	glVertexPointer(3, GL_FLOAT, sizeof(Vertex_PCUTB), (const GLvoid*)offsetof(Vertex_PCUTB, tangent));
	glVertexPointer(3, GL_FLOAT, sizeof(Vertex_PCUTB), (const GLvoid*)offsetof(Vertex_PCUTB, bitangent));

	glDrawArrays(GetDrawMode(drawMode), 0, numVerts);

	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_COLOR_ARRAY);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);

	glBindBuffer(GL_ARRAY_BUFFER, 0);
	UnbindTexture();
}
Beispiel #3
0
VOID CDUIFramePanel::SetControlRect(const RECT& rt)
{
	m_rtControl = rt;

	if(GetDrawMode() != FRAME_PANEL_SINGLE_COLOR)
	{
		CalculateImageFrame();
	}

	RECT rtAvailable = GetContentRect();
	rtAvailable.left += m_rtFrame.left;
	rtAvailable.right -= m_rtFrame.right;
	rtAvailable.top += m_rtFrame.top;
	rtAvailable.bottom -= m_rtFrame.bottom;

	if(IsRectEmpty(&rtAvailable))
	{
		rtAvailable.right = rtAvailable.left;
		rtAvailable.bottom = rtAvailable.top;
	}

	//DUI_ASSERT(GetControlCount() == 1);
	if(GetControlCount() >= 1)
	{
		GetControlByIndex(0)->SetControlRect(rtAvailable);
	}
}
Beispiel #4
0
VOID CDUIFramePanel::PaintBkgnd(HDC dc)
{
	if(GetDrawMode() & FRAME_PANEL_SINGLE_COLOR)
	{	
		DrawFrameWithColor(dc);
	}
	else 
	{
		DrawFrameWithImage(dc);
	}
}
Beispiel #5
0
void XSurfaceOpenGL::Draw( float x, float y )
{
    if( GetDrawMode() != xDM_NONE )
    {
        glPushMatrix();

        if( GetDrawMode() == xDM_NORMAL )
            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        else if( GetDrawMode() == xDM_SCREEN )
            glBlendFunc(GL_SRC_ALPHA, GL_ONE );
//		x += m_fAdjustAxisX;
//		y += m_fAdjustAxisY;
        glTranslatef( x, y, 0);	// 어느쪽을하든 차이가 없더라. 아이폰/아이패드 둘다 3g는 테스트 안해봄
        glTranslatef( m_fAdjustAxisX, m_fAdjustAxisY, 0 );
        if( m_fRotX )
            glRotatef( m_fRotX, 1.0f, 0, 0 );
        if( m_fRotY )
            glRotatef( m_fRotY, 0, 1.0f, 0 );
        if( m_fRotZ )
            glRotatef( m_fRotZ, 0, 0, 1.0f );
        if( m_fScaleX != 1.0f || m_fScaleY != 1.0f || m_fScaleZ != 1.0f )
            glScalef( m_fScaleX, m_fScaleY, m_fScaleZ );
        glTranslatef( -m_fAdjustAxisX, -m_fAdjustAxisY, 0 );		// 좌표축을 돌린 후 움직인다
        if( m_fAlpha < 1.0f )
        {
            DrawCoreAlpha();
        } else
        {
            DrawCore();
        }

        glPopMatrix();
    }
    m_fRotX = m_fRotY = m_fRotZ = 0;
    m_fScaleX = m_fScaleY = 1.0f;
    m_fAdjustAxisX = m_fAdjustAxisY = 0;
}
Beispiel #6
0
	void PrelightPipeline::Execute(const std::shared_ptr<SceneManager> &sceneManager)
	{
		// pre
		m_DrawCall = 0;
		m_CurrentCamera = nullptr;
		m_CurrentShader = nullptr;
		SortPassByIndex();

		// find visible nodes, 1 cam 1 query
		std::unordered_map<std::string, RenderQuery::Ptr> queries;

		for (auto pair : m_PassMap)
		{
			auto pass = pair.second;
			auto camNode = pass->GetCameraNode();

			if (camNode == nullptr)
			{
				LOGW << "Camera for pass " + pass->GetName() + " not found!";
				continue;
			}

			auto it = queries.find(camNode->GetName());
			if (it != queries.end())
				continue;

			RenderQuery::Ptr query = RenderQuery::Create();

			sceneManager->GetRenderQuery(camNode->GetComponent<Camera>()->GetFrustum(), query);
			query->Sort(camNode->GetWorldPosition(), false);

			queries.emplace(camNode->GetName(), query);
		}

		// draw passes

		for (unsigned int i = 0; i < m_SortedPasses.size(); i++)
		{
			auto passName = m_SortedPasses[i];
			auto pass = m_PassMap[passName];

			auto drawMode = pass->GetDrawMode();

			m_CurrentCamera = pass->GetCameraNode();
			m_CurrentShader = pass->GetFirstShader();

			if (m_CurrentCamera == nullptr)
				continue;

			auto query = queries[m_CurrentCamera->GetName()];

			pass->Bind();

			if (drawMode == DrawMode::RENDERABLE)
			{
				for (const auto &node : query->OpaqueNodes)
					DrawRenderable(pass, node);
			}
			else if (drawMode == DrawMode::LIGHT)
			{
				glDepthMask(GL_FALSE);

				for (const auto &node : query->LightNodes)
					DrawLight(pass, node);

				glDepthMask(GL_TRUE);
				glEnable(GL_DEPTH_TEST);
				glCullFace(GL_BACK);
			}
			else 
			{
				DrawQuad(pass);
			}

			pass->UnBind();
		}

		// post
		m_CurrentCamera = nullptr;
		m_CurrentShader = nullptr;
	}
void
My_TestGLDrawing::DrawTest(bool offscreen)
{
    std::cout << "My_TestGLDrawing::DrawTest()\n";

    HdPerfLog& perfLog = HdPerfLog::GetInstance();
    perfLog.Enable();
    
    // Reset all counters we care about.
    perfLog.ResetCache(HdTokens->extent);
    perfLog.ResetCache(HdTokens->points);
    perfLog.ResetCache(HdTokens->topology);
    perfLog.ResetCache(HdTokens->transform);
    perfLog.SetCounter(UsdImagingTokens->usdVaryingExtent, 0);
    perfLog.SetCounter(UsdImagingTokens->usdVaryingPrimvar, 0);
    perfLog.SetCounter(UsdImagingTokens->usdVaryingTopology, 0);
    perfLog.SetCounter(UsdImagingTokens->usdVaryingVisibility, 0);
    perfLog.SetCounter(UsdImagingTokens->usdVaryingXform, 0);

    int width = GetWidth(), height = GetHeight();

    double aspectRatio = double(width)/height;
    GfFrustum frustum;
    frustum.SetPerspective(60.0, aspectRatio, 1, 100000.0);

    GfMatrix4d viewMatrix;
    viewMatrix.SetIdentity();
    viewMatrix *= GfMatrix4d().SetRotate(GfRotation(GfVec3d(0, 1, 0), _rotate[0]));
    viewMatrix *= GfMatrix4d().SetRotate(GfRotation(GfVec3d(1, 0, 0), _rotate[1]));
    viewMatrix *= GfMatrix4d().SetTranslate(GfVec3d(_translate[0], _translate[1], _translate[2]));

    GfMatrix4d projMatrix = frustum.ComputeProjectionMatrix();

    GfMatrix4d modelViewMatrix = viewMatrix; 
    if (UsdGeomGetStageUpAxis(_stage) == UsdGeomTokens->z) {
        // rotate from z-up to y-up
        modelViewMatrix = 
            GfMatrix4d().SetRotate(GfRotation(GfVec3d(1.0,0.0,0.0), -90.0)) *
            modelViewMatrix;
    }

    GfVec4d viewport(0, 0, width, height);
    _engine->SetCameraState(modelViewMatrix, projMatrix, viewport);

    size_t i = 0;
    TF_FOR_ALL(timeIt, GetTimes()) {
        UsdTimeCode time = *timeIt;
        if (*timeIt == -999) {
            time = UsdTimeCode::Default();
        }
        UsdImagingGLRenderParams params;
        params.drawMode = GetDrawMode();
        params.enableLighting = IsEnabledTestLighting();
        params.enableIdRender = IsEnabledIdRender();
        params.frame = time;
        params.complexity = _GetComplexity();
        params.cullStyle = IsEnabledCullBackfaces() ?
                            UsdImagingGLCullStyle::CULL_STYLE_BACK :
                            UsdImagingGLCullStyle::CULL_STYLE_NOTHING;

        glViewport(0, 0, width, height);

        glEnable(GL_DEPTH_TEST);

        if(IsEnabledTestLighting()) {
            if(UsdImagingGLEngine::IsHydraEnabled()) {
                _engine->SetLightingState(_lightingContext);
            } else {
                _engine->SetLightingStateFromOpenGL();
            }
        }

        if (!GetClipPlanes().empty()) {
            params.clipPlanes = GetClipPlanes();
            for (size_t i=0; i<GetClipPlanes().size(); ++i) {
                glEnable(GL_CLIP_PLANE0 + i);
            }
        }

        GfVec4f const &clearColor = GetClearColor();
        GLfloat clearDepth[1] = { 1.0f };

        // Make sure we render to convergence.
        TfErrorMark mark;
        do {
            glClearBufferfv(GL_COLOR, 0, clearColor.data());
            glClearBufferfv(GL_DEPTH, 0, clearDepth);
            _engine->Render(_stage->GetPseudoRoot(), params);
        } while (!_engine->IsConverged());
        TF_VERIFY(mark.IsClean(), "Errors occurred while rendering!");

        std::cout << "itemsDrawn " << perfLog.GetCounter(HdTokens->itemsDrawn) << std::endl;
        std::cout << "totalItemCount " << perfLog.GetCounter(HdTokens->totalItemCount) << std::endl;

        std::string imageFilePath = GetOutputFilePath();
        if (!imageFilePath.empty()) {
            if (time != UsdTimeCode::Default()) {
                std::stringstream suffix;
                suffix << "_" << std::setw(3) << std::setfill('0') << params.frame << ".png";
                imageFilePath = TfStringReplace(imageFilePath, ".png", suffix.str());
            }
            std::cout << imageFilePath << "\n";
            WriteToFile("color", imageFilePath);
        }
        i++;
    }