// Back-end render function
void RenderablePicoSurface::render(const RenderInfo& info) const
{
	// Invoke appropriate display list
	if (info.checkFlag(RENDER_PROGRAM))
    {
        if (info.checkFlag(RENDER_VERTEX_COLOUR))
        {
            glCallList(_dlProgramVcol);
        }
        else
        {
            glCallList(_dlProgramNoVCol);
        }
	}
	else
    {
		glCallList(_dlRegular);
	}
}
Пример #2
0
// Back-end render
void MD5Surface::render(const RenderInfo& info) const
{
	if (info.checkFlag(RENDER_BUMP))
    {
		glCallList(_lightingList);
	}
	else
    {
		glCallList(_normalList);
	}
}
Пример #3
0
void RenderablePatchSolid::render(const RenderInfo& info) const
{
#ifdef PATCHES_USE_VBO
	glBindBuffer(GL_ARRAY_BUFFER, _vboData);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIdx);
	
	glNormalPointer(GL_DOUBLE, sizeof(ArbitraryMeshVertex), BUFFER_OFFSET(16));
	glClientActiveTexture(GL_TEXTURE0);
	glTexCoordPointer(2, GL_DOUBLE, sizeof(ArbitraryMeshVertex), BUFFER_OFFSET(0));
	glVertexPointer(3, GL_DOUBLE, sizeof(ArbitraryMeshVertex), BUFFER_OFFSET(40));

	const RenderIndex* strip_indices = 0;

	for (std::size_t i = 0; i < m_tess.m_numStrips; i++, strip_indices += m_tess.m_lenStrips)
	{
		glDrawElements(GL_QUAD_STRIP, GLsizei(m_tess.m_lenStrips), RenderIndexTypeID, strip_indices);
	}

	GlobalOpenGL().assertNoErrors();

	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
	glBindBuffer(GL_ARRAY_BUFFER, 0);
#else
	if (m_tess.vertices.empty() || m_tess.indices.empty()) return;

	if (info.checkFlag(RENDER_BUMP))
	{
		glVertexAttribPointerARB(11, 3, GL_DOUBLE, 0, sizeof(ArbitraryMeshVertex), &m_tess.vertices.front().normal);
		glVertexAttribPointerARB(8, 2, GL_DOUBLE, 0, sizeof(ArbitraryMeshVertex), &m_tess.vertices.front().texcoord);
		glVertexAttribPointerARB(9, 3, GL_DOUBLE, 0, sizeof(ArbitraryMeshVertex), &m_tess.vertices.front().tangent);
		glVertexAttribPointerARB(10, 3, GL_DOUBLE, 0, sizeof(ArbitraryMeshVertex), &m_tess.vertices.front().bitangent);
	}
	else
	{
		glNormalPointer(GL_DOUBLE, sizeof(ArbitraryMeshVertex), &m_tess.vertices.front().normal);
		glTexCoordPointer(2, GL_DOUBLE, sizeof(ArbitraryMeshVertex), &m_tess.vertices.front().texcoord);
	}

	glVertexPointer(3, GL_DOUBLE, sizeof(ArbitraryMeshVertex), &m_tess.vertices.front().vertex);

	const RenderIndex* strip_indices = &m_tess.indices.front();

	for(std::size_t i = 0; i<m_tess.m_numStrips; i++, strip_indices += m_tess.m_lenStrips)
	{
		glDrawElements(GL_QUAD_STRIP, GLsizei(m_tess.m_lenStrips), RenderIndexTypeID, strip_indices);
	}

#if defined(_DEBUG)
	//RenderNormals();
#endif

#endif
}
Пример #4
0
void RenderablePatchSolid::render(const RenderInfo& info) const
{
    if (_tess.vertices.empty() || _tess.indices.empty()) return;

    if (!info.checkFlag(RENDER_BUMP))
    {
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    }

    // No colour changing
    glDisableClientState(GL_COLOR_ARRAY);
    if (info.checkFlag(RENDER_VERTEX_COLOUR))
    {
        glColor3f(1, 1, 1);
    }

    if (_needsUpdate)
    {
        _needsUpdate = false;

        // Add vertex geometry to vertex buffer
        VertexBuffer_T currentVBuf;
        currentVBuf.addVertices(_tess.vertices.begin(), _tess.vertices.end());

        // Submit indices
        const RenderIndex* strip_indices = &_tess.indices.front();
        for (std::size_t i = 0;
            i < _tess.m_numStrips;
            i++, strip_indices += _tess.m_lenStrips)
        {
            currentVBuf.addIndexBatch(strip_indices, _tess.m_lenStrips);
        }

        // Render all batches
        _vertexBuf.replaceData(currentVBuf);
    }

    _vertexBuf.renderAllBatches(GL_QUAD_STRIP, info.checkFlag(RENDER_BUMP));
}
Пример #5
0
void Winding::render(const RenderInfo& info) const
{
    // Do not render if there are no points
	if (empty())
    {
		return;
	}

    // Our vertex colours are always white, if requested
    glDisableClientState(GL_COLOR_ARRAY);
    if (info.checkFlag(RENDER_VERTEX_COLOUR))
    {
        glColor3f(1, 1, 1);
    }

	// A shortcut pointer to the first array element to avoid
	// massive calls to std::vector<>::begin()
	const WindingVertex& firstElement = front();

	// Set the vertex pointer first
	glVertexPointer(3, GL_DOUBLE, sizeof(WindingVertex), &firstElement.vertex);

    // Check render flags. Multiple flags may be set, so the order matters.
    if (info.checkFlag(RENDER_TEXTURE_CUBEMAP))
    {
        // In cube-map mode, we submit the vertex coordinate as the texture
        // coordinate. The RenderSystem will set the appropriate texture matrix
        // etc.
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
        glTexCoordPointer(
            3, GL_DOUBLE, sizeof(WindingVertex), &firstElement.vertex
        );
    }
	else if (info.checkFlag(RENDER_BUMP))
    {
        // Lighting mode, submit normals, tangents and texcoords to the shader
        // program.
		glVertexAttribPointer(
            ATTR_NORMAL, 3, GL_DOUBLE, 0, sizeof(WindingVertex), &firstElement.normal
        );
		glVertexAttribPointer(
            ATTR_TEXCOORD, 2, GL_DOUBLE, 0, sizeof(WindingVertex), &firstElement.texcoord
        );
		glVertexAttribPointer(
            ATTR_TANGENT, 3, GL_DOUBLE, 0, sizeof(WindingVertex), &firstElement.tangent
        );
		glVertexAttribPointer(
            ATTR_BITANGENT, 3, GL_DOUBLE, 0, sizeof(WindingVertex), &firstElement.bitangent
        );
	}
	else
    {
        // Submit normals in lighting mode
		if (info.checkFlag(RENDER_LIGHTING))
        {
			glNormalPointer(GL_DOUBLE, sizeof(WindingVertex), &firstElement.normal);
		}

        // Set texture coordinates in 2D texture mode
		if (info.checkFlag(RENDER_TEXTURE_2D))
        {
            glEnableClientState(GL_TEXTURE_COORD_ARRAY);
            glTexCoordPointer(
                2, GL_DOUBLE, sizeof(WindingVertex), &firstElement.texcoord
            );
		}
	}

    // Submit all data to OpenGL
	glDrawArrays(GL_POLYGON, 0, GLsizei(size()));
}
Пример #6
0
void RenderablePatchWireframe::render(const RenderInfo& info) const
{
    // No colour changing
    glDisableClientState(GL_COLOR_ARRAY);
    if (info.checkFlag(RENDER_VERTEX_COLOUR))
    {
        glColor3f(1, 1, 1);
    }

    if (_tess.vertices.empty()) return;

    if (_needsUpdate)
    {
        _needsUpdate = false;

        const std::vector<ArbitraryMeshVertex>& patchVerts = _tess.vertices;

        // Vertex buffer to receive and render vertices
        VertexBuffer_T currentVBuf;

        std::size_t firstIndex = 0;
        for (std::size_t i = 0; i <= _tess.curveTreeV.size(); ++i)
        {
            currentVBuf.addBatch(patchVerts.begin() + firstIndex,
                _tess.m_nArrayWidth);

            if (i == _tess.curveTreeV.size()) break;

            if (!_tess.curveTreeV[i]->isLeaf())
            {
                currentVBuf.addBatch(
                    patchVerts.begin() + GLint(_tess.curveTreeV[i]->index),
                    _tess.m_nArrayWidth
                    );
            }

            firstIndex += (_tess.arrayHeight[i] * _tess.m_nArrayWidth);
        }

        const ArbitraryMeshVertex* p = &patchVerts.front();
        std::size_t uStride = _tess.m_nArrayWidth;
        for (std::size_t i = 0; i <= _tess.curveTreeU.size(); ++i)
        {
            currentVBuf.addBatch(p, _tess.m_nArrayHeight, uStride);

            if (i == _tess.curveTreeU.size()) break;

            if (!_tess.curveTreeU[i]->isLeaf())
            {
                currentVBuf.addBatch(
                    patchVerts.begin() + _tess.curveTreeU[i]->index,
                    _tess.m_nArrayHeight, uStride
                    );
            }

            p += _tess.arrayWidth[i];
        }

        // Render all vertex batches
        _vertexBuf.replaceData(currentVBuf);
    }

    _vertexBuf.renderAllBatches(GL_LINE_STRIP);
}