I'm right now following a tutorial to be able to use some OpenGL goodness in a SFML window. The thing is that when i call for sf::Window window() class and try to use the draw() method from this class i get an error ‘class sf::Window’ has no member named ‘draw’. But i have seen people on the internet using this method with the same class. So i might forget something really important here. If anybody have experienced the same problem, any answer will be much appreciated. Thank you.
Here is the code :
#include <iostream>
#include <string>
#include <unistd.h>
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include "Menu.hh"
#include "../../md2_test/Src/Render.h"
#include "../../md2_test/Src/Framework.h"
GLFWwindow* InitWindow(int ScrX, int ScrY);
void Rendering(GLFWwindow* window);
exec_menu()
{
//sf::RenderWindow window(sf::VideoMode(1200, 800), "Zappy");
sf::Window window;
window.create(sf::VideoMode(1200, 800), "OpenGl");
window.setVerticalSyncEnabled(true);
Menu menu;
bool running = true;
menu.music.play();
while (running)
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
if (event.type == sf::Event::KeyPressed)
{
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) window.close();
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
buttonSwitcher(0, menu);
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
buttonSwitcher(1, menu);
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Return) && menu.button == 3)
exec_game();
}
if (event.type == sf::Event::TextEntered)
{
if (event.text.unicode >= 46 && event.text.unicode <= 58 && menu.button == 1 && menu.i\
p.size() < 16)
menu.ip.push_back(static_cast<char>(event.text.unicode));
else if (event.text.unicode >= 33 && event.text.unicode < 127 && menu.button == 2 && m\
enu.hostname.size() < 12)
menu.hostname.push_back(static_cast<char>(event.text.unicode));
else if (event.text.unicode == 8 && menu.button == 1 && menu.ip.size() > 0)
menu.ip.pop_back();
else if (event.text.unicode == 8 && menu.button == 2 && menu.hostname.size() > 0)
menu.hostname.pop_back();
}
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
menu.textIp.setString(menu.ip);
menu.textHost.setString(menu.hostname);
window.clear();
window.draw(menu.spriteBack);
window.draw(menu.rect1);
window.draw(menu.rect2);
window.draw(menu.rect3);
window.draw(menu.text1);
window.draw(menu.text2);
window.draw(menu.text3);
window.draw(menu.textIp);
window.draw(menu.textHost);
window.display();
}
}
int main()
{
exec_menu();
return (0);
}
sf::Window
has nodraw()
method, that is insf::RenderWindow()
. You even have that commented out. Mixing OpenGL and the graphics module is a bad idea. – Jason Jul 6 at 17:13