void Target_Dodecahedron::Sizer(void) { dx = manager->CashedDx(); minJx = minJy = minJz = ihuge_; maxJx = maxJy = maxJz = -ihuge_; GenerateVertices(); GenerateNormals(); int na = (int)vertices[5].data[0]; int nb = (int)vertices[6].data[1]; int nzz = (int)vertices[0].data[2]; for(int ix=-na; ix<=na; ++ix) { real x = (real)ix; for(int iy=-nb; iy<=nb; ++iy) { real y = (real)iy; for(int iz=-nzz; iz<=nzz; ++iz) { real z = (real)iz; bool bOk = Check(x, y, z); if (bOk) { InternalMinMax(ix, iy, iz); } } } } // AllocateArrays(maxJx - minJx + 1, maxJy - minJy + 1, maxJz - minJz + 1); }
void TextureView::PerformSizeUpdate (const AbstractView* source, const AbstractView* target, int width, int height) { if (target == this) { set_size(width, height); std::vector<GLfloat> inner_verts; GenerateVertices(size(), 0.f, RoundNone, 0.f, &inner_verts, 0); vbo_.bind(0); vbo_.set_data(sizeof(GLfloat) * inner_verts.size(), &inner_verts[0]); vbo_.reset(); //AdjustImageArea (*request.size()); RequestRedraw(); } if (source == this) { report_size_update(source, target, width, height); } }
void Target_Octahedron::Sizer(void) { dx = manager->CashedDx(); minJx = minJy = minJz = ihuge_; maxJx = maxJy = maxJz = -ihuge_; GenerateVertices(); GenerateNormals(); int nlong = (int)shpar[0]; real nlongHalf = nlong / (real)2.; // for(int jx=0; jx<=nlong; ++jx) { real x = (real)jx - nlongHalf; for(int jy=0; jy<=nlong; ++jy) { real y = (real)jy - nlongHalf; for(int jz=0; jz<=nlong; ++jz) { real z = (real)jz - nlongHalf; if (Check(x, y, z)) { InternalMinMax(jx, jy, jz); } } } } AllocateArrays(maxJx - minJx + 1, maxJy - minJy + 1, maxJz - minJz + 1); }
void AbstractNode::GenerateRoundedVertices (std::vector<GLfloat>* inner, std::vector<GLfloat>* outer) { GenerateVertices(size(), default_border_width() * AbstractWindow::theme()->pixel(), round_type(), round_radius_, inner, outer); }
Plane::Plane(float quadWidth, float quadHeight, unsigned int width, unsigned int height){ //There's one more row of vertices than quads, same for columns unsigned int quadCount = width*height; unsigned int vertexCount = (width+1)*(height+1); // This is explained further down, but the formula for the amount of indices in the plane is // (quads per row * 2 + 1) * rows + 1 // The last +1 is for the stitch leading into the plane altogether, // while the +1 for each row is for the stitch finalizing each strip (as well as starting the next one.) unsigned int indexCount = (2 * width + 1) * height + 1; Vertex* vertices = new Vertex[vertexCount]; GLuint* indices = new GLuint[indexCount]; GenerateVertices(vertices, quadWidth, quadHeight, width + 1, height + 1); GenerateUvCoordinates(vertices, 1.0f / quadWidth, 1.0f / quadHeight, width + 1, height + 1); GenerateIndices(indices, width, height); GenerateNormals(vertices, width + 1, height + 1); GenerateVao(vertices, indices, vertexCount, indexCount); delete[] vertices; delete[] indices; }
MapChunk::MapChunk( ADT* _adt, Chunk* chunk ) : Adt(_adt), Source(chunk) { FILE* stream = chunk->GetStream(); Header.Read(stream); fseek(stream, chunk->Offset, SEEK_SET); Index = Header.IndexX + Header.IndexY * 16; GenerateVertices(stream); }
void Renderer::GenerateVertices(v_3ct *vertices, uint32_t *index, Drawable *obj) { obj->PrepareVertices(this, vertices, index); if (!obj->is_complex_)return; for (const auto &drawable : obj->complex_list_) { GenerateVertices(vertices, index, drawable.get()); } }
void AbstractNode::GenerateRoundedVertices (Orientation shadedir, short shadetop, short shadedown, std::vector<GLfloat>* inner, std::vector<GLfloat>* outer) { GenerateVertices(0.f, 0.f, size().width(), size().height(), default_border_width() * AbstractWindow::theme()->pixel(), round_type(), round_radius(), shadedir, shadetop, shadedown, inner, outer); }
Sphere::Sphere(glm::vec3 pos, float radius, unsigned int rings, unsigned int sectors) { m_pos = m_centerPos = pos; m_radius = radius; m_rings = rings; m_sectors = sectors; CreateBuffers(); GenerateVertices(); GenerateIndexes(); GenerateNormals(); }
IActor::ActorReturnState Terrain::Load() { LoadHeightMap(); GenerateVertices(); GenerateIndicesWithTextureMapping(); GenerateVerticesNormal(); BuildGeometryBuffer(); UnloadHeightMap(); SetInitialPhysicsProperties(); return IActor::Load(); }
LPDIRECT3DVERTEXBUFFER9 Renderer::GenerateVertexBuffer(Renderer::BufferType type, std::list<std::unique_ptr<Drawable>> *list) { if (list->size() <= 0) { return NULL; } LPDIRECT3DVERTEXBUFFER9 vertex_buffer = nullptr; uint32_t object_count = 0; uint32_t index = 0; for (const auto &obj : *list) { object_count += GetComplexVBObjectCount(obj.get()); } v_3ct vertices[4 * object_count]; for (const auto &obj : *list) { GenerateVertices(vertices, &index, obj.get()); } if (type == DYNAMIC) { if (FAILED(device_->CreateVertexBuffer(4 * index * sizeof(v_3ct), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1, D3DPOOL_DEFAULT, &vertex_buffer, NULL))) { //TODO: Error handling } VOID *temp_vertices; if (FAILED(vertex_buffer->Lock(0, 4 * index * sizeof(v_3ct), &temp_vertices, D3DLOCK_DISCARD))) { //TODO: Error handling } else { memcpy(temp_vertices, vertices, 4 * index * sizeof(v_3ct)); vertex_buffer->Unlock(); } } else { if (FAILED(device_->CreateVertexBuffer(4 * index * sizeof(v_3ct), D3DUSAGE_WRITEONLY, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1, D3DPOOL_DEFAULT, &vertex_buffer, NULL))) { //TODO: Error handling } VOID *temp_vertices; if (FAILED(vertex_buffer->Lock(0, 4 * index * sizeof(v_3ct), &temp_vertices, 0))) { //TODO: Error handling } else { memcpy(temp_vertices, vertices, 4 * index * sizeof(v_3ct)); vertex_buffer->Unlock(); } } return vertex_buffer; }
void TextureView::InitializeImageView () { chessboard_.reset(new ChessBoard(size().width(), size().height())); //chessboard_->Resize(size()); std::vector<GLfloat> inner_verts; GenerateVertices(size(), 0.f, RoundNone, 0.f, &inner_verts, 0); vbo_.generate(); glGenVertexArrays(2, vao_); glBindVertexArray(vao_[0]); vbo_.bind(0); vbo_.set_data(sizeof(GLfloat) * inner_verts.size(), &inner_verts[0]); glEnableVertexAttribArray(AttributeCoord); glVertexAttribPointer(AttributeCoord, 3, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0)); glBindVertexArray(vao_[1]); GLfloat vertices[] = { 0.f, 0.f, 0.f, 1.f, // left-bottom 400.f, 0.f, 1.f, 1.f, // right-bottom 0.f, 300.f, 0.f, 0.f, // left-top 400.f, 300.f, 1.f, 0.f // right-top }; vbo_.bind(1); vbo_.set_data(sizeof(vertices), vertices); glEnableVertexAttribArray(AttributeCoord); glEnableVertexAttribArray(AttributeUV); glVertexAttribPointer(AttributeCoord, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 4, BUFFER_OFFSET(0)); glVertexAttribPointer(AttributeUV, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 4, BUFFER_OFFSET(2 * sizeof(GLfloat))); glBindVertexArray(0); vbo_.reset(); }
DotIcon::DotIcon () : AbstractIcon() { int radius = pixel_size(3); set_size(radius * 2, radius * 2); std::vector<GLfloat> inner_verts; std::vector<GLfloat> outer_verts; GenerateVertices(-radius, -radius, radius, radius, pixel_size(1), RoundAll, radius, &inner_verts, &outer_verts); glGenVertexArrays(2, vao_); glBindVertexArray(vao_[0]); vbo_.generate(); vbo_.bind(0); vbo_.set_data(sizeof(GLfloat) * inner_verts.size(), &inner_verts[0]); glEnableVertexAttribArray( AbstractWindow::shaders()->location( Shaders::WIDGET_SIMPLE_TRIANGLE_COORD)); glVertexAttribPointer( AbstractWindow::shaders()->location( Shaders::WIDGET_SIMPLE_TRIANGLE_COORD), 3, GL_FLOAT, GL_FALSE, 0, 0); glBindVertexArray(vao_[1]); vbo_.bind(1); vbo_.set_data(sizeof(GLfloat) * outer_verts.size(), &outer_verts[0]); glEnableVertexAttribArray(AttributeCoord); glVertexAttribPointer(AttributeCoord, 2, GL_FLOAT, GL_FALSE, 0, 0); glBindVertexArray(0); vbo_.reset(); }
Terrain::Terrain(const char* filename) { // Load height map from file int components; unsigned char* data; data = stbi_load(filename, &width, &height, &components, 0); if (data == NULL) Log() << "Couldn't load image: " << filename << "\n"; // Convert height map to float. heightMap = new float*[width]; normals = new glm::vec3*[width]; tangents = new glm::vec3*[width]; for (int i = 0; i < width; i++) { heightMap[i] = new float[height]; normals[i] = new glm::vec3[height]; tangents[i] = new glm::vec3[height]; } for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { heightMap[x][y] = data[(x + y*width)*components] / 256.f; } } stbi_image_free(data); Filter3x3(); CalculateNormals(); GenerateVertices(); GenerateIndices(); for (int i = 0; i < width; i++) { delete[] normals[i]; delete[] tangents[i]; } delete[] normals; delete[] tangents; GenerateBuffers(); GenerateVertexArray(); }
HeightMappedPlane::HeightMappedPlane(float quadWidth, float quadHeight, float maxHeight, unsigned int width, unsigned int height, Texture* heightMap){ unsigned int quadCount = width * height; unsigned int vertexCount = (width + 1) * (height + 1); // We're not doing trianglestrips this time, so six indicies per quad (2 triangles * 3 points). unsigned int indexCount = quadCount * 6; Vertex* vertices = new Vertex[vertexCount]; GLuint* indices = new GLuint[indexCount]; //heightMap->PrintData(); GenerateVertices(vertices, quadWidth, quadHeight, maxHeight, width + 1, height + 1, heightMap); GenerateIndices(indices, width, height); GenerateUvCoordinates(vertices, 1.0f / quadWidth, 1.0f / quadHeight, width + 1, height + 1); Model::GenerateNormals(vertices, indices, vertexCount, indexCount); Model::GenerateTangents(vertices, indices, vertexCount, indexCount); Model::GenerateBitangents(vertices, vertexCount); Model::GenerateVao(vertices, indices, vertexCount, indexCount); }
void CDetailObject::Init( void ) { #if 0 GETRENDERERINTERFACEPARAMS renderInterfaceParam; static DWORD msgHash_GetRendererInterface = CHashString(_T("GetRendererInterface")).GetUniqueID(); m_ToolBox->SendMessage(msgHash_GetRendererInterface, sizeof(GETRENDERERINTERFACEPARAMS), &renderInterfaceParam, NULL, NULL ); static DWORD msgHash_CreateController = CHashString(_T("CreateController")).GetUniqueID(); m_ToolBox->SendMessage(msgHash_CreateController, sizeof( IController** ), &m_GeometryController ); static DWORD msgHash_CreateGeometry = CHashString(_T("CreateGeometry")).GetUniqueID(); m_ToolBox->SendMessage(msgHash_CreateGeometry, sizeof( IGeometry** ), &m_Geometry ); m_IRenderer = renderInterfaceParam.m_RendererInterface; //load the shader IEffect * MyEffect = NULL; //load the shader LOADFILEEXTPARAMS lfep; if( m_ShaderFile == "" ) { m_ShaderFile = "SHADERS/DEFAULTSHADER.efx"; } m_ShaderFile.MakeSafeFileName(); CHashString filename( m_ShaderFile ); lfep.fileName = (TCHAR*)m_ShaderFile; lfep.bInternalLoad = true; static DWORD msgHash_LoadFileByExtension = CHashString(_T("LoadFileByExtension")).GetUniqueID(); DWORD retval = EngineGetToolBox()->SendMessage(msgHash_LoadFileByExtension, sizeof(LOADFILEEXTPARAMS), &lfep); if( retval == MSG_HANDLED ) { CREATEEFFECTINTERFACE cef; cef.m_Name = &filename; static DWORD msgHash_GetEffectInterface = CHashString(_T("GetEffectInterface")).GetUniqueID(); EngineGetToolBox()->SendMessage(msgHash_GetEffectInterface, sizeof(CREATEEFFECTINTERFACE ), &cef ); MyEffect = cef.m_EffectInterface; if( !MyEffect ) { EngineGetToolBox()->Log( LOGERROR, _T("Could not load DetailObject's shader" ) ); } } GenerateVertices(); CREATEMATERIALINTERFACE cmat; CREATEOBJECTPARAMS cop; TCHAR buf[ 512 ]; CHashString hszType( _T("CMaterial" ) ); IHashString * hname = GetName(); if( m_GeometryController && m_Geometry ) { m_Geometry->SetController( m_GeometryController ); //set shader IMaterial * material = NULL; _stprintf( buf, "%s_mat", hname->GetString()); CHashString hszName( buf ); //Create the material cop.parentName = NULL; cop.typeName = &hszType; cop.name = &hszName; static DWORD msgHash_CreateObject = CHashString(_T("CreateObject")).GetUniqueID(); m_ToolBox->SendMessage(msgHash_CreateObject, sizeof(CREATEOBJECTPARAMS), &cop, NULL, NULL); if( material ) { cmat.m_Name = &hszName; static DWORD msgHash_GetMaterialInterface = CHashString(_T("GetMaterialInterface")).GetUniqueID(); m_ToolBox->SendMessage(msgHash_GetMaterialInterface, sizeof(cmat), &cmat, NULL, NULL); if( cmat.m_MaterialInterface ) { material = cmat.m_MaterialInterface; material->SetEffect( MyEffect ); } } m_Geometry->SetMaterial( material ); //do the proper allocation for the geometry BUFFERALLOCATIONSTRUCT tempalloc; tempalloc.m_Offset = m_VertexBufferAllocation.m_Offset; tempalloc.m_Size = m_VertexBufferAllocation.m_Size; tempalloc.m_Stride = m_VertexBufferAllocation.m_Stride; tempalloc.m_InterfaceHandle = m_VertexBufferAllocation.m_InterfaceHandle; tempalloc.m_AllocationHandle = m_VertexBufferAllocation.m_AllocationHandle; ////vertex size and offset should be current m_Geometry->SetVertexBufferAllocation( tempalloc ); tempalloc.m_Offset = m_IndexBufferAllocation.m_Offset; tempalloc.m_Size = m_IndexBufferAllocation.m_Size; tempalloc.m_Stride = m_IndexBufferAllocation.m_Stride; tempalloc.m_InterfaceHandle = m_IndexBufferAllocation.m_InterfaceHandle; tempalloc.m_AllocationHandle = m_IndexBufferAllocation.m_AllocationHandle; ////vertex size and offset should be current m_Geometry->SetIndexBufferAllocation( tempalloc ); } else { } InitializeTextures(); UpdateBoundingObject(); #endif }
void VegetationFixedGeometry::Build(Vector<VegetationRenderData*>& renderDataArray, const FastNameSet& materialFlags) { ReleaseRenderData(renderDataArray); renderDataArray.push_back(new VegetationRenderData()); VegetationRenderData& renderData = *renderDataArray[0]; NMaterial* vegetationMaterial = NMaterial::CreateMaterial(FastName("Vegetation_Material"), NMaterialName::GRASS, NMaterial::DEFAULT_QUALITY_NAME); vegetationMaterial->AddNodeFlags(DataNode::NodeRuntimeFlag); FastNameSet::iterator end = materialFlags.end(); for(FastNameSet::iterator it = materialFlags.begin(); it != end; ++it) { vegetationMaterial->SetFlag(it->first, NMaterial::FlagOn); } if(RenderManager::Instance()->GetCaps().isFramebufferFetchSupported) { vegetationMaterial->SetFlag(VegetationPropertyNames::FLAG_FRAMEBUFFER_FETCH, NMaterial::FlagOn); } vegetationMaterial->SetPropertyValue(VegetationPropertyNames::UNIFORM_WORLD_SIZE, Shader::UT_FLOAT_VEC3, 1, &worldSize); renderData.SetMaterial(vegetationMaterial); SafeRelease(vegetationMaterial); size_t resolutionCount = resolutionScale.size(); uint32 sortDirectionCount = GetSortDirectionCount(); Vector<VegetationIndex>& indexData = renderData.GetIndices(); Vector<VegetationVertex>& vertexData = renderData.GetVertices(); uint32 tilesPerRow = (uint32)resolutionScale[resolutionCount - 1]; uint32 maxClusterRowSize = (tilesPerRow * maxClusters); size_t maxTotalClusters = maxClusterRowSize * maxClusterRowSize; uint32 layerDataCount = 0; uint32 indexDataCount = 0; for(uint32 layerIndex = 0; layerIndex < maxLayerTypes; ++layerIndex) { TextureSheetCell& cellData = textureSheet.cells[layerIndex]; layerDataCount += VEGETATION_CLUSTER_SIZE[cellData.geometryId]; indexDataCount += VEGETATION_CLUSTER_INDEX_SIZE[cellData.geometryId]; } uint32 totalIndexCount = 0; for(uint32 i = 0; i < resolutionCount; ++i) { totalIndexCount += indexDataCount * (maxTotalClusters / (uint32)resolutionScale[i]); } totalIndexCount *= sortDirectionCount; indexData.resize(totalIndexCount); vertexData.resize(maxTotalClusters * layerDataCount); Vector<uint32> layerOffsets(maxLayerTypes); GenerateVertices(maxClusters, maxTotalClusters, maxClusterRowSize, tilesPerRow, unitSize, layerOffsets, renderData); GenerateIndices(maxClusters, maxClusterRowSize, layerOffsets, renderData); //VI: need to build vertex & index objects AFTER initialization GenerateRenderDataObjects(renderData); }
/** * erzeugt die OpenGL-Vertices. * * @author OLiver * @author FloSoft */ void TerrainRenderer::GenerateOpenGL(const GameWorldViewer& gwv) { width = gwv.GetWidth(); height = gwv.GetHeight(); LandscapeType lt = gwv.GetLandscapeType(); GenerateVertices(gwv); // We have 2 triangles per map point unsigned int triangleCount = width * height * 2; // Ränder zählen borders.resize(width * height); for(MapCoord y = 0; y < height; ++y) { for(MapCoord x = 0; x < width; ++x) { MapPoint pt(x, y); TerrainType t1 = gwv.GetNode(pt).t1; //-V807 TerrainType t2 = gwv.GetNode(pt).t2; unsigned int pos = GetVertexIdx(pt); if( (borders[pos].left_right[0] = TerrainData::GetEdgeType(lt, t2, t1)) ) borders[pos].left_right_offset[0] = triangleCount++; if( (borders[pos].left_right[1] = TerrainData::GetEdgeType(lt, t1, t2)) ) borders[pos].left_right_offset[1] = triangleCount++; t1 = gwv.GetNodeAround(pt, 3).t1; if( (borders[pos].right_left[0] = TerrainData::GetEdgeType(lt, t1, t2)) ) borders[pos].right_left_offset[0] = triangleCount++; if( (borders[pos].right_left[1] = TerrainData::GetEdgeType(lt, t2, t1)) ) borders[pos].right_left_offset[1] = triangleCount++; t1 = gwv.GetNode(pt).t1; t2 = gwv.GetNodeAround(pt, 5).t2; if( (borders[pos].top_down[0] = TerrainData::GetEdgeType(lt, t2, t1)) ) borders[pos].top_down_offset[0] = triangleCount++; if( (borders[pos].top_down[1] = TerrainData::GetEdgeType(lt, t1, t2)) ) borders[pos].top_down_offset[1] = triangleCount++; } } gl_vertices.resize(triangleCount); gl_texcoords.resize(triangleCount); gl_colors.resize(triangleCount); // Normales Terrain erzeugen for(MapCoord y = 0; y < height; ++y) { for(MapCoord x = 0; x < width; ++x) { MapPoint pt(x, y); UpdateTrianglePos(pt, gwv, false); UpdateTriangleColor(pt, gwv, false); UpdateTriangleTerrain(pt, gwv, false); } } // Ränder erzeugen for(MapCoord y = 0; y < height; ++y) { for(MapCoord x = 0; x < width; ++x) { MapPoint pt(x, y); UpdateBorderTrianglePos(pt, gwv, false); UpdateBorderTriangleColor(pt, gwv, false); UpdateBorderTriangleTerrain(pt, gwv, false); } } if(SETTINGS.video.vbo) { // Generiere und Binde den Vertex Buffer glGenBuffersARB(1, (GLuint*)&vbo_vertices); glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo_vertices); glBufferDataARB(GL_ARRAY_BUFFER_ARB, gl_vertices.size() * sizeof(Triangle), &gl_vertices.front(), GL_STATIC_DRAW_ARB); glVertexPointer(2, GL_FLOAT, 0, NULL); // Generiere und Binde den Textur Koordinaten Buffer glGenBuffersARB(1, (GLuint*)&vbo_texcoords); glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo_texcoords); glBufferDataARB(GL_ARRAY_BUFFER_ARB, gl_texcoords.size() * sizeof(Triangle), &gl_texcoords.front(), GL_STATIC_DRAW_ARB ); glTexCoordPointer(2, GL_FLOAT, 0, NULL); // Generiere und Binde den Color Buffer glGenBuffersARB(1, (GLuint*)&vbo_colors); glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo_colors); glBufferDataARB(GL_ARRAY_BUFFER_ARB, gl_colors.size() * sizeof(ColorTriangle), &gl_colors.front(), GL_STATIC_DRAW_ARB ); glColorPointer(3, GL_FLOAT, 0, NULL); vboBuffersUsed = true; } else { glVertexPointer(2, GL_FLOAT, 0, &gl_vertices.front()); glTexCoordPointer(2, GL_FLOAT, 0, &gl_texcoords.front()); glColorPointer(3, GL_FLOAT, 0, &gl_colors.front()); } }
/** * erzeugt die OpenGL-Vertices. * * @author OLiver * @author FloSoft */ void TerrainRenderer::GenerateOpenGL(const GameWorldViewer * gwv) { width = gwv->GetWidth(); height = gwv->GetHeight(); LandscapeType lt = gwv->GetLandscapeType(); GenerateVertices(gwv); unsigned int offset = width * height * 2; // Ränder zählen borders = new Borders[width * height]; for(unsigned short y = 0; y < height; ++y) { for(unsigned short x = 0; x < width; ++x) { unsigned char t1 = gwv->GetNode(x, y).t1; unsigned char t2 = gwv->GetNode(x, y).t2; unsigned int pos = y * width + x; if( (borders[pos].left_right[0] = BORDER_TABLES[lt][t1][t2][1]) ) { borders[pos].left_right_offset[0] = offset + border_count; ++border_count; } if( (borders[pos].left_right[1] = BORDER_TABLES[lt][t1][t2][0]) ) { borders[pos].left_right_offset[1] = offset + border_count; ++border_count; } t1 = gwv->GetNodeAround(x, y,3).t1; if( (borders[pos].right_left[0] = BORDER_TABLES[lt][t2][t1][1]) ) { borders[pos].right_left_offset[0] = offset + border_count; ++border_count; } if( (borders[pos].right_left[1] = BORDER_TABLES[lt][t2][t1][0]) ) { borders[pos].right_left_offset[1] = offset + border_count; ++border_count; } t1 = gwv->GetNode(x, y).t1; t2 = gwv->GetNodeAround(x,y,5).t2; if( (borders[pos].top_down[0] = BORDER_TABLES[lt][t1][t2][1]) ) { borders[pos].top_down_offset[0] = offset + border_count; ++border_count; } if( (borders[pos].top_down[1] = BORDER_TABLES[lt][t1][t2][0]) ) { borders[pos].top_down_offset[1] = offset + border_count; ++border_count; } } } gl_vertices = new Triangle[offset + border_count]; gl_texcoords = new Triangle[offset + border_count]; gl_colors = new ColorTriangle[offset + border_count]; // Normales Terrain erzeugen for(unsigned short y = 0; y < height; ++y) { for(unsigned short x = 0; x < width; ++x) { UpdateTrianglePos(x,y,gwv,false); UpdateTriangleColor(x,y,gwv,false); UpdateTriangleTerrain(x,y,gwv,false); } } // Ränder erzeugen for(unsigned short y = 0; y < height; ++y) { for(unsigned short x = 0; x < width; ++x) { UpdateBorderTrianglePos(x,y,gwv,false); UpdateBorderTriangleColor(x,y,gwv,false); UpdateBorderTriangleTerrain(x,y,gwv,false); } } //unsigned buffer_size = (offset ) * 2 * 3 * sizeof(float); if(SETTINGS.video.vbo) { // Generiere und Binde den Vertex Buffer glGenBuffersARB(1, (GLuint*)&vbo_vertices); glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo_vertices); glBufferDataARB(GL_ARRAY_BUFFER_ARB, (offset + border_count) * 3 * 2 * sizeof(float), gl_vertices, GL_STATIC_DRAW_ARB); glVertexPointer(2, GL_FLOAT, 0, NULL); // Generiere und Binde den Textur Koordinaten Buffer glGenBuffersARB(1, (GLuint*)&vbo_texcoords); glBindBufferARB(GL_ARRAY_BUFFER_ARB,vbo_texcoords); glBufferDataARB(GL_ARRAY_BUFFER_ARB, (offset + border_count) * 3 * 2 * sizeof(float), gl_texcoords, GL_STATIC_DRAW_ARB ); glTexCoordPointer(2, GL_FLOAT, 0, NULL); // Generiere und Binde den Color Buffer glGenBuffersARB(1, (GLuint*)&vbo_colors); glBindBufferARB(GL_ARRAY_BUFFER_ARB,vbo_colors); glBufferDataARB(GL_ARRAY_BUFFER_ARB, (offset + border_count) * 3 * 3 * sizeof(float), gl_colors, GL_STATIC_DRAW_ARB ); glColorPointer(3, GL_FLOAT, 0, NULL); } else { glVertexPointer(2, GL_FLOAT, 0, gl_vertices); glTexCoordPointer(2, GL_FLOAT, 0, gl_texcoords); glColorPointer(3, GL_FLOAT, 0, gl_colors); } }