예제 #1
0
파일: Mesh.cpp 프로젝트: jkhoogland/magnum
void Mesh::draw(AbstractShaderProgram& shader) {
    shader.use();

    #ifndef MAGNUM_TARGET_GLES
    drawInternal(_count, _baseVertex, _instanceCount, _baseInstance, _indexOffset, _indexStart, _indexEnd);
    #elif !defined(MAGNUM_TARGET_GLES2)
    drawInternal(_count, _baseVertex, _instanceCount, _indexOffset, _indexStart, _indexEnd);
    #else
    drawInternal(_count, _baseVertex, _instanceCount, _indexOffset);
    #endif
}
예제 #2
0
//--------------------------------------------------------------
void testApp::draw(){
    if (ofGetElapsedTimef() < 2.0f) { return; }
    
#ifndef DISABLE_STREAMING
    if(streamer.wantsNewFrame()) {
        streamer.beginGrab();
            drawInternal();
        streamer.endGrab();
    }
#endif

    drawInternal();
}
예제 #3
0
void
drawLimit(int *Kid, int *Curx, int *Cury, char ***screen,
	  struct Tgraph *graph)
/*
The drawXxx routines all have the forllowing arguments:
Kid		--	Ineger index of the current child
Curx		--	Current x position in the 2D character field
Cury		--	Current y position in the 2D character field
screen		--	pointer to the 2D character field
graph		--	The parent
*/
{
#define kid (*Kid)
#define curx (*Curx)
#define cury (*Cury)
	int             width = graph->down[kid]->dim.x;
	if (width < 3)
		width = 3;
	drawInternal(screen, graph->down[kid], curx, cury + 1);
	(*screen)[cury][curx + (width - 1) / 2 - 1] = 'l';
	(*screen)[cury][curx + (width - 1) / 2] = 'i';
	(*screen)[cury][curx + (width - 1) / 2 + 1] = 'm';
	curx += width + 1;

	kid++;
}
예제 #4
0
void SVGImage::draw(SkCanvas* canvas, const SkPaint& paint, const FloatRect& dstRect, const FloatRect& srcRect,
    RespectImageOrientationEnum shouldRespectImageOrientation, ImageClampingMode clampMode)
{
    if (!m_page)
        return;

    drawInternal(canvas, paint, dstRect, srcRect, shouldRespectImageOrientation, clampMode, KURL());
}
예제 #5
0
void BaseInstance::draw()
{
    pthread_mutex_lock(&m_canDrawMutex);
    pthread_mutex_lock(&m_canSyncMutex);

    core::getAssetManager()->processTasksGPU();

    if(platform::get_cpu_time() - m_gcLastTime > GC_TIME)
    {
        m_xi_objectManager->runGarbageCollection();
        m_gcLastTime = platform::get_cpu_time();
    }

    m_activeScene->sync();
    m_xi_renderer->sync();
    m_renderQueue.sync();

    m_uiManager->sync();

    if(m_debugUI)
    {
        m_debugUI->sync();
    }

    pthread_mutex_unlock(&m_canDrawMutex);
    pthread_mutex_unlock(&m_canTickMutex);

    if(m_mainFrameBufferProxy)
    {
        m_mainFrameBufferProxy->bind();

        drawInternal();

        m_xi_renderer->render(m_renderQueue, m_mainFrameBufferProxy);

        m_debugDrawer->draw();

        if(!isEditor() && m_debugPhysics)
        {
            // Draw physx debug information with tick locked as it must not overlap with physics update.
            pthread_mutex_lock(&m_canTickMutex);
            m_debugDrawer->drawPhysX(m_activeScene->m_pxScene->getRenderBuffer());
            pthread_mutex_unlock(&m_canTickMutex);
        }

        m_uiManager->draw();

        if(m_debugUI)
        {
            m_debugUI->draw();
        }

        m_mainFrameBufferProxy->unbind();
    }
}
예제 #6
0
void AssimpModel::drawInternal(const aiNode* nd)
{
    aiMatrix4x4 matrix = nd->mTransformation;

    // update transform
    aiTransposeMatrix4(&matrix);
    glPushMatrix();
    glMultMatrixf((float*)&matrix);

    // draw all meshes assigned to this node
    for (unsigned int n = 0; n < nd->mNumMeshes; ++n) {
        const aiMesh* mesh = m_scene->mMeshes[nd->mMeshes[n]];
        applyMaterial(m_scene->mMaterials[mesh->mMaterialIndex]);

	glEnable(GL_TEXTURE_2D);
        mesh->mNormals == NULL ? glDisable(GL_LIGHTING) :  glEnable(GL_LIGHTING);
        mesh->mColors[0] != NULL?  glEnable(GL_COLOR_MATERIAL) : glDisable(GL_COLOR_MATERIAL);
        for (unsigned int t = 0; t < mesh->mNumFaces; ++t) {
            const struct aiFace* face = &mesh->mFaces[t];
            unsigned int modes[4] = {GL_POLYGON, GL_POINTS, GL_LINES, GL_TRIANGLES};
            unsigned int mode = face->mNumIndices > 3? 0: face->mNumIndices;
            glBegin(modes[mode]);
            for(unsigned int i = 0; i < face->mNumIndices; i++) {
                int index = face->mIndices[i];
                if(mesh->mColors[0] != NULL) {
                    glColor4fv((GLfloat*)&mesh->mColors[0][index]);
                }

                if(mesh->HasTextureCoords(0)) {
                    glTexCoord2f(mesh->mTextureCoords[0][index].x,  mesh->mTextureCoords[0][index].y);
                }

                if(mesh->mNormals != NULL) {
                    glNormal3fv(&mesh->mNormals[index].x);
                }

                glVertex3fv(&mesh->mVertices[index].x);
            }

            glEnd();
        }

        glDisable(GL_TEXTURE_2D);
    }

    // draw all children
    for (unsigned int child = 0; child < nd->mNumChildren; ++child) {
        drawInternal(nd->mChildren[child]);
    }

    glPopMatrix();
}
void MultilevelLayouter::drawInternal(Graph& G, count level) {
	count n = G.numberOfNodes();

	if (n <= N_THRSH) {
		// unrecursive part: call drawing routine
		METISGraphWriter gWriter;
		gWriter.write(G, true, "output/test-multi-coarsest.graph");
		DEBUG("initial layout by FR, G's size: ", G.numberOfNodes());
		FruchtermanReingold initLayouter(bottomLeft, topRight, false);
		initLayouter.draw(G);
		PostscriptWriter writer;
		writer.write(G, "output/test-multi-coarsest-FR.eps");
		MaxentStress layouter(bottomLeft, topRight, true);
		layouter.draw(G);
		writer.write(G, "output/test-multi-coarsest-ME.eps");
	}
	else {
		// compute clustering
		PLP clusterer(G);
		clusterer.run();
		Partition clustering = clusterer.getPartition();
		EdgeCut ec;
		INFO("Clustering: #clusters: ", clustering.numberOfSubsets(), "; cut: ", ec.getQuality(clustering, G));

		// coarsen by clustering
		ParallelPartitionCoarsening contracter(G, clustering);
		contracter.run();
		Graph Gcon = contracter.getCoarseGraph();
		std::vector<node> mapping = contracter.getFineToCoarseNodeMapping();

		// make recursive call
		drawInternal(Gcon, level + 1);

		// apply recursive solution to current graph
		G.initCoordinates();
		G.forNodes([&](node v) {
			G.setCoordinate(v, Gcon.getCoordinate(mapping[v]));
//			TRACE("coordinate of ", v, ": ", G.getCoordinate(v, 0), " / ", G.getCoordinate(v, 1));
		});
		DEBUG("local refinement of graph of size ", n);

		// run drawing code on current graph
		FruchtermanReingold layouter(bottomLeft, topRight, true); //, 50 * (level + 1), 0.1); // TODO: externalize
		layouter.draw(G);
	}
}
예제 #8
0
void Component::draw(Graphics* const TheGraphics, Real32 Opacity) const
{
    //If not visible then don't draw
    if (!getVisible())
        return;

    //Grab the initial transformation
    GLdouble InitMat[16];
    glGetDoublev(GL_MODELVIEW_MATRIX, InitMat);

    //Translate to my position
    glTranslatef(getPosition().x(), getPosition().y(), 0);

    if(setupClipping(TheGraphics))
    {

        //Activate My Border Drawing constraints
        Border* DrawnBorder = getDrawnBorder();
        if(DrawnBorder != NULL)
        {
            DrawnBorder->activateInternalDrawConstraints(TheGraphics,0,0,getSize().x(),getSize().y());
        }


        //Draw My Background
        drawBackground(TheGraphics, getDrawnBackground(), Opacity);

        //Draw Internal
        drawInternal(TheGraphics, Opacity);

        //Make sure the clipping is reset
        setupClipping(TheGraphics);

        //Draw My Foreground
        drawForeground(TheGraphics, getDrawnForeground(), Opacity);

        //Draw all parts that should not be clipped against
        drawUnclipped(TheGraphics, Opacity);
    }

    //Reset the transformation
    glLoadMatrixd(InitMat);
}
예제 #9
0
void SVGImage::drawForContainer(SkCanvas* canvas, const SkPaint& paint, const FloatSize containerSize, float zoom, const FloatRect& dstRect,
    const FloatRect& srcRect, const KURL& url)
{
    if (!m_page)
        return;

    // Temporarily disable the image observer to prevent changeInRect() calls due re-laying out the image.
    ImageObserverDisabler imageObserverDisabler(this);

    IntSize roundedContainerSize = roundedIntSize(containerSize);
    setContainerSize(roundedContainerSize);

    FloatRect scaledSrc = srcRect;
    scaledSrc.scale(1 / zoom);

    // Compensate for the container size rounding by adjusting the source rect.
    FloatSize adjustedSrcSize = scaledSrc.size();
    adjustedSrcSize.scale(roundedContainerSize.width() / containerSize.width(), roundedContainerSize.height() / containerSize.height());
    scaledSrc.setSize(adjustedSrcSize);

    drawInternal(canvas, paint, dstRect, scaledSrc, DoNotRespectImageOrientation, ClampImageToSourceRect, url);
}
예제 #10
0
void StateMachineApp:: draw() {
    drawInternal();

    if(currentState)
        currentState->draw();
}
예제 #11
0
void WorldObjectEffect::draw(DrawInfo &di) {
	if (singleCbvBufferMode) assert(di.objectNum < maxObjects);
	int frameIndex = xapp().getCurrentBackBufferIndex();
	Camera *cam = nullptr;
	CBV *cbv = nullptr;
	if (inThreadOperation) {
		// copy global camera to thread camera: TODO: should only be needed once
		threadLocal.camera = xapp().camera;
		cam = &threadLocal.camera;
		threadLocal.cbv = this->cbv;
		cbv = &threadLocal.cbv;
	} else {
		cam = &xapp().camera;
		cbv = &this->cbv;
		// update lights, for thread operations: must have been done earlier in divideBulk (same material for all objects)
		xapp().lights.lights.material = *di.material;
		xapp().lights.update();
	}
	prepareDraw(&xapp().vr);
	if (!xapp().ovrRendering) {
		threadLocal.vr_eyesm[0] = vr_eyes;
		XMMATRIX vp = cam->worldViewProjection();
		XMMATRIX toWorld = XMLoadFloat4x4(&di.world);
		XMMATRIX wvp = calcWVP(toWorld, vp);
		XMStoreFloat4x4(&cbv->wvp, wvp);
		cbv->world = di.world;
		cbv->cameraPos.x = cam->pos.x;
		cbv->cameraPos.y = cam->pos.y;
		cbv->cameraPos.z = cam->pos.z;
		cbv->alpha = di.alpha;
		if (inBulkOperation) {
			memcpy(getCBVUploadAddress(frameIndex, di.threadNum, di.objectNum, 0), cbv, sizeof(*cbv));
		} else {
			memcpy(cbvGPUDest, cbv, sizeof(*cbv));
		}
		//memcpy(getCBVUploadAddress(frameIndex, di.threadNum, di.objectNum), &cbv, sizeof(cbv));
		//memcpy(cbvGPUDest + cbvAlignedSize, &cbv, sizeof(cbv));
		//memcpy(getCBVUploadAddress(frameIndex, 0), &cbv, sizeof(cbv));
		drawInternal(di);
		return;
	}
	// draw VR, iterate over both eyes
	//xapp().vr.prepareDraw();
	for (int eyeNum = 0; eyeNum < 2; eyeNum++) {
		// adjust PVW matrix
		threadLocal.cameram[eyeNum] = xapp().camera;
		threadLocal.vr_eyesm[eyeNum] = vr_eyes;
		cam = &threadLocal.cameram[eyeNum];
		cbv = &threadLocal.cbvm[eyeNum];
		*cbv = this->cbv;
		di.eyeNum = eyeNum;
		XMMATRIX adjustedEyeMatrix;
		cam->eyeNumUse = true;
		cam->eyeNum = eyeNum;
		threadLocal.vr_eyesm[eyeNum].adjustEyeMatrix(adjustedEyeMatrix, cam, eyeNum, &xapp().vr);
		//xapp().vr.adjustEyeMatrix(adjustedEyeMatrix, cam);
		XMMATRIX toWorld = XMLoadFloat4x4(&di.world);
		XMMATRIX wvp = calcWVP(toWorld, adjustedEyeMatrix);
		XMStoreFloat4x4(&cbv->wvp, wvp);
		cbv->world = di.world;
		cbv->cameraPos.x = cam->pos.x;
		cbv->cameraPos.y = cam->pos.y;
		cbv->cameraPos.z = cam->pos.z;
		cbv->alpha = di.alpha;
		//if (eyeNum == 1) di.objectNum += 12;//10010;
		if (inBulkOperation) {
			UINT8 *mem = getCBVUploadAddress(frameIndex, di.threadNum, di.objectNum, eyeNum);
			//if (di.objectNum == 100) {
			//	Log(" di100 " << mem << " " << frameIndex << " " << di.threadNum << endl);
			//}
			memcpy(mem, cbv, sizeof(*cbv));
		} else {
			memcpy(cbvGPUDest, cbv, sizeof(*cbv));
		}
		drawInternal(di);
		//if (di.objectNum == 100 /*&& eyeNum == 1 && frameIndex < 3*/) drawInternal(di);
		//if (eyeNum == 1) drawInternal(di);
		//if (eyeNum == 1) di.objectNum -= 12;//10010;
		if (!inThreadOperation) {
			//xapp().vr.nextEye();
		}
	}
	di.eyeNum = 0;
	//xapp().vr.endDraw();
}
예제 #12
0
void AssimpModel::drawImpl()
{
    drawInternal(m_scene->mRootNode);
}
void MultilevelLayouter::draw(Graph& G) {
	drawInternal(G, 0);
}