Example #1
0
/**
 * Serializes a LWGEOM to a char*.  This is a helper function that partially
 * writes the appropriate draw, stroke, and fill commands used to generate an
 * SVG image using ImageMagick's "convert" command.

 * @param output a char reference to write the LWGEOM to
 * @param lwgeom a reference to a LWGEOM
 * @return the numbers of character written to *output
 */
static size_t
drawGeometry(char *output, LWGEOM *lwgeom, LAYERSTYLE *styles )
{
	char *ptr = output;
	int i;
	int type = lwgeom_getType(lwgeom->type);

	switch (type)
	{
	case POINTTYPE:
		ptr += drawPoint(ptr, (LWPOINT*)lwgeom, styles );
		break;
	case LINETYPE:
		ptr += drawLineString(ptr, (LWLINE*)lwgeom, styles );
		break;
	case POLYGONTYPE:
		ptr += drawPolygon(ptr, (LWPOLY*)lwgeom, styles );
		break;
	case MULTIPOINTTYPE:
	case MULTILINETYPE:
	case MULTIPOLYGONTYPE:
	case COLLECTIONTYPE:
		for (i=0; i<((LWCOLLECTION*)lwgeom)->ngeoms; i++)
		{
			ptr += drawGeometry( ptr, lwcollection_getsubgeom ((LWCOLLECTION*)lwgeom, i), styles );
		}
		break;
	}

	return (ptr - output);
}
void GraphicsObject::render(const GraphicsContext &context)
{

    glPushMatrix();

    transform();

    prepareMaterial();

/*    if (_shader)
        bindShader(*_shader, context);*/

    drawGeometry();

   /* if (_shader)
        releaseShader();*/

    releaseMaterial();

    for (object_vector_t::iterator i = _childs.begin();
        i != _childs.end(); 
        i++)
        (*i)->render(context);

    glPopMatrix();
}
Example #3
0
void GeometryModel::display(const Matrix4<float> &viewMatrix) const
{
    unsigned int shaderSaved = ShaderManager::instance()->getCurrentProgram();
    ShaderManager::instance()->bind(shader);

    glUniformMatrix4fv(mProjectionLoc, 1, false, (const float*)projectionMatrix);
    glUniformMatrix4fv(mViewLoc, 1, false, (const float*)(viewMatrix * modelMatrix));
    glUniform3fv(colorLoc, 1, (const float*)Vector3<float>(red, green, blue));

    glBindVertexArray(vertexArrayObject);

    GLboolean cullFaceActive;
    glGetBooleanv(GL_CULL_FACE, &cullFaceActive);
    if(cullFaceActive)
    {
        glDisable(GL_CULL_FACE);
    }
    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    glLineWidth(1.3);

    glBindBuffer(GL_ARRAY_BUFFER, bufferIDs[VAO_VERTEX_POSITION]);
    glBufferData(GL_ARRAY_BUFFER, vertexArray.size()*sizeof(Point3<float>), &vertexArray[0], GL_DYNAMIC_DRAW);
    glEnableVertexAttribArray(SHADER_VERTEX_POSITION);
    glVertexAttribPointer(SHADER_VERTEX_POSITION, 3, GL_FLOAT, false, 0, 0);
    drawGeometry();

    if(cullFaceActive)
    {
        glEnable(GL_CULL_FACE);
    }
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

    ShaderManager::instance()->bind(shaderSaved);
}
Example #4
0
File: Node.cpp Project: crvv/simple
void Node::draw(Renderer *renderer) {
    if (drawable) {
        beforeDraw(renderer);
        drawGeometry();
        afterDraw(renderer);
    }
    for (auto &node : children) {
        node->draw(renderer);
    }
}
void GLES2Lesson::render() {

    clearBuffers();
    prepareShaderProgram();
    setPerspective();

    drawGeometry( triangleVertices,
                  triangleColours,
                  triangleIndices,
                  3,
                  triangleTransformMatrix
                );

    drawGeometry( squareVertices,
                  squareColours,
                  squareIndices,
                  4,
                  squareTransformMatrix
                );
}
Example #6
0
void display(void)
{
   GLfloat feedBuffer[1024];
   GLint size;

   glMatrixMode (GL_PROJECTION);
   glLoadIdentity ();
   glOrtho (0.0, 100.0, 0.0, 100.0, 0.0, 1.0);

   glClearColor (0.0, 0.0, 0.0, 0.0);
   glClear(GL_COLOR_BUFFER_BIT);
   drawGeometry (GL_RENDER);

   glFeedbackBuffer (1024, GL_3D_COLOR, feedBuffer);
   (void) glRenderMode (GL_FEEDBACK);
   drawGeometry (GL_FEEDBACK);

   size = glRenderMode (GL_RENDER);
   printBuffer (size, feedBuffer);
}
void GLES2Lesson::render() {
    clearBuffers();
    prepareShaderProgram();
    setPerspective();
    resetTransformMatrices();

    drawGeometry(vboCubeVertexDataIndex,
                 vboCubeVertexIndicesIndex,
                 36,
                 cubeTransformMatrix
    );
}
Example #8
0
void GeometryPainter::drawGeometryCollection(QPainter& pt, const OGRGeometryCollection* collection,
                                             const QMatrix& m)
{
  if (collection == NULL)
  {
    throw Exception("Internal Error: GeometryPainter::drawGeometryCollection - Null geometry");
  }
  for (int i = 0; i < collection->getNumGeometries(); i++)
  {
    drawGeometry(pt, collection->getGeometryRef(i), m);
  }
}
    void GLES2Lesson::render() {
        clearBuffers();
        prepareShaderProgram();
        setPerspective();
        resetTransformMatrices();

        for (auto &star : mStars) {

            glUniform4fv(fragmentTintPosition, 1, &star->mColor[0]);

            drawGeometry(vboCubeVertexDataIndex,
                         vboCubeVertexIndicesIndex,
                         4,
                         star->mTransform
            );
        }
    }
Example #10
0
void UIManipulator::draw(ShaderStack *stack)
{
    if ( isEmpty() )
        return;

    QVector4D testVec = stack->cameraProjectionTop() * stack->coordinateTransformTop() * stack->worldToCameraTop()
            * stack->modelToWorldTop() * QVector4D(0,0,0,1);

    stack->counterScalePush();
    stack->counterScaleSetTop(testVec.z());

    for ( int i = 0; i < geometryCount(); i++ )
    {
        drawGeometry(geometryAt(i).data(), stack);
    }

    stack->counterScalePop();
}
Example #11
0
void display(void)
{
    // update view
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(60.0, (float)width / (float)height, 0.1, 500.0);

    glRotatef(xRotation, 1.0f, 0.0f, 0.0f);
    glRotatef(yRotation, 0.0f, 1.0f, 0.0f);
    glTranslatef(-xListenerPos, -yListenerPos, -zListenerPos);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    // clear
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glClearColor(0.4f, 0.6f, 1.0f, 0.0f);

    // draw geometry
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texture);
        drawGeometry(walls);
        drawGeometry(rotatingMesh);
        drawGeometry(doorList[0]);
        drawGeometry(doorList[1]);
        drawGeometry(doorList[2]);
        drawGeometry(doorList[3]);
    glDisable(GL_TEXTURE_2D);

    // draw sound objects
    for (int object = 0; object < NUM_OBJECTS; object++) {
        float audibility = 1.0f;
        objects[object].channel->getAudibility(&audibility);

        glPrintF(8 + object, 1, "sound[%i] VOL: %f", object, audibility);

        glPolygonMode(GL_FRONT, GL_FILL);
        glPushMatrix();
        glTranslatef(objects[object].xPos, objects[object].yPos, objects[object].zPos);

        glDisable(GL_LIGHTING);
        glColor3f(1.0f - audibility, audibility, 0.0f);
        glRotatef(accumulatedTime * 200.0f, 1.0f, 1.0f, 0.0f);
        glutSolidTetrahedron();

        //glPopAttrib();
        glPopMatrix();
    }

    // finish in idle()
    //glutSwapBuffers();
    //glutPostWindowRedisplay(0);
}
Example #12
0
void BccInterface::drawWorld(BccWorld * world, KdTreeDrawer * drawer)
{
	const float das = world->drawAnchorSize();
	const unsigned n = world->numTetrahedronMeshes();
	unsigned i;
	for(i=0;i<n;i++) {
		drawTetrahedronMesh(world->tetrahedronMesh(i), drawer);
		drawAnchors(world->tetrahedronMesh(i), drawer, das);
	}
	
	if(world->triangleGeometries()) drawGeometry(world->triangleGeometries(), drawer);
	
	unsigned igroup;
	GeometryArray * selected = world->selectedGroup(igroup);
	if(selected) {
		drawer->setGroupColorLight(igroup);
		glDisable(GL_DEPTH_TEST);
		drawer->geometry(selected);
	}
	
	if(m_patchMesh) {
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		glColor3f(.03f, .14f, .44f);
		drawer->geometry(m_patchMesh);
	}
    
    if(m_tetMesh) {
#if 0
		drawTetrahedronMesh(m_tetMesh, drawer);
#else
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		glColor3f(.03f, .14f, .44f);
		drawer->tetrahedronMesh(m_tetMesh);
#endif
	}
	
    const std::vector<AOrientedBox> * boxes = world->patchBoxes();
	glColor3f(0.f, 0.99f, 0.f);
	glBegin(GL_LINES);
	std::vector<AOrientedBox>::const_iterator it = boxes->begin();
	for(;it!=boxes->end();++it)
		drawer->orientedBox(&(*it));
	glEnd();
}
    void GLES2Lesson::render() {
        clearBuffers();
        prepareShaderProgram();
        setPerspective();
        resetTransformMatrices();

        if (enableBlending) {
            enableAlphaBlending();
        } else {
            disableAlfaBlending();
        }


        drawGeometry(vboCubeVertexDataIndex,
                     vboCubeVertexIndicesIndex,
                     36,
                     cubeTransformMatrix
        );
    }
Example #14
0
void Skinning::draw()
{
	gl::clear( Color( 1.0f, 1.0f, 1.0f ) );	
	
	mCam.lookAt( gConfigScene.eye, Vec3f::zero() );
	mCam.setPerspective( 60, getWindowAspectRatio(), 0.01, 500 );
	gl::setMatrices( mCam );
	
	
	glEnable(GL_LIGHT0);
	
	GLfloat pos[] = {0.0, 2.0, 15.0, 1.0};
	GLfloat diff[] = {1.0, 1.0, 1.0, 1.0};
	
	glLightfv(GL_LIGHT0, GL_POSITION, pos);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, diff);
	
	mShaderPhong.bind();
	mShaderPhong.uniform("shininess",128.0f);
	mShaderPhong.uniform("tex",0);
	
	
	drawGeometry();
	
	mShaderPhong.unbind();
	glDisable(GL_LIGHT0);
	
	if (mDrawNormals)
		drawNormals();
	
	// Params
	if (mShowParams){
		params::InterfaceGl::draw();
	}
	
}
Example #15
0
void Object3D::draw(void)
{
    beforeTransformations();
    glMatrixMode(GL_MODELVIEW_MATRIX);
    glPushMatrix();

    glTranslatef(translation().x(), translation().y(), translation().z());
    glTranslatef(center().x(), center().y(), center().z());

    QQuaternion t = interactiveQuartenion();
    glRotatef(degreeFromCos(t.scalar()),
              0, 0, t.z());

    //glMultMatrixf(rotations().constData());
    glMultMatrixd(rotations().constData());

    m_modelView = glGetMatrix(GL_MODELVIEW_MATRIX);
    m_projection = glGetMatrix(GL_PROJECTION_MATRIX);

    afterTransformations();
    drawGeometry();

    glPopMatrix();
}
//--------------------------------------------------------------
void testApp::draw(){
	
	ofBackground(255*.2);
	
	
	if(allLoaded){
		
		if(!viewComps){
			fbo.begin();
			ofClear(0, 0, 0);
			
			cam.begin(ofRectangle(0, 0, fbo.getWidth(), fbo.getHeight()));
			
			drawGeometry();
			
			cam.end();
			
			fbo.end();	
			
			//cout << timeline.getDrawRect().height << " tl height " << endl;
			
			if(!ofGetMousePressed(0)){
				timeline.setOffset(ofVec2f(0, ofGetHeight() - timeline.getDrawRect().height));
			}
			fboRectangle.height = (timeline.getDrawRect().y - fboRectangle.y - 20);
			fboRectangle.width = 16.0/9.0*fboRectangle.height;
			ofDrawBitmapString(currentCompositionDirectory, ofPoint(fboRectangle.x, fboRectangle.y-15));

			if(presentMode){
				fboRectangle.x = 0;
				fboRectangle.y = 0;
				fboRectangle.height = ofGetHeight();
				fboRectangle.width = 16.0/9.0*fboRectangle.height;
			}
			else {
				fboRectangle.x = 250;
				fboRectangle.y = 100;
				fboRectangle.height = (timeline.getDrawRect().y - fboRectangle.y - 20);
				fboRectangle.width = 16.0/9.0*fboRectangle.height;
				ofDrawBitmapString(currentCompositionDirectory, ofPoint(fboRectangle.x, fboRectangle.y-15));
			}

			fbo.getTextureReference().draw(fboRectangle);
			
			if(currentlyRendering){
				fbo.getTextureReference().readToPixels(savingImage.getPixelsRef());
				char filename[512];
				sprintf(filename, "%s/save_%05d.png", saveFolder.c_str(), currentRenderFrame);
				savingImage.saveImage(filename);
				
				//cout << "at save time its set to " << hiResPlayer->getCurrentFrame() << endl;

				///////frame debugging
				//		numFramesRendered++;
				//		cout << "	Rendered (" << numFramesRendered << "/" << numFramesToRender << ") +++ current render frame is " << currentRenderFrame << " quick time reports frame " << hiResPlayer->getCurrentFrame() << endl;
				//		sprintf(filename, "%s/TEST_FRAME_%05d_%05d_B.png", saveFolder.c_str(), currentRenderFrame, hiResPlayer->getCurrentFrame());
				//		savingImage.saveImage(filename);
				//		savingImage.setFromPixels(hiResPlayer->getPixelsRef());
				//		savingImage.saveImage(filename);
				//////
				
				//stop when finished
				currentRenderFrame++;
				if(currentRenderFrame > timeline.getOutFrame()){
					finishRender();
				}
			}
			
			if(sampleCamera){
				ofDrawBitmapString("RECORDING CAMERA", ofPoint(600, 10));
			}
		}
		
		gui.setDraw(!currentlyRendering && !presentMode);
		if(!presentMode && !viewComps){
			timeline.draw();
		}
		
		if(!presentMode){
			gui.draw();
		}
		
		ofSetColor(255);
	}
	
	if(viewComps){
		ofPushStyle();
		for(int i = 0; i < comps.size(); i++){
			if(comps[i]->wasRenderedInBatch){
				ofSetColor(50,200,100, 200);
				ofRect(*comps[i]->toggle);
			}
			else if(comps[i]->batchExport){
				ofSetColor(255,255,100, 200);
				ofRect(*comps[i]->toggle);
			}
		}
		ofPopStyle();
	}
	
}
Example #17
0
void display(void)
{	
	// update view	
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(
		60.0,								// fov
		(float)width / (float)height,		// aspect
		0.1,								// near
		500.0								// far
		);


	glRotatef(xRotation, 1.0f, 0.0f, 0.0f);
	glRotatef(yRotation, 0.0f, 1.0f, 0.0f);
	glTranslatef(-xListenerPos, -yListenerPos, -zListenerPos);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	// clear
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glClearColor(0.4, 0.6f, 1.0f, 0.0f);

	glEnable(GL_TEXTURE_2D);
	glBindTexture( GL_TEXTURE_2D, texture );

	// draw geometry
	drawGeometry(walls);
	drawGeometry(rotatingMesh);
	drawGeometry(doorList[0]);
	drawGeometry(doorList[1]);
	drawGeometry(doorList[2]);
	drawGeometry(doorList[3]);


	
	glDisable(GL_TEXTURE_2D);


	// draw sound objects
	int object;
	for (object = 0; object < NUM_OBJECTS; object++)
	{
		float directOcclusion = 1.0f;
		float reverbOcclusion = 1.0f;

		// set colour baced on direct occlusion
		objects[object].channel->get3DOcclusion(&directOcclusion, &reverbOcclusion);
		float intensity = 1.0f - directOcclusion;
				
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
		glPushMatrix();
		glTranslatef(objects[object].xPos, objects[object].yPos, objects[object].zPos);

		glPushAttrib(GL_LIGHTING_BIT);
			
		intensity *= 0.75f;
		float color[4] = { intensity, intensity, 0.0f, 0.0f };
		glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color);
		intensity *= 0.5f;
		float ambient[4] = { intensity, intensity, 0.0f, 0.0f };
		glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient);
		
		glRotatef(accumulatedTime * 200.0f, 0.0f, 1.0f, 0.0f);
		glutSolidTorus(0.15f, 0.6f, 8, 16);
		glPopAttrib();
		glPopMatrix();
	}

	// finish
	glutSwapBuffers();
}
Example #18
0
int main(int argc, char* argv[])
{
    SetupCallbacks();

    // generate geometry

    genGrid( GRID_ROWS, GRID_COLUMNS, GRID_SIZE, grid_vertices, grid_indices );
    genTorus( TORUS_ROWS, TORUS_SLICES, TORUS_RADIUS, TORUS_THICKNESS, torus_vertices, torus_indices );

    // flush cache so that no stray data remains

    sceKernelDcacheWritebackAll();

    // setup VRAM buffers

    void* frameBuffer = (void*)0;
    const void* doubleBuffer = (void*)0x44000;
    const void* renderTarget = (void*)0x88000;
    const void* depthBuffer = (void*)0x110000;

    // setup GU

    sceGuInit();

    sceGuStart(GU_DIRECT,list);
    sceGuDrawBuffer(GU_PSM_4444,frameBuffer,BUF_WIDTH);
    sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,(void*)doubleBuffer,BUF_WIDTH);
    sceGuDepthBuffer((void*)depthBuffer,BUF_WIDTH);
    sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
    sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);
    sceGuDepthRange(0xc350,0x2710);
    sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
    sceGuEnable(GU_SCISSOR_TEST);
    sceGuDepthFunc(GU_GEQUAL);
    sceGuEnable(GU_DEPTH_TEST);
    sceGuFrontFace(GU_CW);
    sceGuShadeModel(GU_SMOOTH);
    sceGuEnable(GU_CULL_FACE);
    sceGuEnable(GU_TEXTURE_2D);
    sceGuEnable(GU_DITHER);
    sceGuFinish();
    sceGuSync(0,0);

    sceDisplayWaitVblankStart();
    sceGuDisplay(GU_TRUE);


    // setup matrices

    ScePspFMatrix4 identity;
    ScePspFMatrix4 projection;
    ScePspFMatrix4 view;

    gumLoadIdentity(&identity);

    gumLoadIdentity(&projection);
    gumPerspective(&projection,75.0f,16.0f/9.0f,0.5f,1000.0f);

    {
        ScePspFVector3 pos = {0,0,-5.0f};

        gumLoadIdentity(&view);
        gumTranslate(&view,&pos);
    }

    ScePspFMatrix4 textureProjScaleTrans;
    gumLoadIdentity(&textureProjScaleTrans);
    textureProjScaleTrans.x.x = 0.5;
    textureProjScaleTrans.y.y = -0.5;
    textureProjScaleTrans.w.x = 0.5;
    textureProjScaleTrans.w.y = 0.5;

    ScePspFMatrix4 lightProjection;
    ScePspFMatrix4 lightProjectionInf;
    ScePspFMatrix4 lightView;
    ScePspFMatrix4 lightMatrix;

    gumLoadIdentity(&lightProjection);
    gumPerspective(&lightProjection,75.0f,1.0f,0.1f,1000.0f);
    gumLoadIdentity(&lightProjectionInf);
    gumPerspective(&lightProjectionInf,75.0f,1.0f,0.0f,1000.0f);

    gumLoadIdentity(&lightView);
    gumLoadIdentity(&lightMatrix);

    // define shadowmap

    Texture shadowmap = {
        GU_PSM_4444,
        0, 128, 128, 128,
        sceGeEdramGetAddr() + (int)renderTarget
    };

    // define geometry

    Geometry torus = {
        identity,
        sizeof(torus_indices)/sizeof(unsigned short),
        torus_indices,
        torus_vertices,
        0xffffff
    };
    Geometry grid = {
        identity,
        sizeof(grid_indices)/sizeof(unsigned short),
        grid_indices,
        grid_vertices,
        0xff7777
    };

    // run sample

    int val = 0;

    for(;;)
    {
        // update matrices

        // grid
        {
            ScePspFVector3 pos = {0,-1.5f,0};

            gumLoadIdentity(&grid.world);
            gumTranslate(&grid.world,&pos);
        }

        // torus
        {
            ScePspFVector3 pos = {0,0.5f,0.0f};
            ScePspFVector3 rot = {val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f)};

            gumLoadIdentity(&torus.world);
            gumTranslate(&torus.world,&pos);
            gumRotateXYZ(&torus.world,&rot);
        }

        // orbiting light
        {
            ScePspFVector3 lightLookAt = { torus.world.w.x, torus.world.w.y, torus.world.w.z };
            ScePspFVector3 rot1 = {0,val * 0.79f * (GU_PI/180.0f),0};
            ScePspFVector3 rot2 = {-(GU_PI/180.0f)*60.0f,0,0};
            ScePspFVector3 pos = {0,0,LIGHT_DISTANCE};

            gumLoadIdentity(&lightMatrix);
            gumTranslate(&lightMatrix,&lightLookAt);
            gumRotateXYZ(&lightMatrix,&rot1);
            gumRotateXYZ(&lightMatrix,&rot2);
            gumTranslate(&lightMatrix,&pos);
        }

        gumFastInverse(&lightView,&lightMatrix);

        // render to shadow map

        {
            sceGuStart(GU_DIRECT,list);

            // set offscreen texture as a render target

            sceGuDrawBufferList(GU_PSM_4444,(void*)renderTarget,shadowmap.stride);

            // setup viewport

            sceGuOffset(2048 - (shadowmap.width/2),2048 - (shadowmap.height/2));
            sceGuViewport(2048,2048,shadowmap.width,shadowmap.height);

            // clear screen

            sceGuClearColor(0xffffffff);
            sceGuClearDepth(0);
            sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);

            // setup view/projection from light

            sceGuSetMatrix(GU_PROJECTION,&lightProjection);
            sceGuSetMatrix(GU_VIEW,&lightView);

            // shadow casters are drawn in black
            // disable lighting and texturing

            sceGuDisable(GU_LIGHTING);
            sceGuDisable(GU_TEXTURE_2D);

            // draw torus to shadow map

            drawShadowCaster( &torus );

            sceGuFinish();
            sceGuSync(0,0);
        }

        // render to frame buffer

        {
            sceGuStart(GU_DIRECT,list);

            // set frame buffer

            sceGuDrawBufferList(GU_PSM_4444,(void*)frameBuffer,BUF_WIDTH);

            // setup viewport

            sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
            sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);

            // clear screen

            sceGuClearColor(0xff554433);
            sceGuClearDepth(0);
            sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);

            // setup view/projection from camera

            sceGuSetMatrix(GU_PROJECTION,&projection);
            sceGuSetMatrix(GU_VIEW,&view);
            sceGuSetMatrix(GU_MODEL,&identity);

            // setup a light
            ScePspFVector3 lightPos = { lightMatrix.w.x, lightMatrix.w.y, lightMatrix.w.z };
            ScePspFVector3 lightDir = { lightMatrix.z.x, lightMatrix.z.y, lightMatrix.z.z };

            sceGuLight(0,GU_SPOTLIGHT,GU_DIFFUSE,&lightPos);
            sceGuLightSpot(0,&lightDir, 5.0, 0.6);
            sceGuLightColor(0,GU_DIFFUSE,0x00ff4040);
            sceGuLightAtt(0,1.0f,0.0f,0.0f);
            sceGuAmbient(0x00202020);
            sceGuEnable(GU_LIGHTING);
            sceGuEnable(GU_LIGHT0);

            // draw torus

            drawGeometry( &torus );

            // setup texture projection

            sceGuTexMapMode( GU_TEXTURE_MATRIX, 0, 0 );
            sceGuTexProjMapMode( GU_POSITION );

            // set shadowmap as a texture

            sceGuTexMode(shadowmap.format,0,0,0);
            sceGuTexImage(shadowmap.mipmap,shadowmap.width,shadowmap.height,shadowmap.stride,shadowmap.data);
            sceGuTexFunc(GU_TFX_MODULATE,GU_TCC_RGB);
            sceGuTexFilter(GU_LINEAR,GU_LINEAR);
            sceGuTexWrap(GU_CLAMP,GU_CLAMP);
            sceGuEnable(GU_TEXTURE_2D);

            // calculate texture projection matrix for shadowmap

            ScePspFMatrix4 shadowProj;
            gumMultMatrix(&shadowProj, &lightProjectionInf, &lightView);
            gumMultMatrix(&shadowProj, &textureProjScaleTrans, &shadowProj);

            // draw grid receiving shadow

            drawShadowReceiver( &grid, shadowProj );

            sceGuFinish();
            sceGuSync(0,0);
        }

        sceDisplayWaitVblankStart();
        frameBuffer = sceGuSwapBuffers();

        val++;
    }

    sceGuTerm();

    sceKernelExitGame();
    return 0;
}
Example #19
0
void nRenderer::drawLitOpaqueGeometry() {
	drawGeometry(nRenderable::Opaque, true);
}
Example #20
0
void nRenderer::drawNonLitTransluentGeometry() {
	drawGeometry(nRenderable::Transluent, false);
}
Example #21
0
//--------------------------------------------------------------
void testApp::draw(){
	
	updateParticleSystem();
	updatePerlinLuminosity();

	renderTarget.begin();
	ofClear(0,0,0,255);
	cam.begin(ofRectangle(0,0,renderTarget.getWidth(), renderTarget.getHeight()));
			
    if(player.isLoaded()){
		drawGeometry();
	}

	ofPushMatrix();
//	ofScale(1,-1,1);
	ofTranslate(timeline.getValue("x offset"), 0, timeline.getValue("z offset"));
	glEnable(GL_DEPTH_TEST);
	ofEnableBlendMode(OF_BLENDMODE_SCREEN);
	
	ofSetColor(0);
	ofPushMatrix();
	ofScale(1, -1, 1);
	meshBuilder.getMesh().disableColors();
	meshBuilder.getMesh().draw();
	meshBuilder.getMesh().enableColors();
	ofPopMatrix();
	ofSetColor(255);
	
	ambientShader.begin();
	ofEnablePointSprites();
	ofDisableArbTex();
	crossSprite.getTextureReference().bind();
	
	ambientShader.setUniform1f("maxDisance", particleMaxDistance) ;
	ambientShader.setUniform1f("maxSize", particeMaxSize) ;

	ofEnableBlendMode(OF_BLENDMODE_SCREEN);
	ofPushStyle();
	glPointSize(3.0);
	ofSetColor(particleFade*255);
	ambientParticles.drawVertices();
	ofPopStyle();
	ambientShader.end();

	crossSprite.getTextureReference().unbind();
	
	glDisable(GL_DEPTH_TEST);
	ofDisablePointSprites();
	ofEnableArbTex();

	ofPopMatrix();
	
//	randomUnits.drawVertices();
//	clusters.drawVertices();

	cam.end();
	
	renderTarget.end();
	
	ofEnableAlphaBlending();
	ofPushStyle();
	ofSetColor(0);
	ofRect(fboRect);
	ofPopStyle();

	
	renderTarget.getTextureReference().draw(fboRect.x,fboRect.getBottom(),fboRect.width,-fboRect.height);
	
	if(rendering){

		saveImage.setUseTexture(false);
		renderTarget.readToPixels(saveImage.getPixelsRef());
		saveImage.mirror(true, false);
		char filename[1024];
		sprintf(filename, "%sframe_%05d.png",renderFolder.c_str(), currentFrameNumber);
		saveImage.saveImage(filename);
		currentFrameNumber++;
		
	}
	timeline.draw();
    gui.draw();
}
Example #22
0
/**
 * Main Application.  Currently, drawing styles are hardcoded in this method.
 * Future work may entail reading the styles from a .properties file.
 */
int main( int argc, const char* argv[] )
{
	FILE *pfile;
	LWGEOM *lwgeom;
	char line [2048];
	char *filename;
	int layerCount;
	int styleNumber;
	LAYERSTYLE *styles;

	getStyles(&styles);

	if ( argc != 2 )
	{
		lwerror("You must specifiy a wkt filename to convert.\n");
		return -1;
	}

	if ( (pfile = fopen(argv[1], "r")) == NULL)
	{
		perror ( argv[1] );
		return -1;
	}

	filename = malloc( strlen(argv[1])+11 );
	strncpy( filename, "../images/", 10 );
	strncat( filename, argv[1], strlen(argv[1])-3 );
	strncat( filename, "png", 3 );

	printf( "generating %s\n", filename );

	layerCount = 0;
	while ( fgets ( line, sizeof line, pfile ) != NULL && !isspace(*line) )
	{

		char output[2048];
		char *ptr = output;
		char *styleName;
		int useDefaultStyle;

		ptr += sprintf( ptr, "convert -size %s xc:none ", imageSize );

		useDefaultStyle = getStyleName(&styleName, line);
		LWDEBUGF( 4, "%s", styleName );

		if (useDefaultStyle)
		{
			printf("   Warning: using Default style for layer %d\n", layerCount);
			lwgeom = lwgeom_from_ewkt( line, PARSER_CHECK_NONE );
		}
		else
			lwgeom = lwgeom_from_ewkt( line+strlen(styleName)+1, PARSER_CHECK_NONE );
		LWDEBUGF( 4, "geom = %s", lwgeom_to_ewkt((LWGEOM*)lwgeom,0) );

		styleNumber = layerCount % length(styles);
		ptr += drawGeometry( ptr, lwgeom, getStyle(styles, styleName) );

		ptr += sprintf( ptr, "-flip tmp%d.png", layerCount );

		lwfree( lwgeom );

		LWDEBUGF( 4, "%s", output );
		system(output);

		addHighlight( layerCount );
		addDropShadow( layerCount );
		layerCount++;
		free(styleName);
	}

	flattenLayers(filename);
	optimizeImage(filename);

	fclose(pfile);
	free(filename);
	freeStyles(&styles);
	return 0;
}
Example #23
0
void nRenderer::drawNonLitOpaqueGeometry() {
	drawGeometry(nRenderable::Opaque, false);
}
Example #24
0
void nRenderer::drawLitTransluentGeometry() {
	drawGeometry(nRenderable::Transluent, true);
}