Witam,
Mam problem z renderowaniem tekstury w moim programie.
Kod:
Klasa Game:
#pragma once
#include <vector>
#include <SFML/Graphics.hpp>
#include "Wall.h"
using namespace std;
using namespace sf;
class Game
{
public:
Game()
{
init();
}
void render(RenderWindow &window)
{
for (int i = 0; i < walls.size(); i++)
{
walls[i].render(window);
}
}
private:
void init()
{
{
newWall({ 0,1000 }, 'd');
newWall({ 0,744 }, 'g');
}
}
void newWall(Vector2f pos, char type)
{
Wall wall(pos, type);
walls.push_back(wall);
}
vector <Wall> walls;
};
Klasa Wall:
#pragma once
#include <SFML/Graphics.hpp>
using namespace sf;
class Wall
{
public:
Wall(Vector2f pos, char type) // type = 'g' - grass, 'd' - dirt
{
/*if (type == 'g')
wallTexture.loadFromFile("data/wallgrass.png");
else*/
wallTexture.loadFromFile("data/walldirt.png");
wall.setTexture(wallTexture);
wall.setPosition(pos);
}
FloatRect box()
{
return wall.getGlobalBounds();
}
float left()
{
return wall.getPosition().x;
}
float top()
{
return wall.getPosition().y;
}
float right()
{
return left() + box().width;
}
float bottom()
{
return top() + box().height;
}
void render(RenderWindow &window)
{
window.draw(wall);
}
private:
Sprite wall;
Texture wallTexture;
};
Po odpaleniu aplikacji sprite'y się nie pojawiają, a w konsoli pokazuję się informacja:
"An internal OpenGL call failed in Texture.cpp(98).
Expression:
glFlush()
Error description:
GL_INVALID_OPERATION
The specified operation is not allowed in the current state."
i tak 3 razy...
Co się stało?
Pozdrawiam wszystkich forumowiczów.