Ejemplo n.º 1
0
//--------------------------------------------------------------
void SkyBox::render(Uint32 passID)
{
    if(passID != 1)
        return;

    glScalef(m_scale, m_scale, m_scale);

    bindVBO(*this);
    enableTexCoordArray(m_txCoordOffset);

    m_shader.enable();
    m_shader.setProjection(GraphicRenderer::getInstance()->getProjectionMatrix());
    m_shader.setView(Camera::getActiveCamera()->getViewMatrix());
    m_shader.setModel(getModelMatrix());

    /// Left
    m_shader.setTextureParameter("skyTexture", m_left, 0);
    enableVertexArray(m_leftOffset);
    glDrawArrays(GL_QUADS, 0, 4);
    /// Right
    m_shader.setTextureParameter("skyTexture", m_right, 0);
    enableVertexArray(m_rightOffset);
    glDrawArrays(GL_QUADS, 0, 4);
    /// Front
    m_shader.setTextureParameter("skyTexture", m_front, 0);
    enableVertexArray(m_frontOffset);
    glDrawArrays(GL_QUADS, 0, 4);
    /// Back
    m_shader.setTextureParameter("skyTexture", m_back, 0);
    enableVertexArray(m_backOffset);
    glDrawArrays(GL_QUADS, 0, 4);
    /// Top
    m_shader.setTextureParameter("skyTexture", m_top, 0);
    enableVertexArray(m_topOffset);
    glDrawArrays(GL_QUADS, 0, 4);
    /// Bottom
    m_shader.setTextureParameter("skyTexture", m_bottom, 0);
    enableVertexArray(m_bottomOffset);
    glDrawArrays(GL_QUADS, 0, 4);

    m_shader.disable();

    unbindVBO();
}
Ejemplo n.º 2
0
void Canvas::flushGL()
{
	switch( this->glOperation_ ) {
	case None:
		break;
	case Lines: {
		enableVertexArray();
		disableTexture();
		glVertexPointer(3, GL_FLOAT, 0, this->vertexs_.data());
		glDrawArrays(GL_LINES, 0, this->vertexs_.size()/3);
#ifdef DEBUG
		{
			const GLenum err = glGetError();
			if(err != GL_NO_ERROR){
				CINAMO_EXCEPTION(Exception, "[BUG] Failed to draw arrays: 0x%08x", err);
			}
		}
#endif
		break;
	}
	case LineStrip: {
		enableVertexArray();
		disableTexture();
		glVertexPointer(3, GL_FLOAT, 0, this->vertexs_.data());
#ifdef DEBUG
		{
			const GLenum err = glGetError();
			if(err != GL_NO_ERROR){
				CINAMO_EXCEPTION(Exception, "[BUG] Failed to set vertex pointer: 0x%08x", err);
			}
		}
#endif
		glDrawArrays(GL_LINE_STRIP, 0, this->vertexs_.size()/3);
#ifdef DEBUG
		{
			const GLenum err = glGetError();
			if(err != GL_NO_ERROR){
				CINAMO_EXCEPTION(Exception, "[BUG] Failed to draw arrays: 0x%08x", err);
			}
		}
#endif
		break;
	}
	case Texture: {
		enableVertexArray();
		enableTexture();
		glVertexPointer(3, GL_FLOAT, 0, this->vertexs_.data());
#ifdef DEBUG
		{
			const GLenum err = glGetError();
			if(err != GL_NO_ERROR){
				CINAMO_EXCEPTION(Exception, "[BUG] Failed to set vertex pointer: 0x%08x", err);
			}
		}
#endif
		glTexCoordPointer(2, GL_FLOAT, 0, this->texCoords_.data());
#ifdef DEBUG
		{
			const GLenum err = glGetError();
			if(err != GL_NO_ERROR){
				CINAMO_EXCEPTION(Exception, "[BUG] Failed to set vertex pointer: 0x%08x", err);
			}
		}
#endif
		glDrawArrays(GL_TRIANGLES, 0, this->vertexs_.size()/3);
#ifdef DEBUG
		{
			const GLenum err = glGetError();
			if(err != GL_NO_ERROR){
				CINAMO_EXCEPTION(Exception, "[BUG] Failed to draw arrays: 0x%08x", err);
			}
		}
#endif
		break;
	}
	case Rect: {
		enableVertexArray();
		disableTexture();
		glVertexPointer(3, GL_FLOAT, 0, this->vertexs_.data());
#ifdef DEBUG
		{
			const GLenum err = glGetError();
			if(err != GL_NO_ERROR){
				CINAMO_EXCEPTION(Exception, "[BUG] Failed to set vertex pointer: 0x%08x", err);
			}
		}
#endif
		glDrawArrays(GL_TRIANGLES, 0, this->vertexs_.size()/3);
#ifdef DEBUG
		{
			const GLenum err = glGetError();
			if(err != GL_NO_ERROR){
				CINAMO_EXCEPTION(Exception, "[BUG] Failed to draw arrays: 0x%08x", err);
			}
		}
#endif
		break;
	}
	default:
		CINAMO_EXCEPTION(Exception, "Unknown Operation", this->glOperation_);
		break;
	}
	vertexs_.clear();
	texCoords_.clear();
	this->glOperation_ = None;
}