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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:05:36+00:00 2026-05-28T08:05:36+00:00

Myself and a few other guys are taking a crack at building a simple

  • 0

Myself and a few other guys are taking a crack at building a simple side scroller type game. However, I can not get a hold of them to help answer my question so I put it to you, the following code leaves me with a SIGSEGV error in the notated place… if anyone can tell me why, I would really appreciate it. If you need anymore info I will be watching this closely.

Main.cpp

Vector2 dudeDim(60,60);
Vector2 dudePos(300, 300);
Entity *test = new Entity("img/images.jpg", dudeDim, dudePos, false);

leads to:

Entity.cpp

Entity::Entity(std::string filename, Vector2 size, Vector2 position, bool passable):
mTexture(filename)
{
    mTexture.load(false);
    mDimension2D = size;

    mPosition2D = position;

    mPassable = passable;
}

leads to:

Textures.cpp

void Texture::load(bool generateMipmaps)
{
    FREE_IMAGE_FORMAT imgFormat = FIF_UNKNOWN;

    FIBITMAP *dib(0);

    imgFormat = FreeImage_GetFileType(mFilename.c_str(), 0);

//std::cout << "File format: " << imgFormat << std::endl;

if (FreeImage_FIFSupportsReading(imgFormat)) // Check if the plugin has reading capabilities and load the file
    dib = FreeImage_Load(imgFormat, mFilename.c_str());
if (!dib)
    std::cout << "Error loading texture files!" << std::endl;

BYTE* bDataPointer = FreeImage_GetBits(dib); // Retrieve the image data

mWidth = FreeImage_GetWidth(dib); // Get the image width and height
mHeight = FreeImage_GetHeight(dib);
mBitsPerPixel = FreeImage_GetBPP(dib);

if (!bDataPointer || !mWidth || !mHeight)
    std::cout << "Error loading texture files!" << std::endl;

// Generate and bind ID for this texture

vvvvvvvvvv!!!ERROR HERE!!!vvvvvvvvvvv

glGenTextures(1, &mId);

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

glBindTexture(GL_TEXTURE_2D, mId); 

int format = mBitsPerPixel == 24 ? GL_BGR_EXT : mBitsPerPixel == 8 ? GL_LUMINANCE : 0; 
int iInternalFormat = mBitsPerPixel == 24 ? GL_RGB : GL_DEPTH_COMPONENT;  

if(generateMipmaps)
    glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, mWidth, mHeight, 0, format, GL_UNSIGNED_BYTE, bDataPointer); 
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // Linear Filtering
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering

//std::cout << "texture generated " << mId << std::endl;
FreeImage_Unload(dib);
}

after reading Peter’s suggestion I have changed my main.cpp file to:

#include <iostream>
#include <vector>

#include "Game.h"

using namespace std;


int main(int argc, char** argv)
{

Game theGame;

/* Initialize game control objects and resources */
if (theGame.onInit() != false)
{
    return theGame.onExecute();
}
else
{
    return -1;
}
}

and it would seem the SIGSEGV error is gone and I’m now left with something not initializing. So thank you peter you were correct now I’m off to solve this issue.

ok so this is obviously a small amount of the code but in order to save time and a bit of sanity: all the code is available at:

GitHub Repo

  • 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-05-28T08:05:37+00:00Added an answer on May 28, 2026 at 8:05 am

    So after looking at your code I can say that it’s probably that you have not initialized you OpenGL context before executing that code.

    You need to call your Game::onInit() which also calls RenderEngine::initGraphics() before making any calls to OpenGL. Which you currently don’t do. You currently do main()->Game ctor (calls rendering engine ctor but that ctor doesn't init SDL and OpenGL)->Entity ctor->load texture

    For details look at the OpenGL Wiki FAQ

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

Sidebar

Related Questions

I'm using a few repository which I do not host myself and I thinking
I've been teaching myself Dojo over the last few days. However, if you look
I am currently trying to build myself a nice few classes to build my
I would try it myself, but I can't. Could someone check for me? I
I've read a few other posts like this one about avoiding repetition in Java
So working on a project recently (by myself - no other developers), I somehow
I've been driving myself crazy over the past few days over this one. We've
Lately, I've found myself in quite a few arguments with my boss about the
Does OpenID improve the user experience? Edit Not to detract from the other comments,
I often find myself wanting (and then usually writing) Scalaz type class instances for

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.