Im trying to create a GUI using the library Irrlicht in C++, however whilst wring my Gui Handler, I get SIGSEGV errors when trying to access any data outside the constructor.
My header looks like this:
#pragma once
#include <irrlicht.h>
#include "Structs.h"
#include <vector>
#include <string>
class GuiHandler
{
public:
GuiHandler(Structs::SAppContext *contIN);
~GuiHandler();
bool GuiEvent(const irr::SEvent& eventType);
struct RGBPicker
{
IGUIButton* sample;
IGUIStaticText* RGB[3];
IGUIEditBox* RGBValues[3];
int Colour[3];
};
RGBPicker bottomColour;
RGBPicker topColour;
int i;
}
The values are assigned to the 2 RGBPicker
variables in the constructor in the cpp file:
GuiHandler::GuiHandler(Structs::SAppContext *contIN)
{
context = contIN;
int xpos = 185;
int ypos= 110;
//bottomColour.pickerTexture->fill(s)
bottomColour.sample = context->env->addButton(rect<s32>(128+xpos, 16+ypos, 198+xpos, 86+ypos), 0, 111, L"");
bottomColour.sample->setEnabled(false); //static box
bottomColour.RGBValues[0] = context->env->addEditBox(L"", rect<s32>(64+xpos, 64+ypos, 120+xpos, 84+ypos), true, 0, 113);
bottomColour.RGBValues[1] = context->env->addEditBox(L"", rect<s32>(64+xpos, 40+ypos, 120+xpos, 60+ypos), true, 0, 113);
bottomColour.RGBValues[2] = context->env->addEditBox(L"", rect<s32>(64+xpos, 16+ypos, 120+xpos, 36+ypos), true, 0, 113);
for(int i = 0; i < 3; i++)
{
bottomColour.RGBValues[i]->setMax(3);
bottomColour.RGBValues[i]->setText(L"0");
}
bottomColour.RGBValues[0]->setToolTipText(L"B1");
bottomColour.RGBValues[1]->setToolTipText(L"G1");
bottomColour.RGBValues[2]->setToolTipText(L"R1");
bottomColour.RGB[0] = context->env->addStaticText(L"B:", rect<s32>(48+xpos, 64+ypos, 66+xpos, 84+ypos), false, false, 0, -1,114);
bottomColour.RGB[1] = context->env->addStaticText(L"G:", rect<s32>(48+xpos, 40+ypos, 66+xpos, 60+ypos), false, false, 0, -1,114);
bottomColour.RGB[2] = context->env->addStaticText(L"R:", rect<s32>(48+xpos, 16+ypos, 66+xpos, 36+ypos), false, false, 0, -1,114);
std::cout<<i<<std::endl;
i=2;
std::cout<<i<<std::endl;
}
Whilst everything works within the header- accesing all the topColour, bottomColour and context statements, when in any other method within the class, they result in a SIGSEGV. Even printing out i with cout. I know i must be doing very simple incorrectly however I can't work it out.
Thanks.