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

  • SEARCH
  • Home
  • 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 7955107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:38:08+00:00 2026-06-04T03:38:08+00:00

I’m making a game in OpenGL on Windows using Code::Blocks (C++) and MinGW. All

  • 0

I’m making a game in OpenGL on Windows using Code::Blocks (C++) and MinGW. All the drawing and logic is fine, the game works perfectly. Until, suddenly, it doesn’t. After some random amount of time, the game Segfaults. As is typical with GL segfaults, the stack trace is unhelpful. The only thing I got was that the segfault occurred in the vendor’s implementation of OpenGL. I’ve tested this on multiple graphics cards from different vendors, and they ALL do this, so the problem is on my end.

I ran the program though gDEBugger and got the same unhelpful stack trace. Lol. I also used GLIntercept, but nothing jumped out at me. So I set about finding the segfault the manual way (BuGLe refuses to compile…) and basically write trace messages to a log. I’ve narrowed it down to one call to glDrawArrays. I’ve done a lot of poking around the internet and tried a lot of the fixes I found.

Because this game wasn’t coded for portability, I’ve been hesitant to run it in wine and valgrind. Before I go messing with that wonderful mess, I’d appreciate it if you could look at my code and find the error. (I’m sure it’s something obvious…)

(Note: For readability, I’ve removed all of my trace lines)

void PlayerShip::Render()
{
    glPushMatrix(); //Save the current state

    glTranslatef(m_PosX, m_PosY, 0);
    glRotatef(vect.Rotation - 90, 0, 0, 1); //Matrixes are applied in reverse order


    double xl = m_SizeX / 2, yl = m_SizeY / 2; //Get values to add/subract to the midpoint for the corners
    glEnable(GL_TEXTURE_2D); //Redundant
    TextureManager::Inst()->BindTexture(TexIDs::Playership01); //Bind the texture

    glEnableClientState(GL_VERTEX_ARRAY); //These enables and disables are redundant here
    glEnableClientState(GL_TEXTURE_COORD_ARRAY); 
    glDisableClientState(GL_NORMAL_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);

    GLdouble* Verts;
    Verts = new GLdouble[12] { -xl, -yl, -.5,    xl, -yl, -.5,
                           xl,  yl, -.5,    -xl, yl, -.5}; //Calculate quad vertices
    GLdouble* Texs;
    Texs = new GLdouble[8] {0, 0,    1, 0,   1, 1,    0, 1}; //Calculate texture vertices

    glVertexPointer(3, GL_DOUBLE, 0, Verts);
    glTexCoordPointer(2, GL_DOUBLE, 0, Texs);

    glDrawArrays(GL_QUADS, 0, 12);

    delete [] Verts;
    delete [] Texs;

    glPopMatrix();
}

The interesting thing is that this code works… for awhile. I’ve printed the values of all variables, they’re all correct, the pointers aren’t null, glGetError calls spaced throughout the code always return NO_ERROR. Frankly, I’m at a loss.

A note to any who suggest I do something different: I need to use vertex arrays to support legacy (1.4) GL implementations, and I’m declaring my arrays as pointers so that I can (in the future) reuse them for drawing multiple primitives at one time (say, having exhaust come out of the ship)

  • 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-04T03:38:10+00:00Added an answer on June 4, 2026 at 3:38 am

    Your last argument to glDrawArrays should be 4 (number of elements), not 12 (number of floats).

    You’re trying to draw 12 elements (= 36 floats), and accessing past the bounds of your array.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.