- surface rendering is a step closer to using VBO's (code now works using Vertex Arrays, next stop Vertex Buffer Objects)
This commit is contained in:
parent
6ec92f2127
commit
1574e05fcd
|
@ -1857,6 +1857,8 @@ void Renderer::renderSurface(const int renderFps) {
|
|||
|
||||
int lastSurfaceDataIndex = -1;
|
||||
if(mapSurfaceData.find(visibleQuad) == mapSurfaceData.end()) {
|
||||
printf("Calculating surface for Rendering VBO style [%s]\n",visibleQuad.getString().c_str());
|
||||
|
||||
//std::vector<SurfaceData> surface;
|
||||
std::vector<SurfaceData> &surface = mapSurfaceData[visibleQuad];
|
||||
|
||||
|
@ -1982,8 +1984,8 @@ void Renderer::renderSurface(const int renderFps) {
|
|||
}
|
||||
|
||||
#else
|
||||
bool legacyRendering = true;
|
||||
if(legacyRendering) {
|
||||
bool useVertexArrayRendering = true;
|
||||
if(useVertexArrayRendering == false) {
|
||||
//printf("\LEGACY qCache.visibleScaledCellList.size() = %d \n",qCache.visibleScaledCellList.size());
|
||||
|
||||
for(int visibleIndex = 0;
|
||||
|
@ -2052,7 +2054,13 @@ void Renderer::renderSurface(const int renderFps) {
|
|||
else {
|
||||
int lastSurfaceDataIndex = -1;
|
||||
std::vector<SurfaceData> surface;
|
||||
//surface.reserve(qCache.visibleScaledCellList.size());
|
||||
//if(mapSurfaceData.find(visibleQuad) == mapSurfaceData.end())
|
||||
{
|
||||
//printf("Calculating surface for Rendering using VA's [%s]\n",visibleQuad.getString().c_str());
|
||||
|
||||
//std::vector<SurfaceData> surface;
|
||||
//std::vector<SurfaceData> &surface = mapSurfaceData[visibleQuad];
|
||||
surface.reserve(qCache.visibleScaledCellList.size());
|
||||
|
||||
for(int visibleIndex = 0;
|
||||
visibleIndex < qCache.visibleScaledCellList.size(); ++visibleIndex) {
|
||||
|
@ -2100,10 +2108,10 @@ void Renderer::renderSurface(const int renderFps) {
|
|||
|
||||
surfaceDataIndex = surface.size()-1;
|
||||
|
||||
//surface[surfaceDataIndex].texCoords.reserve(100);
|
||||
//surface[surfaceDataIndex].texCoordsSurface.reserve(100);
|
||||
//surface[surfaceDataIndex].vertices.reserve(100);
|
||||
//surface[surfaceDataIndex].normals.reserve(100);
|
||||
surface[surfaceDataIndex].texCoords.reserve(100);
|
||||
surface[surfaceDataIndex].texCoordsSurface.reserve(100);
|
||||
surface[surfaceDataIndex].vertices.reserve(100);
|
||||
surface[surfaceDataIndex].normals.reserve(100);
|
||||
}
|
||||
|
||||
lastSurfaceDataIndex = surfaceDataIndex;
|
||||
|
@ -2131,9 +2139,14 @@ void Renderer::renderSurface(const int renderFps) {
|
|||
surface[surfaceDataIndex].vertices.push_back(tc10->getVertex());
|
||||
surface[surfaceDataIndex].normals.push_back(tc10->getNormal());
|
||||
}
|
||||
|
||||
}
|
||||
//printf("\nsurface.size() = %d vs qCache.visibleScaledCellList.size() = %d \n",surface.size(),qCache.visibleScaledCellList.size());
|
||||
|
||||
//std::vector<SurfaceData> &surface = mapSurfaceData[visibleQuad];
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
|
||||
for(int i = 0; i < surface.size(); ++i) {
|
||||
SurfaceData &data = surface[i];
|
||||
|
||||
|
@ -2151,24 +2164,20 @@ void Renderer::renderSurface(const int renderFps) {
|
|||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, texCoordsSurface);
|
||||
|
||||
assertGl();
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
assertGl();
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, 0, vertices);
|
||||
glNormalPointer(GL_FLOAT, 0, normals);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, data.vertices.size());
|
||||
|
||||
glClientActiveTexture(fowTexUnit);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glClientActiveTexture(baseTexUnit);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
|
||||
//assertGl();
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
//assertGl();
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -227,6 +227,18 @@ public:
|
|||
|
||||
return 0.5f * ((v0.x * v1.y) - (v0.y * v1.x));
|
||||
}
|
||||
|
||||
std::string getString() const {
|
||||
std::ostringstream streamOut;
|
||||
streamOut << "#1: " << this->p[0].getString();
|
||||
streamOut << "#2: " << this->p[1].getString();
|
||||
streamOut << "#3: " << this->p[2].getString();
|
||||
streamOut << "#4: " << this->p[3].getString();
|
||||
std::string result = streamOut.str();
|
||||
streamOut.str(std::string());
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
typedef Quad2<int> Quad2i;
|
||||
|
|
|
@ -157,7 +157,7 @@ void ModelRendererGl::renderMesh(Mesh *mesh) {
|
|||
if(lastTexture != texture->getHandle()){
|
||||
//assert(glIsTexture(texture->getHandle()));
|
||||
//throw runtime_error("glIsTexture(texture->getHandle()) == false for texture: " + texture->getPath());
|
||||
if(glIsTexture(texture->getHandle()) == true) {
|
||||
if(glIsTexture(texture->getHandle()) == GL_TRUE) {
|
||||
glBindTexture(GL_TEXTURE_2D, texture->getHandle());
|
||||
lastTexture= texture->getHandle();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user