SFML + OpenGL을 함께 사용하려고 시도하지만 잘 이해하지 못합니다. 튜토리얼에서 나는 window.setActive (false)을 사용한다고 썼다.SFML + OpenGL : 동시에 작업하는 방법은 무엇입니까?
내 코드 : 나는 원 그리기와 OpenGL을 부분을 언급 할 때, 모든 괜찮
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>
#include <iostream>
#include <sstream>
#include <math.h>
using namespace std;
int main()
{
sf::RenderWindow window(sf::VideoMode(640, 480), "SFML works!");
sf::FloatRect frect;
sf::Font font;
font.loadFromFile("PaPYRUS.ttf");
int z=45;
int x=0, y=0;
stringstream l;
l<<z;
cout<<l.str()<<endl;
string s="Lololololooooooooooooooooooooooooo0000000000oooooooooo\nlololololol "+l.str()+" lololo";
sf::Text text(s, font, 20);
text.setPosition(20, 40);
frect=text.getGlobalBounds();
cout<<frect.height<<" "<<frect.left<<" "<<frect.top<<" "<<frect.width;
bool running=true;
int x2=0, y2=0;
sf::CircleShape shape(30);
shape.setFillColor(sf::Color::Green);
while (running)
{
sf::Event event;
while (window.pollEvent(event))
{
x2+=2;
y2++;
shape.setPosition(x2, y2);
if (event.type == sf::Event::Closed)
running=false;
}
// From that place problems begin
window.setActive(true);
glClearColor(0.0f, 0.0f, 0.1f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
window.setActive(false);
window.draw(shape);
window.draw(text);
window.setActive(true);
glColor3f(1.0f, 0.0f, 0.1f);
glBegin(GL_POLYGON);
for (float i = 0; i<2 * 3.14; i += float(3.14/4))
{
glVertex2f(20 + 5*sinf(i), 40 + 6*cosf(i));
}
window.setActive(false);
window.display();
}
return 0;
}
. window.setActive (false)를 다른 코드 위치에 넣지 만 작동하지 않습니다.
오류 : "윈도우의 컨텍스트를 활성화하지 못했습니다" "OpenGL을 컨텍스트를 해제하지 못했습니다 : A"당신이 할 수있는 경우
이, 바로이 코드를 만드는 방법을 제시해주십시오.
window.setActive (false)를 사용하면 오류가 발생합니다. 나중에 window.pushGLStates(); 및 window.popGLStates();하지만 아무것도 좋은 –