Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: missing functions  (Read 1087 times)

0 Members and 1 Guest are viewing this topic.

TESTOHIRVI

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
missing functions
« on: June 20, 2022, 01:54:21 pm »
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>
#include "main.h"


int main()
{
    sf::ContextSettings settings;
    settings.antialiasingLevel = 8;
    sf::Window window(sf::VideoMode(800, 600), "The Game", sf::Style::Default, settings);
    glEnable(GL_TEXTURE_2D);
    window.setFramerateLimit(165);

    float x = 100;
    float y = 100;

    float offset = 0;
    //Get window width and height
    sf::Vector2u size = window.getSize();
    unsigned int width = size.x;
    unsigned int height = size.y;

    sf::CircleShape dude(15.f);
    dude.setFillColor(sf::Color(0, 255, 0));

    dude.setOutlineThickness(3.f);
    dude.setOutlineColor(sf::Color(250, 150, 100));

    dude.setPosition(x, y);

    bool running = true;
    while (running)
    {
        window.setActive(true);
        sf::Event event;

        while (window.pollEvent(event)) {

            switch (event.type) {
            case sf::Event::Closed:
                running = false;
                break;

            case sf::Event::Resized:
                // adjust the viewport when the window is resized
                glViewport(0, 0, event.size.width, event.size.height);
                width = event.size.width;
                height = event.size.height;

            default:
                break;
            }
        }


        //Game Loop

        if (event.type == sf::Event::KeyPressed) {
            switch (event.key.code) {
                case sf::Keyboard::Right:
                    ++offset;
                    break;

                case sf::Keyboard::Left:
                    --offset;
                    break;

                case sf::Keyboard::Down:
                    ++offset;
                    break;

                case sf::Keyboard::Up:
                    --offset;
                    break;
            }
        }

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        dude.move(x + offset, y + offset);
        //end the current frame
        window.clear();
        window.draw(dude);
        window.display();

        window.setActive(false);

    }


    return 0;
}
 

saying that there's no member called draw and no member called clear in window
« Last Edit: June 20, 2022, 03:56:44 pm by eXpl0it3r »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: missing functions
« Reply #1 on: June 20, 2022, 03:57:37 pm »
As mentioned on Discord, you need to use an sf::RenderWindow instead
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything