Esempio n. 1
0
Flake::Flake( Storm* storm ) {
	_storm = storm;

    _trail = new va::VertexShape();
    _trail->setMode(GL_TRIANGLE_STRIP);
    addChild(_trail);
    
    setPosition(va::random(600,700), va::random(600,700),0);    
    _loc = getPosition();
    _vel.set(va::random(0.001,0.01), va::random(0.001,0.01),0);    
	
    // adding 40 vertices
	for (unsigned int i=0; i<20; ++i) {
        _trail->addVertex(i, 0, 0);
        _trail->addVertex(i, 10, 0);
    }

    // adding 40 vertex colors
	for (unsigned int i=0; i<20; ++i) {
        _trail->addVertexColor(0, 0, 0, 1-(i/20.0f));
        _trail->addVertexColor(0, 0, 0, 1-(i/20.0f));
    }
        
    disableDepthTest();
    disableLighting();
    enableBlending();
    
    _maxvelocity = 10.0;
    _maxsteer = 3.0;
    _r = 10;
}
void OpenGLRenderer::drawPolygon(unsigned int aRenderMode, float* aVertices, int aVertexSize, int aVertexCount)
{
	//Setup the colors array based on the foreground color
	int colorSize = 4;
	std::vector<float> colors;
	for (int i = 0; i < aVertexCount; ++i)
	{
		colors.push_back(m_ForegroundColor.red);
		colors.push_back(m_ForegroundColor.green);
		colors.push_back(m_ForegroundColor.blue);
		colors.push_back(m_ForegroundColor.alpha);
	}

	//If the foreground alpha isn't full, enable blending
	if(m_ForegroundColor.alpha != 1.0f)
	{
		enableBlending();
	}

	//Draw the polygon
	drawPolygon(aRenderMode, aVertices, aVertexSize, aVertexCount, &colors[0], colorSize);

	//If the foreground alpha isn't full, blending is enabled, disable it
	if(m_ForegroundColor.alpha != 1.0f)
	{
		disableBlending();
	}
}
Esempio n. 3
0
	GLLineTrailRenderer::GLLineTrailRenderer() :
		GLRenderer(),
		nbSamples(8),
		width(1.0f),
		duration(1.0f),
		degeneratedR(0.0f),
		degeneratedG(0.0f),
		degeneratedB(0.0f),
		degeneratedA(0.0f)
	{
		enableBlending(true);	
	}
void OpenGLRenderer::drawTexture(OpenGLTexture* aTexture, float* aUvCoordinates, float* aVertices)
{
	if(aTexture != NULL)
	{
		int vertexCount = 4;
		int vertexSize = 2;

		//Setup the colors array based on the foreground color
		bool hasTransparency = aTexture->getFormat() == GL_RGBA || aTexture->getAlpha() != 1.0f;
		int colorSize = hasTransparency ? 4 : 3;
		std::vector <float> colors;
		for (int i = 0; i < vertexCount; ++i)
		{
			colors.push_back(aTexture->getColor().red);
			colors.push_back(aTexture->getColor().green);
			colors.push_back(aTexture->getColor().blue);
			if(colorSize == 4)
			{
				colors.push_back(aTexture->getAlpha());
			}
		}

	//If the foreground alpha isn't full, enable blending
	if(hasTransparency == true)
	{
	  enableBlending();
	}

    //Set the uvCoordinates of the texture.
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glTexCoordPointer(2, GL_FLOAT, 0, aUvCoordinates);

	//Enable the texture and bind it
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, aTexture->getId());

	//Draw the texture
	drawPolygon(GL_TRIANGLE_STRIP, aVertices, vertexSize, vertexCount, &colors[0], colorSize);

    //Disable the client states
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisable(GL_TEXTURE_2D);

	//If the foreground alpha isn't full, blending is enabled, disable it
	if(hasTransparency == true)
	{			
		disableBlending();
	}
  }
}
void GraphicsDeviceGL_1_3::drawVirtualScreen()
{
	glViewport( m_virtualViewport[0], m_virtualViewport[1], m_virtualViewport[2], m_virtualViewport[3] );

	//update the video memory framebuffer.
	lockBuffer();
		if (m_writeFrame > m_renderFrame)
		{
			m_videoFrameBuffer->update( m_frameWidth, m_frameHeight, m_frameBuffer_32bpp[m_writeBufferIndex] );
		}
		m_renderFrame = m_writeFrame;
	unlockBuffer();

	enableBlending(false);
	drawFullscreenQuad(m_videoFrameBuffer);

	glViewport( m_fullViewport[0], m_fullViewport[1], m_fullViewport[2], m_fullViewport[3] );
}
Esempio n. 6
0
// ------------------------------------------------------------------
// Name : beginDisplay
// ------------------------------------------------------------------
void DisplayEngine::beginDisplay()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    m_iStencilDepth = 0;
    enableBlending();
}