Hi everyone, first I must say what a great community! anyways so I recently started with sfml and am self taught in c++ so don't get too technical on me if possible
So in my program I have a game class, player class, and graphics class(among others). The program runs fine but I get this error in the console >
An internal OpenGL call failed in Texture.cpp (95) : GL_INVALID_OPERATION, the s
pecified operation is not allowed in the current state
An internal OpenGL call failed in Texture.cpp (95) : GL_INVALID_OPERATION, the s
pecified operation is not allowed in the current state
Process returned 0 (0x0) execution time : 1.947 s
Press any key to continue.
The strange thing is the program seems to run fine. the code just loads up a texture, turns it in to a sprite then draws it to the screen.
Game class...(part of it)
void Game::GameLoop()
{
Graphics graphics;
Player player1;
while (isRunning)
{
player1.Update();
graphics.ClearWindow();
graphics.Draw(player1.xposition,player1.yposition,player1.direction);
graphics.DrawWindow();
//Close out of the window
isRunning = graphics.QueryWindow();
}
graphics.~Graphics();
}
Graphics.h
#ifndef GRAPHICS_H
#define GRAPHICS_H
#include <SFML/Graphics.hpp>
class Graphics
{
public:
Graphics();
~Graphics();
void Load();
void Draw(int xposition,int yposition,char direction);
void DrawWindow();
void ClearWindow();
bool QueryWindow();
sf::RenderWindow window;
sf::Texture chartexture;
sf::Sprite charsprite;
protected:
private:
};
#endif // GRAPHICS_H
Graphics.cpp
#include "Graphics.h"
Graphics::Graphics()
{
window.create(sf::VideoMode(800, 600, 32), "SFML works!");
Load();
}
void Graphics::Load()
{
chartexture.loadFromFile("data/graphics/characters/old man.bmp");
charsprite.setTexture(chartexture);
}
void Graphics::Draw(int xposition,int yposition,char direction)
{
window.draw(charsprite);
}
void Graphics::DrawWindow()
{
window.display();
}
void Graphics::ClearWindow()
{
window.clear(sf::Color::Red);
}
bool Graphics::QueryWindow()
{
sf::Event windowstate;
while (window.pollEvent(windowstate))
{
if(windowstate.type == sf::Event::Closed)return false;
}
return true;
}
Graphics::~Graphics()
{
chartexture.~Texture();
window.close();
}
Any help on how to do away with this would be great. It does't hamper the program but I can see it being problematic down the line...