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 8689909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:46:39+00:00 2026-06-12T23:46:39+00:00

I am attempting to implement a method to draw a bunch of cubes using

  • 0

I am attempting to implement a method to draw a bunch of cubes using vertexBufferObjects in OpenGL and Java however am running into a problem when calling the glDrawArrays command.

Essentially what this program does is cycle through x, y, z coordinates and calculates from there where the vertices of a cube centered at that coordinate are and then enters these vertices to a float buffer. (Note I am only entering the vertex data for one face at the moment as to keep the code simple while it is perfected)

The error that occurs is:

EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000006056ec90, pid=6424, tid=7696

int verticesPerObject = 12; //number of vertices per square
int chunkSizeX = 4; //number of cubes in x direction
int chunkSizeY = 4; //number of cubes in y direction
int chunkSizeZ = 4; //number of cubes in z direction
FloatBuffer vertexData = BufferUtils.createFloatBuffer(chunkSizeX * chunkSizeY * chunkSizeZ * verticesPerObject);

    for (int x = 0; x < chunkSizeX; x++) {
        for (int y = 0; y < chunkSizeY; y++) {
            for (int z = 0; z < chunkSizeZ; z++) {
                vertexData.put(new float[]{
                        (float)x * blockWidth - blockWidth/2, (float)y * blockHeight - blockHeight/2, (float)z * blockDepth + blockDepth/2,
                        (float)x * blockWidth + blockWidth/2, (float)y * blockHeight - blockHeight/2, (float)z * blockDepth + blockDepth/2,
                        (float)x * blockWidth + blockWidth/2, (float)y * blockHeight + blockHeight/2, (float)z * blockDepth + blockDepth/2,
                        (float)x * blockWidth - blockWidth/2, (float)y * blockHeight + blockHeight/2, (float)z * blockDepth + blockDepth/2
                });
            }
        }
    }

    vertexData.flip();

    int vboVertexHandle = glGenBuffers();
    glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
    glBufferData(GL_ARRAY_BUFFER, vertexData, GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

    glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
    glVertexPointer(verticesPerObject, GL_FLOAT, 0, 0L);

    glEnableClientState(GL_VERTEX_ARRAY);
    glDrawArrays(GL_QUADS, 0, verticesPerObject);
    glDisableClientState(GL_VERTEX_ARRAY);
  • 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-12T23:46:40+00:00Added an answer on June 12, 2026 at 11:46 pm

    Your call to glVertexPointer is wrong. Its first parameter is not the number of overall floats, but the number of floats (or rather components) of a single vertex, in your case 3. The reason for the access violation is just, that the glVertexPointer call fails and glDrawArrays then uses the default parameters, which might specify 4 components per vertex, or not use your buffer object or use some other unspecified parameters not matching your vertex data. So just replace it by

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

    The variable name verticesPerObject is a bit misleading anyway, since it doesn’t contain the number of vertices, but the number of floats, but this is mere cosmetics, the rest of its usage is correct.

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

Sidebar

Related Questions

I'm attempting to convert Java code to C# but I'm running into a problem
Attempting to implement a poor man's test of whether a process is still running
I'm attempting to implement nested object forms for my site, using Ryan Daigle's blog
I'm attempting to implement a Catalyst application using nginx as a frontend web proxy
So I'm attempting to write a simple sprite loading method using a canvas, and
I'm attempting implement the add method mentioned in the Generic sparse matrix addition question
I am attempting to implement an asynchronous method queue in Javascript as seen in
I'm attempting to implement a stack using a linked list. My stack constructor createStack()
I am attempting to implement an IShellBrowser. One method of such is: HRESULT STDMETHODCALLTYPE
I'm attempting to implement a tap-gesture recognizer on a UIImageView. However I can't get

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.