Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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);
}
share|improve this question

closed as off-topic by Byte56 Jul 7 at 14:16

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about debugging a problem in your project must present a concise selection of code and context so as to allow a reader to diagnose the issue without needing to read all of your code or to engage in extensive back-and-forth dialog. For more information, see this meta thread." – Byte56
If this question can be reworded to fit the rules in the help center, please edit the question.

    
This is a compiler error, not anything to do with OpenGL. What versions are you using? Compiler, SFML, windows/linux/mac? –  Jason Jul 6 at 16:42
    
Linux under ubuntu, with the latest version of GCC/G++ with the sfml version 2. –  Hakeem El Bakka-lee Jul 6 at 16:55
    
Please read the documentation‌​. sf::Window has no draw() method, that is in sf::RenderWindow(). You even have that commented out. Mixing OpenGL and the graphics module is a bad idea. –  Jason Jul 6 at 17:13
    
Why is it a bad idea ? For instance if i need to draw a menu i better do it in SFML, but if i don't mix them together i will end up with two loops : one for the menu and another for the game, wich is not optimal at all, and besides the optiness, i will not be able to reach the menu again from the game. It must be a solution. –  Hakeem El Bakka-lee Jul 7 at 4:56
1  
It's not a bad idea, the official tutorial even shows how. –  Alayric Jul 7 at 7:08
show 1 more comment

Browse other questions tagged or ask your own question.