本文整理汇总了C++中VBO类的典型用法代码示例。如果您正苦于以下问题:C++ VBO类的具体用法?C++ VBO怎么用?C++ VBO使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VBO类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: draw
void Shader::draw( VBO& geometry, GLenum renderType ){
bindGeometry( &geometry );
VertexAttributeBase* attr = NULL;
if(geometry.getAttr("indices") == NULL ){
glDrawArrays( renderType, 0, (attr)? attr->count : 0 );
}
else{
attr = geometry.getAttr("indices");
//bind and draw the indices
attr->bind();
glIndexPointer( GL_UNSIGNED_INT, 0, 0);
glDrawElements( renderType, attr->count, GL_UNSIGNED_INT, 0);
//unbind
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0);
}
//unbind all the buffers and attributes
attr = NULL;
// for(a_it = attributes.begin(); a_it != attributes.end(); a_it++){
// glDisableVertexAttribArray( a_it->second );
// glBindBuffer( GL_ARRAY_BUFFER, 0 );
// }
}
开发者ID:Akira-Hayasaka,项目名称:ofxScene,代码行数:27,代码来源:Shader.cpp
示例2: DrawVertices
void VBO::DrawVertices(VBO& vertexBuffer, const GLenum mode, const GLsizei count) {
vertexBuffer.EnableVertexAttribInterleavedWithBind();
vertexBuffer.DrawVertices(mode, count);
vertexBuffer.DisableVertexAttribInterleavedWithBind();
}
开发者ID:Erkaman,项目名称:graphics-experiments,代码行数:8,代码来源:vbo.cpp
示例3: VBO
VBO* VBO::CreateIndex(const GLenum type) {
VBO* indexBuffer = new VBO();
indexBuffer->SetTarget(GL_ELEMENT_ARRAY_BUFFER);
indexBuffer->SetType(type);
indexBuffer->SetUsage(GL_STATIC_DRAW);
return indexBuffer;
}
开发者ID:Erkaman,项目名称:graphics-experiments,代码行数:9,代码来源:vbo.cpp
示例4: TEST_F
TEST_F(TransformFeedbackTest, test)
{
std::ifstream vsFile("data/transform_feedback.vert");
std::ifstream gsFile("data/transform_feedback.geom");
Shader vertex(GL_VERTEX_SHADER);
Shader geometry(GL_GEOMETRY_SHADER);
ShaderProgram shader;
Query query(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
VAO vao;
VBO vbo;
TFBO tfbo;
const GLchar* feedbackVaryings[] = { "outValue" };
GLfloat data[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
GLfloat feedback[15];
GLuint primitives;
ASSERT_TRUE(vertex.compile(vsFile));
ASSERT_TRUE(geometry.compile(gsFile));
shader.attach(vertex);
shader.attach(geometry);
shader.setTransformFeedbackVaryings(1, feedbackVaryings, GL_INTERLEAVED_ATTRIBS);
ASSERT_TRUE(shader.link());
shader.use();
shader.printDebug();
vao.bind();
vbo.bind();
vbo.setData(sizeof(data), data, GL_STATIC_DRAW);
GLint inputAttrib = shader.getAttribLocation("inValue");
vao.enableAttrib(inputAttrib);
glVertexAttribPointer(inputAttrib, 1, GL_FLOAT, GL_FALSE, 0, 0);
tfbo.setData(sizeof(data) * 3, nullptr, GL_STATIC_READ);
tfbo.bindBufferBase(0);
mogl::enable(GL_RASTERIZER_DISCARD);
query.begin();
TransformFeedback::begin(GL_TRIANGLES);
glDrawArrays(GL_POINTS, 0, 5);
TransformFeedback::end();
query.end();
mogl::disable(GL_RASTERIZER_DISCARD);
mogl::Sync::flush();
primitives = query.get<GLuint>(GL_QUERY_RESULT);
tfbo.getSubData(0, sizeof(feedback), feedback);
std::cout << primitives << " primitives written" << std::endl;
for (unsigned int i = 0; i < 15; ++i)
std::cout << feedback[i] << std::endl;
}
开发者ID:Ryp,项目名称:moGL,代码行数:54,代码来源:transform_feedback.cpp
示例5: assert
void UBOShaderInterface::SetUpBuffer(VBO &buffer)
{
assert(!buffer.Created());
buffer.Create();
buffer.Bind(GL_UNIFORM_BUFFER);
glBufferData(GL_UNIFORM_BUFFER, m_blockSize, NULL, GL_STREAM_DRAW);
// Allocate VBO using this size
buffer.Unbind();
}
开发者ID:222464,项目名称:GLLight2D,代码行数:13,代码来源:UBOShaderInterface.cpp
示例6: TrackBallCamera
VBOScene::VBOScene()
// Start of user code super class
// End of user code
{
// Start of user code constructor
cameras.push_back(new TrackBallCamera());
doubleBuffer = new DoubleBuffer();
doubleBuffer->getVertexBuffer()->init();
VBO* vBO = new VoxelVBO();
vBO->setInstanceSize(6);
doubleBuffer->setVBO(vBO);
updateCamera = true;
bindBuffer = false;
// End of user code
}
开发者ID:RetroGamingArena,项目名称:minequest,代码行数:15,代码来源:VBOScene.cpp
示例7: setVaoPointers
/// assuming vao is already bound
void ParticleBilboard::setVaoPointers(VBO &vbo, u32 start){
vbo.attrib(1).pointer_float(4, (sizeof(ParticleBilboard)), (void*)offsetof(ParticleBilboard, position)).divisor(1)
.attrib(2).pointer_float(4, (sizeof(ParticleBilboard)), (void*)offsetof(ParticleBilboard, velocity)).divisor(1)
.attrib(3).pointer_float(1, (sizeof(ParticleBilboard)), (void*)offsetof(ParticleBilboard, lifetime)).divisor(1)
.attrib(4).pointer_float(1, (sizeof(ParticleBilboard)), (void*)offsetof(ParticleBilboard, layer)).divisor(1)
.attrib(5).pointer_float(1, (sizeof(ParticleBilboard)), (void*)offsetof(ParticleBilboard, size)).divisor(1);
}
开发者ID:DezerteR,项目名称:Po-Male-Ka,代码行数:8,代码来源:Particles.cpp
示例8: assert
void
PrimitiveRenderer::bind(const VBO & vbo) {
if (vbo.hasVertexArrayObjects()) {
int a = vbo.getVertexArrayId();
if (!a) {
cerr << "trying to bind zero vao" << endl;
assert(0);
} else if (a != current_vertex_array) {
current_vertex_array = a;
glBindVertexArray(a);
}
} else {
glBindBuffer(GL_ARRAY_BUFFER, vbo.getVertexBufferId());
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.getIndexBufferId());
vbo.setPointers();
}
}
开发者ID:Sometrik,项目名称:framework,代码行数:17,代码来源:PrimitiveRenderer.cpp
示例9: VBO
void RAS_StorageVBO::IndexPrimitives(RAS_MeshSlot& ms)
{
RAS_MeshSlot::iterator it;
VBO *vbo;
for (ms.begin(it); !ms.end(it); ms.next(it))
{
vbo = m_vbo_lookup[it.array];
if (vbo == 0)
m_vbo_lookup[it.array] = vbo = new VBO(it.array, it.totindex);
// Update the vbo
if (ms.m_mesh->MeshModified())
{
vbo->UpdateData();
}
vbo->Draw(*m_texco_num, m_texco, *m_attrib_num, m_attrib, m_attrib_layer);
}
}
开发者ID:diekev,项目名称:blender,代码行数:21,代码来源:RAS_StorageVBO.cpp
示例10: commitVBO
bool commitVBO(U32 chunkCount, GLenum usage, GLuint& handleOut, size_t& offsetOut) {
if (chunkCount < VBO::MAX_VBO_CHUNK_COUNT) {
for (VBO& vbo : g_globalVBOs) {
if (vbo.allocateChunks(chunkCount, usage, offsetOut)) {
handleOut = vbo.handle();
return true;
}
}
VBO vbo;
if (vbo.allocateChunks(chunkCount, usage, offsetOut)) {
handleOut = vbo.handle();
g_globalVBOs.push_back(vbo);
return true;
}
} else {
VBO vbo;
if (vbo.allocateWhole(chunkCount, usage)) {
offsetOut = 0;
handleOut = vbo.handle();
g_globalVBOs.push_back(vbo);
return true;
}
}
return false;
}
开发者ID:IonutCava,项目名称:trunk,代码行数:27,代码来源:glMemoryManager.cpp
示例11: init
void init() {
camera.position[2] = 15;
libpng_version();
light0.slot = GL_LIGHT0;
light0.setDiffuse(1.0, 1.0, 1.0, 1.0);
light0.setPosition(0.0, 0.0, 1.0, 0.0);
light0.load();
light0.enable();
glewInit();
loadObj((char*) "models/350z.obj", &mesh);
VBOfromMesh(vbo, mesh);
vbo.generate();
int w, h;
test_texture = texture_bank.findOrReg((char*) "textures/350z/vinyls.png");
//test_texture = PNG_load((const char*) "textures/vinyls.png", &w, &h);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, test_texture);
programID = loadShaders("shaders/vertex.glsl", "shaders/fragment.glsl");
glUseProgram(programID);
uTex = glGetUniformLocation(programID, "texDiff");
glUniform1i(uTex, 0);
uProjection = glGetUniformLocation(programID, "projection");
uView = glGetUniformLocation(programID, "view");
uModel = glGetUniformLocation(programID, "model");
uLightPos = glGetUniformLocation(programID, "lightPos");
uLightDiff = glGetUniformLocation(programID, "lightDiff");
uLightSpec = glGetUniformLocation(programID, "lightSpec");
uCameraPosition = glGetUniformLocation(programID, "cameraPosition");
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_ALPHA_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_DEPTH_TEST);
}
开发者ID:Starkus,项目名称:NewHorizon,代码行数:51,代码来源:NewHorizon.cpp
示例12: init
virtual void init() override {
auto va = vbo.addQuad();
if (vbo.changeState(VBOs::Dirty, VBOs::Updating)) {
va[0].position = glm::vec3(-5.0f,-5.0f,0.0f);
va[1].position = glm::vec3(5.0f,-5.0f,0.0f);
va[2].position = glm::vec3(5.0f,5.0f,0.0f);
va[3].position = glm::vec3(-5.0f,5.0f,0.0f);
va[0].texCoord = glm::vec2(0.0f,0.0f);
va[1].texCoord = glm::vec2(1.0f,0.0f);
va[2].texCoord = glm::vec2(1.0f,1.0f);
va[3].texCoord = glm::vec2(0.0f,1.0f);
for (int i = 0; i < 4; ++i) {
// va[i].setColor(i/4.0f,0.0f,0.0f,1.0f);
va[i].setColor(1.0f,1.0f,1.0f,1.0f);
}
vbo.changeState(VBOs::Updating,VBOs::Updated);
} else {
Noto::error("VBO was in wrong initial state");
}
}
开发者ID:nonvirtualthunk,项目名称:axc,代码行数:24,代码来源:SimpleTestbed.cpp
示例13: main_test
int main_test(){
Context context;
StopWatch swatch;
World world;
CameraControl ev;
glPointSize(2.0);
ev.cam.position = vec(0.0f,0.0f,5.0f);
mouse_move_spawner.register_listener(&ev);
key_event_handler.register_listener(&ev);
FlatShader3D flat;
flat.SetProjection(ProjectionMatrix(0.01,0.01,0.01,200000.0));
GameObject * go = new GameObjectTest(context);
go->GravityBound = false;
go->aabb.pos[0] += 0.1;
go->aabb.pos[2] += 0.1;
go->aabb.pos[1] -= 4.0;
go->aabb.size = vec(20.0,2.0,20.0);
go->aabb.mass = 100000.0;
go->Tetra.TRS = TMatrix(vec(10.0f,0.0f,10.0f)) * SMatrix(vec(10.0f,1.0f,10.0f));
world.InsertObject(go);
go = new GameObjectTest(context);
go->GravityBound = false;
go->aabb.size = vec(2.0,2.0,2.0);
go->Tetra = Tetragon();
world.InsertObject(go);
VBO stars = context.Stars;
while(true){
Matrix<float,4> cameraMatrix;
go->aabb.pos = -ev.cam.position.As<double>() - vec(0.0,0.0,0.0);
print(go->aabb.pos);
auto goList = world.GetNearbyObjects(vec(0.0,0.0,0.0),5000000.0);
world.PhysicsUpdate(vec(0.0,0.0,0.0),500000,0.1);
for(auto go : goList){
go.Get()->DoUpdate(world);
}
//ev.cam.position = go->aabb.pos.As<float>() + vec(0.0f,-2.0f,0.0f);
print(go->aabb.pos);
swatch.Reset();
swatch.Start();
ClearBuffer(vec(0.0f,0.0f,0.0f,1.0f));
cameraMatrix = ev.GetCamera().getTransformMatrix();
/*cameraMatrix[3][0] = 0;
cameraMatrix[3][1] = 0;
cameraMatrix[3][2] = 0;
*/
flat.SetCamera(cameraMatrix);
flat.SetModelView(Matrix<float,4>::Eye());
context.StarColors.Bind(0);
stars.BindBuffer(0);
VertexBufferObject::DrawBuffers(DrawMethod::Points,100);
flat.SetCamera(ev.GetCamera().getTransformMatrix());
goList = world.GetNearbyObjects(vec(0.0,0.0,0.0),5000000.0);
for(auto go: goList){
go.Get()->Draw(flat);
}
SwapBuffers();
Sleep(1/30.0 - swatch.ElapsedSeconds());
}
}
开发者ID:rolfrm,项目名称:epiclib,代码行数:66,代码来源:octree_demo.cpp
示例14: write
// write output to VBO
void write(VBO& vbo, GLenum usage = GL_STATIC_DRAW) {
vbo.data(GL_ARRAY_BUFFER, _array, usage);
}
开发者ID:krig,项目名称:simplex,代码行数:4,代码来源:mesher.hpp
示例15: DialogBoxParam
//.........这里部分代码省略.........
}
}
else
{
worldTM = currentNode->GetWorldTM( time );
}
(*nodeIter)->m_toParentMatrix.push_back( Matrix4x4( worldTM[0], worldTM[1], worldTM[2], worldTM[3] ) );
}
localTM = currentNode->GetWorldTM().Inverse();
(*nodeIter)->m_worldToLocal = Matrix4x4( localTM[0], localTM[1], localTM[2], localTM[3] );
//Save the node
BinaryFile.saveNode( *nodeIter, myFile );
BinaryFile.saveInt( (*nodeIter)->m_triangleBatchesPerMaterial.size() );
for( auto materialIter = m_materialSet.begin(); materialIter != m_materialSet.end(); ++materialIter )
{
//Set the current material's VBO and IBO
//
IGameMaterial* currentMaterial = *materialIter;
TriangleBatch* currentBatch = triangleBatches[ currentMaterial ];
GMatrix localTMNoTrans = localTM;
localTMNoTrans.SetRow( 3, Point4( 0,0,0,1) );
if( currentBatch != nullptr )
{
MaxMaterial* currentMaxMaterial = currentBatch->m_material;
VBO* currentVBO = currentBatch->m_vbo;
IBO* currentIBO = currentBatch->m_ibo;
vector< NodeFace >& faceVector = facesPerMaterial.find( currentMaterial )->second;
//Get texture materials and export them
//
if( currentMaterial != nullptr )
{
int numOfTexMaps = currentMaterial->GetNumberOfTextureMaps();
myFile << "Number of texture maps: " << numOfTexMaps << "\n";
for( int i = 0; i < numOfTexMaps; ++i )
{
IGameTextureMap* gameTextureMap = currentMaterial->GetIGameTextureMap( i );
if( gameTextureMap != nullptr && gameTextureMap->IsEntitySupported() )
{
int stdMapSlot = gameTextureMap->GetStdMapSlot();
if( stdMapSlot == ID_DI )
{
wstring wBitmapFileName;
wBitmapFileName = gameTextureMap->GetBitmapFileName();
if( wBitmapFileName.size() > 0 )
{
BitmapInfo bi( gameTextureMap->GetBitmapFileName() );
BMMGetFullFilename( &bi );
wBitmapFileName = bi.Name();
std::string fullBitmapFileName( wBitmapFileName.begin(), wBitmapFileName.end() );
if( fullBitmapFileName.size() > 0 )
{
int lastSlash = fullBitmapFileName.find_last_of('\\') + 1;
if( lastSlash != string::npos )
{
const std::string bitmapFileName = fullBitmapFileName.substr( lastSlash );
开发者ID:Zanyruki,项目名称:PortfolioRepository,代码行数:67,代码来源:MaxExporter.cpp
示例16: glClear
void VBOScene::render()
{
// Start of user code render
Engine* engine = Engine::getInstance();
Shader* shader = engine->getShaders()[0];
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Enable blending
//glEnable(GL_BLEND);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if(background != NULL)
background->render();
//glBindBuffer(GL_ARRAY_BUFFER, 0);
//return;
//3D
glUseProgram(shader->getProgramID());
if(updateCamera)
{
glUniformMatrix4fv(shader->getMVPMatrixID(), 1, GL_FALSE, &getSelectedCamera()->getMVP()[0][0]);
/*glUniformMatrix4fv(shader->getMMatrixID(), 1, GL_FALSE, &getSelectedCamera()->getModel()[0][0]);
glUniformMatrix4fv(shader->getVMatrixID(), 1, GL_FALSE, &getSelectedCamera()->getView()[0][0]);
glUniformMatrix4fv(shader->getPMatrixID(), 1, GL_FALSE, &getSelectedCamera()->getProjection()[0][0]);*/
updateCamera = false;
}
//for(int i = 0; i < doubleBuffers.size(); i++)
{
glBindBuffer(GL_ARRAY_BUFFER, doubleBuffer->getVertexBuffer()->getId());
VBO* vBO = doubleBuffer->getVBO();
vector<Attribute*> attributes = vBO->getAttributes();
for(int i = 0; i < attributes.size(); i++)
glEnableVertexAttribArray(i);
int size = 0;
int instanceFace = 4;
for(int i = 0; i < attributes.size(); i++)
{
if( i == 2 )
size=0;
float stride = sizeof(GLfloat) * ( (attributes[i]->getDivisor()>0) ? 2 : 4);
int divisor = attributes[i]->getDivisor();
GLvoid* offset = (GLvoid*)(sizeof(GLuint) * size + sizeof(GLuint)*(divisor > 0 ? instanceFace*6*4/*72*/ : 0));//32 : 0));
glVertexAttribIPointer( i, attributes[i]->getSize(), GL_UNSIGNED_INT, stride, offset);
if(attributes[i]->getDivisor()>0)
glVertexAttribDivisor( i, attributes[i]->getDivisor());
size += attributes[i]->getSize();
}
//glBindBuffer(GL_ARRAY_BUFFER, doubleBuffer->getVertexBuffer()->getId());//bufferIDs[i]);
vector<GLuint>* data = doubleBuffer->getVertexBuffer()->getData();
//if(data->size() != oldSize)
{
int instanceCountFull = (data->size()-(instanceFace*6*4)/*72*/)/2;
//int instanceCount = min( instanceCountFull, 140000 );
glDrawArraysInstanced(GL_TRIANGLES, 0, instanceFace*6, instanceCountFull);
//glDrawArraysInstanced(GL_TRIANGLES, 0, 18, instanceCount);
//glDrawArraysInstanced(glDrawArraysInstanced, doubleBuffer->getIndiceBuffer()->getData()->size(), GL_UNSIGNED_INT, (void*)0, (data->size()-32)/4 );
// oldSize = data->size();
}
for(int i = 0; i < attributes.size(); i++)
glDisableVertexAttribArray(i);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
//2D
if(uI != NULL)
uI->render();
// End of user code
}
开发者ID:RetroGamingArena,项目名称:minequest,代码行数:86,代码来源:VBOScene.cpp
示例17: BindBufferToSetIndex
void UBOShaderInterface::BindBufferToSetIndex(VBO &buffer)
{
glBindBufferBase(GL_UNIFORM_BUFFER, m_bufferBindIndex, buffer.GetID());
}
开发者ID:222464,项目名称:GLLight2D,代码行数:4,代码来源:UBOShaderInterface.cpp
示例18: draw
virtual void draw() override {
// float effTheta = theta + deltaSinceLastUpdate().in(Seconds);
float effTheta = theta;
// float effTheta = epochNanosSteady() * 1000000.0f;
// float effTheta = glfwGetTime();
AxGL::checkError();
modelview = glm::lookAt(
glm::vec3(0.0f,0.0f,-10.0f),
glm::vec3(0.0f,0.0f,0.0f),
glm::vec3(0.0f,1.0f,0.0f)
);
modelview = glm::rotate(modelview,effTheta,glm::vec3(0.0f,0.0f,-1.0f));
projection = glm::perspective(45.0f,AxGL::aspectRatio(),0.5f,200.0f);
glDisable(GL_DEPTH_TEST);
texture->bind();
AxGL::checkError();
shader->bind();
AxGL::checkError();
shader->setUniform("ModelViewMatrix", modelview);
shader->setUniform("ProjectionMatrix", projection);
shader->setUniform("tex0",0);
AxGL::checkError();
vbo.drawElements();
AxGL::checkError();
}
开发者ID:nonvirtualthunk,项目名称:axc,代码行数:28,代码来源:SimpleTestbed.cpp
注:本文中的VBO类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论