Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Segmentation Fault  (Read 2266 times)

0 Members and 1 Guest are viewing this topic.

Rosenzweig

  • Newbie
  • *
  • Posts: 13
    • View Profile
Segmentation Fault
« on: November 18, 2011, 08:35:53 pm »
I just compiled my SFML 2.0 (with OpenGL 3.2) and I get a segmentation fault when I run the program. I guess it's because I call the OpenGL functions when a context does not exist. Can someone help resolve this? I guess this is more of a C++ general question, but I've been trying to resolve this for a while.

Here is my source code:
http://pastebin.com/chxfsk63 - main.cpp
http://pastebin.com/d8d6YtWU - hipstergl.cpp
http://pastebin.com/Qq6QaP9j - hipstergl.hpp

Basically, I make a class with a void function called "Render" in hipstergl.hpp. Then in hipstergl.cpp I insert some OpenGL API calls into the Render function. Then finally I set up my context settings into my Render window, create a while loop for the window, call the Render function and the Window.Display function.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Segmentation Fault
« Reply #1 on: November 18, 2011, 09:26:04 pm »
It seems that the second one is empty. It might be my fault, I edited your message to make the links clickable.
Laurent Gomila - SFML developer

Rosenzweig

  • Newbie
  • *
  • Posts: 13
    • View Profile
Segmentation Fault
« Reply #2 on: November 18, 2011, 09:31:41 pm »
Quote from: "Laurent"
It seems that the second one is empty. It might be my fault, I edited your message to make the links clickable.


I fixed it. I was copying the links off my laptop, sorry for the mistake.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Segmentation Fault
« Reply #3 on: November 18, 2011, 09:38:12 pm »
You never call Render() in your main. So no OpenGL function is called.

You'd better use your debugger to find out what's wrong in your code.
Laurent Gomila - SFML developer

Rosenzweig

  • Newbie
  • *
  • Posts: 13
    • View Profile
Segmentation Fault
« Reply #4 on: November 18, 2011, 09:57:42 pm »
Quote from: "Laurent"
You never call Render() in your main. So no OpenGL function is called.

You'd better use your debugger to find out what's wrong in your code.


The link I gave you didn't show it, sorry. I removed the line to clear errors.

It gives me the segmentation fault when I do this:
Code: [Select]

OpenGL.Render();
Window.Display();

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Segmentation Fault
« Reply #5 on: November 18, 2011, 10:32:33 pm »
Ok. What does the debugger say?
Laurent Gomila - SFML developer

Rosenzweig

  • Newbie
  • *
  • Posts: 13
    • View Profile
Segmentation Fault
« Reply #6 on: November 18, 2011, 10:54:34 pm »
Quote from: "Laurent"
Ok. What does the debugger say?


The debugger says nothing. I have a console window that pops up with my GUI. Basically I run the program, the GUI pops up for a moment, and then it disappears (terminates). Thus I am left with a console window saying "Segmentation Fault".

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Segmentation Fault
« Reply #7 on: November 19, 2011, 11:31:24 am »
Quote
The debugger says nothing

If there's a segmentation fault, it should say something. Do you know how to use it?
Laurent Gomila - SFML developer

Rosenzweig

  • Newbie
  • *
  • Posts: 13
    • View Profile
Segmentation Fault
« Reply #8 on: November 19, 2011, 07:40:31 pm »
Quote from: "Laurent"
Quote
The debugger says nothing

If there's a segmentation fault, it should say something. Do you know how to use it?


I ended up fixing the problem. Something was wrong with the debugger (Damn Codeblocks) and I had to fix it. So after fixing it, I removed a few OpenGL functions to find out that only 2 OpenGL 1.x functions worked. So, I basically had to redownload gl3.h, because the old one was corrupted or something (I have no clue). Basically, it works now. Thanks for the help.