void Shape::sendVertex() { if(m_vertexSent) { throw std::runtime_error("Vertex already sent"); } genVBO(); genVAO(); m_vertexSent = true; m_shader.setOffset(m_array_vertex_index); }
Scene::Scene(BoundingBox& sceneBounds, int width, int height) { color[0] = color[1] = color[2] = 0; pos[0] = pos[1] = 0; rot[0] = rot[1] = 0; boxes.push_back(sceneBounds); boxes[0].x1 = (boxes[0].fx1+1.0f)*0.5f*width; boxes[0].x2 = (boxes[0].fx2+1.0f)*0.5f*width; boxes[0].y1 = height - (boxes[0].fy1+1.0f)*0.5f*height; boxes[0].y2 = height - (boxes[0].fy2+1.0f)*0.5f*height; genVAO(); }
Mesh::Mesh(Grid* grid) { this->indexedModel = grid->getIndexedModel(); this->grid = grid; this->quad = NULL; this->reflectivity = 0; this->glossiness = 0; this->openglDrawHint = GL_STATIC_DRAW; genVAO(); genVBOS(grid->getIndexedModel()); indicesSize = grid->getIndexedModel()->indices.size() * sizeof(float); genIndexBuffer(grid->getIndexedModel()); this->referenceCount = 0; }
Mesh::Mesh(std::string fileName, float reflectivity, float glossiness) { ObjModel model(fileName); indexedModel = model.toIndexedModel(); this->reflectivity = reflectivity; this->glossiness = glossiness; this->quad = NULL; this->grid = NULL; this->openglDrawHint = GL_STATIC_DRAW; genVAO(); genVBOS(indexedModel); indicesSize = indexedModel->indices.size() * sizeof(float); genIndexBuffer(indexedModel); this->referenceCount = 0; }
Scene::Scene(GLuint texture, BoundingBox& textureBounds, BoundingBox& sceneBounds, int width, int height) { color[0] = color[1] = color[2] = 0; pos[0] = pos[1] = 0; rot[0] = rot[1] = 0; scale = 1; tex = texture; boxes.push_back(sceneBounds); boxes[0].x1 = (boxes[0].fx1+1.0f)*0.5f*width; boxes[0].x2 = (boxes[0].fx2+1.0f)*0.5f*width; boxes[0].y1 = height - (boxes[0].fy1+1.0f)*0.5f*height; boxes[0].y2 = height - (boxes[0].fy2+1.0f)*0.5f*height; genVAO(textureBounds); }
Mesh::Mesh(Quad* quad, bool dynamicDraw) { this->indexedModel = quad->getIndexedModel(); this->quad = quad; this->grid = NULL; this->reflectivity = 0; this->glossiness = 0; if (dynamicDraw) this->openglDrawHint = GL_DYNAMIC_DRAW; else this->openglDrawHint = GL_STATIC_DRAW; genVAO(); genVBOS(quad->getIndexedModel()); indicesSize = quad->getIndexedModel()->indices.size() * sizeof(float); genIndexBuffer(quad->getIndexedModel()); this->referenceCount = 0; }