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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:14:09+00:00 2026-06-04T12:14:09+00:00

I am following some tutorials and came up with the following code: // rendering.cpp

  • 0

I am following some tutorials and came up with the following code:

// rendering.cpp

#include "rendering.h"
#include <GL/gl.h>
#include <GL/freeglut.h>

void DrawGLScene()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
}

int InitGL(int argc, char** argv)
{
    /*glShadeModel(GL_SMOOTH);
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glClearDepth(1.0f);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);*/

    glutInit(&argc, argv);
    glutInitWindowSize(500, 500);
    glutInitWindowPosition(100, 100);
    glutDisplayFunc(DrawGLScene);
    glutCreateWindow("Swimming Simulation");
    glutMainLoop(); // Enter GLUT's main loop

    return true;
}

My main function is very simple and only calls that function:

#include "rendering.h"

int main(int argc, char** argv)
{
    InitGL(argc, argv);
    return 0;
}

I am compiling with this command:

g++ -Wall -g swim.cpp rendering.cpp -lglut -lGLU -o swim

Running swim creates a window as expected. However, if I uncomment the lines in InitGL, then I get a segmentation fault when running the program:

(gdb) r
Starting program: <dir> 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x000000335ca52ca7 in glShadeModel () from /usr/lib64/libGL.so.1
Missing separate debuginfos, use: debuginfo-install freeglut-2.6.0-6.fc15.x86_64 glibc-2.14.90-24.fc16.6.x86_64 libX11-1.4.3-1.fc16.x86_64 libXau-1.0.6-2.fc15.x86_64 libXdamage-1.1.3-2.fc15.x86_64 libXext-1.3.0-1.fc16.x86_64 libXfixes-5.0-1.fc16.x86_64 libXi-1.4.5-1.fc16.x86_64 libXxf86vm-1.1.1-2.fc15.x86_64 libdrm-2.4.33-1.fc16.x86_64 libgcc-4.6.3-2.fc16.x86_64 libstdc++-4.6.3-2.fc16.x86_64 libxcb-1.7-3.fc16.x86_64 mesa-libGL-7.11.2-3.fc16.x86_64 mesa-libGLU-7.11.2-3.fc16.x86_64
(gdb) backtrace
#0  0x000000335ca52ca7 in glShadeModel () from /usr/lib64/libGL.so.1
#1  0x0000000000401d67 in InitGL (argc=1, argv=0x7fffffffe198)
    at rendering.cpp:25
#2  0x0000000000401c8c in main (argc=1, argv=0x7fffffffe198) at swim.cpp:37

What should I be doing here to get my program to run without crashing?

  • 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-04T12:14:10+00:00Added an answer on June 4, 2026 at 12:14 pm

    Get rid of glut and use something better like GLFW
    and also a lot of those functions are deprecated so use a modern tutorial like
    http://www.opengl-tutorial.org/
    or
    http://ogldev.atspace.co.uk/

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

Sidebar

Related Questions

I read some tutorials and came up with the following script to authenticate with
I'm learning masm32, following some tutorials. In one tutorial: http://win32assembly.online.fr/tut3.html there is stated: LOCAL
I am trying to learn GNU autotools, and I am following some tutorials, I
I'm trying to implement my first Spring MVC controller, following Spring documentation, some tutorials
I tried following some of the code from here and here , but I
A while back I was following some tutorials an assembly. I was running it
I'm new to python and django but wanted to start following some tutorials. I
I have been working with Xcode 4.2.1, but following some tutorials and videos from
For a pet project I started to fiddle with ANTLR. After following some tutorials
I'm pretty new to Android Development, i'm following some Youtube tutorials currently. I'd like

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.