Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8839779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:18:50+00:00 2026-06-14T10:18:50+00:00

I have been learning VBOs for a couple weeks now, and I have been

  • 0

I have been learning VBOs for a couple weeks now, and I have been told here that VBOs can render “~1 million vertices at several hundred fps”. However, my current VBO test program only gets around 50 FPS with a little of 1 million vertices to render. Are there ways to optimize VBO efficiency? Or, more likely, am I doing something incorrectly? My test program is here:

EDIT: Improved code based on feedback.

#include <windows.h>
#include <SFML/Graphics.hpp>
#include <iostream>

#include <glew.h>
#include <gl/gl.h>
#include <gl/glu.h>

using namespace std;

float cube_vertices[] = {-1, -1, 1,
                         1, -1, 1,
                         1, 1, 1,
                         -1, 1, 1,

                         -1, -1, -1,
                         -1, 1, -1,
                         1, 1, -1,
                         1, -1, -1,

                         -1, 1, -1,
                         -1, 1, 1,
                         1, 1, 1,
                         1, 1, -1,

                         -1, -1, -1,
                         1, -1, -1,
                         1, -1, 1,
                         -1, -1, 1,

                         1, -1, -1,
                         1, 1, -1,
                         1, 1, 1,
                         1, -1, 1,

                         -1, -1, -1,
                         -1, -1, 1,
                         -1, 1, 1,
                         -1, 1, -1};

float cube_normals[] = {0, 0, 1,
                        0, 0, 1,
                        0, 0, 1,
                        0, 0, 1,

                        0, 0, -1,
                        0, 0, -1,
                        0, 0, -1,
                        0, 0, -1,

                        0, 1, 0,
                        0, 1, 0,
                        0, 1, 0,
                        0, 1, 0,

                        0, -1, 0,
                        0, -1, 0,
                        0, -1, 0,
                        0, -1, 0,

                        1, 0, 0,
                        1, 0, 0,
                        1, 0, 0,
                        1, 0, 0,

                        -1, 0, 0,
                        -1, 0, 0,
                        -1, 0, 0,
                        -1, 0, 0};
class Scene {
public:
    void setup_projection( int w, int h ) {
        glViewport( 0, 0, w, h );
        glMatrixMode( GL_PROJECTION );
        glLoadIdentity();
        gluPerspective( 50, (GLdouble)w/(GLdouble)h, 1, 5000.0 );
        glMatrixMode( GL_MODELVIEW );
    }
};
int main() {
    ///Number of models to render
    int NumberOfCubes = 0;
    cout << "Enter number of cubes to render: ";
    cin >> NumberOfCubes;
    system("cls");

    ///Create vectors for mesh data
    //6 faces * 4 verts * x, y, z * number of cubes
    std::vector<float> vertices; vertices.resize(6*4*3*NumberOfCubes);
    std::vector<float> normals; normals.resize(6*4*3*NumberOfCubes);
    for(int i = 0; i < NumberOfCubes; i++)
    {
        for(int j = 0; j < 6*4*3; j++)
        {
            vertices[(i*6*4*3) + j] = cube_vertices[j] + i;
            normals[(i*6*4*3) + j] = cube_normals[j];
        }
    }

    ///Store size of the vectors
    int SizeOfVertices = vertices.size() * sizeof(float);
    int SizeOfNormals = normals.size() * sizeof(float);

    ///Window setup, lighting setup
    sf::RenderWindow window(sf::VideoMode(800, 600, 32), "Test");
    Scene scene;
    scene.setup_projection(window.getSize().x,window.getSize().y);
    glewInit();
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_LIGHTING);
    glShadeModel(GL_SMOOTH);
    glEnable(GL_LIGHT0);
    float XL = .5, YL = .1, ZL = 1;
    GLfloat ambientLight[] = { 0.2f, 0.2f, 0.2f, 1.0f };
    GLfloat diffuseLight[] = { 0.8f, 0.8f, 0.8, 1.0f };
    GLfloat specularLight[] = { 0.5f, 0.5f, 0.5f, 1.0f };
    GLfloat lightpos[] = {XL, YL, ZL, 0.};
    glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
    glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight);
    glLightfv(GL_LIGHT0, GL_POSITION, lightpos);

    ///Generate the VBO
    GLuint VBOID;
    glGenBuffers(1, &VBOID);
    glBindBuffer(GL_ARRAY_BUFFER, VBOID);
    glBufferData(GL_ARRAY_BUFFER, SizeOfVertices + SizeOfNormals, 0, GL_STATIC_DRAW);
    glBufferSubData(GL_ARRAY_BUFFER, 0, SizeOfVertices, &vertices[0]);
    glBufferSubData(GL_ARRAY_BUFFER, SizeOfVertices, SizeOfNormals + SizeOfVertices, &normals[0]);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

    ///FPS Stuff
    sf::Clock FPS;
    sf::Clock ShowFPS;
    float fps;

    ///Start loop
    cout << "Rendering " << NumberOfCubes * 8 << " vertices." << endl;
    cout << "Using graphics card: " << glGetString(GL_RENDERER) << endl;

    while( window.isOpen() ) {
        sf::Event event;
        while( window.pollEvent( event ) ) {
            if( event.type == sf::Event::Closed )
                window.close();
        }
        fps = FPS.getElapsedTime().asSeconds();
        fps = 1 / fps;
        FPS.restart();
        if(ShowFPS.getElapsedTime().asSeconds() > 1)
        {
            cout << "FPS: " << fps << "\t FrameTime: " << 1000 / fps << endl;
            ShowFPS.restart();
        }

        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        scene.setup_projection(window.getSize().x,window.getSize().y);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        gluLookAt(-25, -25, 150, 50, 50, 50, 0, 1, 0);

        glBindBuffer(GL_ARRAY_BUFFER, VBOID);
        glEnableClientState(GL_NORMAL_ARRAY);
        glEnableClientState(GL_VERTEX_ARRAY);
        glColor3f(1, 0, 0);

        glNormalPointer(GL_FLOAT, 0, 0);
        glVertexPointer(3, GL_FLOAT, 0, 0);

        glDrawArrays(GL_QUADS, 0, 6*4*NumberOfCubes);

        glDisableClientState(GL_VERTEX_ARRAY);
        glDisableClientState(GL_NORMAL_ARRAY);
        glBindBuffer(GL_ARRAY_BUFFER, 0);

        window.display();
    }
    return 1;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:18:51+00:00Added an answer on June 14, 2026 at 10:18 am

    After doing further research, I found out about VBO Indexing and was able to use that to get the several hundred FPS with a million vertices.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been learning Google AppEngine for a couple of weeks... now I am
I have been learning Scala for the past couple of months and now I
I have been learning Xcode 4.2 for a bit now and still can't get
I have been learning Java for a few weeks now and I am really
I have been learning C++ for three months now and in that time created
I have been learning Hibernate for the past few weeks, I have gotten most
I have been learning the mapreduce algorithm and how it can potentially scale to
I have been learning python for some time now. While starting this learning python
I have been learning Python for a while, and now I'd like to learn
I have been learning C++ with some books from school that are from the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.