From afb56ea6607574ad3c912d9a855a3801d66c9ba1 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 25 Sep 2013 17:22:48 +0200 Subject: [PATCH] Moved the rendering methods into a new file. --HG-- branch : gsoc2013-dfighter --- .../OpenGL3/driver_opengl_rendering.cpp | 419 ++++++++++++++++++ .../driver/OpenGL3/driver_opengl_vertex.cpp | 385 ---------------- 2 files changed, 419 insertions(+), 385 deletions(-) create mode 100644 code/nel/src/3d/driver/OpenGL3/driver_opengl_rendering.cpp diff --git a/code/nel/src/3d/driver/OpenGL3/driver_opengl_rendering.cpp b/code/nel/src/3d/driver/OpenGL3/driver_opengl_rendering.cpp new file mode 100644 index 000000000..82eb7b7c9 --- /dev/null +++ b/code/nel/src/3d/driver/OpenGL3/driver_opengl_rendering.cpp @@ -0,0 +1,419 @@ +// NeL - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "stdopengl.h" + +#include "driver_opengl.h" +#include "nel/3d/index_buffer.h" +#include "driver_opengl_vertex_buffer_hard.h" + +namespace NL3D { + +#ifdef NL_STATIC +namespace NLDRIVERGL3 { +#endif + +// *************************************************************************** + +bool CDriverGL3::renderLines(CMaterial& mat, uint32 firstIndex, uint32 nlines) +{ + H_AUTO_OGL(CDriverGL3_renderLines) + + // setup material + if ( !setupMaterial(mat) || _LastIB._Values == NULL ) + return false; + + if( !setupProgram( mat ) ) + return false; + + if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true; + // render primitives. + //============================== + // start multipass. + uint nPass; + nPass= beginMultiPass(); + // draw all passes. + for(uint pass=0;passisInvalid()) return true; + + // render primitives. + //============================== + // start multipass. + uint nPass; + + nPass= beginMultiPass(); + + // draw all passes. + for(uint pass=0;pass0); + + if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true; + // Don't setup any material here. + + // render primitives. + //============================== + // NO MULTIPASS HERE!! + // draw the primitives. (nb: ntris>0). + + if (_LastIB._Format == CIndexBuffer::Indices16) + { + glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_SHORT, ((uint16 *) _LastIB._Values)+firstTri); + } + else + { + nlassert(_LastIB._Format == CIndexBuffer::Indices32); + glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, ((uint32 *) _LastIB._Values)+firstTri); + } + + // Profiling. + _PrimitiveProfileIn.NTriangles+= ntris; + _PrimitiveProfileOut.NTriangles+= ntris; + + return true; +} + +// *************************************************************************** + +bool CDriverGL3::renderRawPoints(CMaterial& mat, uint32 startIndex, uint32 numPoints) +{ + H_AUTO_OGL(CDriverGL3_renderRawPoints) + + // setup material + if ( !setupMaterial(mat) ) + return false; + + if( !setupProgram( mat ) ) + return false; + + if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true; + // render primitives. + //============================== + // start multipass. + uint nPass; + nPass= beginMultiPass(); + // draw all passes. + for(uint pass=0;passisInvalid()) return true; + // render primitives. + //============================== + // start multipass. + uint nPass; + nPass= beginMultiPass(); + // draw all passes. + for(uint pass=0;passisInvalid()) return true; + // render primitives. + //============================== + // start multipass. + uint nPass; + nPass= beginMultiPass(); + // draw all passes. + for(uint pass=0;passisInvalid()) return true; + + const uint32 QUAD_BATCH_SIZE = 2048; + static GLshort defaultIndices[QUAD_BATCH_SIZE * 6]; + static bool init = false; + if (!init) + { + // setup the base index buffer + for(uint k = 0; k < QUAD_BATCH_SIZE; ++k) + { + // first tri + defaultIndices[k * 6] = (GLshort) (k * 4); + defaultIndices[k * 6 + 1] = (GLshort) (k * 4 + 1); + defaultIndices[k * 6 + 2] = (GLshort) (k * 4 + 2); + // second tri + defaultIndices[k * 6 + 3] = (GLshort) (k * 4); + defaultIndices[k * 6 + 4] = (GLshort) (k * 4 + 2); + defaultIndices[k * 6 + 5] = (GLshort) (k * 4 + 3); + + } + init = true; + } + + // render primitives. + //============================== + // start multipass. + uint nPass; + nPass= beginMultiPass(); + // draw all passes. + for(uint pass=0;passisInvalid()) return true; - // render primitives. - //============================== - // start multipass. - uint nPass; - nPass= beginMultiPass(); - // draw all passes. - for(uint pass=0;passisInvalid()) return true; - - // render primitives. - //============================== - // start multipass. - uint nPass; - - nPass= beginMultiPass(); - - // draw all passes. - for(uint pass=0;pass0); - - if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true; - // Don't setup any material here. - - // render primitives. - //============================== - // NO MULTIPASS HERE!! - // draw the primitives. (nb: ntris>0). - - if (_LastIB._Format == CIndexBuffer::Indices16) - { - glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_SHORT, ((uint16 *) _LastIB._Values)+firstTri); - } - else - { - nlassert(_LastIB._Format == CIndexBuffer::Indices32); - glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, ((uint32 *) _LastIB._Values)+firstTri); - } - - // Profiling. - _PrimitiveProfileIn.NTriangles+= ntris; - _PrimitiveProfileOut.NTriangles+= ntris; - - return true; -} - -// *************************************************************************** - -bool CDriverGL3::renderRawPoints(CMaterial& mat, uint32 startIndex, uint32 numPoints) -{ - H_AUTO_OGL(CDriverGL3_renderRawPoints) - - // setup material - if ( !setupMaterial(mat) ) - return false; - - if( !setupProgram( mat ) ) - return false; - - if (_CurrentVertexBufferHard && _CurrentVertexBufferHard->isInvalid()) return true; - // render primitives. - //============================== - // start multipass. - uint nPass; - nPass= beginMultiPass(); - // draw all passes. - for(uint pass=0;passisInvalid()) return true; - // render primitives. - //============================== - // start multipass. - uint nPass; - nPass= beginMultiPass(); - // draw all passes. - for(uint pass=0;passisInvalid()) return true; - // render primitives. - //============================== - // start multipass. - uint nPass; - nPass= beginMultiPass(); - // draw all passes. - for(uint pass=0;passisInvalid()) return true; - - const uint32 QUAD_BATCH_SIZE = 2048; - static GLshort defaultIndices[QUAD_BATCH_SIZE * 6]; - static bool init = false; - if (!init) - { - // setup the base index buffer - for(uint k = 0; k < QUAD_BATCH_SIZE; ++k) - { - // first tri - defaultIndices[k * 6] = (GLshort) (k * 4); - defaultIndices[k * 6 + 1] = (GLshort) (k * 4 + 1); - defaultIndices[k * 6 + 2] = (GLshort) (k * 4 + 2); - // second tri - defaultIndices[k * 6 + 3] = (GLshort) (k * 4); - defaultIndices[k * 6 + 4] = (GLshort) (k * 4 + 2); - defaultIndices[k * 6 + 5] = (GLshort) (k * 4 + 3); - - } - init = true; - } - - // render primitives. - //============================== - // start multipass. - uint nPass; - nPass= beginMultiPass(); - // draw all passes. - for(uint pass=0;pass