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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Bacu

Pages: [1] 2
1
General / Tutorial "Opening a window" code doesn't work righ
« on: November 18, 2011, 08:02:10 pm »
Quote from: "sbroadfoot90"
Probably this line here.

Code: [Select]
     states.back()->render(Window);

I'm guessing the signature for render is

Code: [Select]
void render(sf::RenderWindow Window);

or something like that. Change it to

Code: [Select]
void render(const sf::RenderWindow& Window);

winner winner. that was it.

2
General / Tutorial "Opening a window" code doesn't work righ
« on: November 18, 2011, 04:42:40 am »
Peculiar error. no clue on this one.

my code all other source files compile and link properly.
Code: [Select]
#include <vector>
#include <SFML\Graphics.hpp>
#include <SFML\System.hpp>

#include "core.h"
#include "state.h"
#include "state_game.h"

Core::Core()
{
WIDTH = 800;
HEIGHT = 600;
DEPTH = 32;
TITLE = "SpaceGame";
Window.Create(sf::VideoMode(WIDTH, HEIGHT, DEPTH), TITLE);
states.push_back(new State_Game(this));
}

int Core::run()
{
while (Window.IsOpened())
{
while (Window.PollEvent(Event))
{
if (Event.Type == sf::Event::Closed) Window.Close();
}

if (states.empty())
{
return 1;
}

states.back()->process();
states.back()->render(Window);

Window.Display();
}
return 0;
}

void Core::popState()
{
Core::states.pop_back();
}

void Core::pushState(State* newState)
{
Core::states.push_back(newState);
}



Error output
Code: [Select]
1>c:\sfml\sfml2\include\sfml\window\window.hpp(479): error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'
1>          c:\sfml\sfml2\include\sfml\system\noncopyable.hpp(67) : see declaration of 'sf::NonCopyable::NonCopyable'
1>          c:\sfml\sfml2\include\sfml\system\noncopyable.hpp(42) : see declaration of 'sf::NonCopyable'
1>          This diagnostic occurred in the compiler generated function 'sf::Window::Window(const sf::Window &)'
1>c:\sfml\sfml2\include\sfml\graphics\rendertarget.hpp(304): error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'
1>          c:\sfml\sfml2\include\sfml\system\noncopyable.hpp(67) : see declaration of 'sf::NonCopyable::NonCopyable'
1>          c:\sfml\sfml2\include\sfml\system\noncopyable.hpp(42) : see declaration of 'sf::NonCopyable'
1>          This diagnostic occurred in the compiler generated function 'sf::RenderTarget::RenderTarget(const sf::RenderTarget &)'

3
General / Tutorial "Opening a window" code doesn't work righ
« on: November 17, 2011, 04:40:22 am »
problem routed. I was being a stupid ameteur and including .cpp files that ended up making some knotted wreath of infinite self-reference.

4
General / Tutorial "Opening a window" code doesn't work righ
« on: November 17, 2011, 04:07:44 am »
Quote from: "Tex Killer"
Quote from: "Bacu"
today's problem. I've #included <SFML\Graphics>...


It should be SFML/Graphics.hpp
That's what I meant.

5
General / Tutorial "Opening a window" code doesn't work righ
« on: November 17, 2011, 03:05:48 am »
Quote from: "sbroadfoot90"
unrecognised symbol usually means that you aren't linking to the necessary libraries

I've linked to all of the -s-d.libs in the proper order. I'm fairly certain I copied all of the settings over from the project file that worked properly.

6
General / Tutorial "Opening a window" code doesn't work righ
« on: November 17, 2011, 02:51:28 am »
today's problem. I've #included <SFML\Graphics>, but for some reason if I try to make an sf::RenderWindow or any other thing, it says that it's an unrecognized symbol. My autocomplete doesn't show up when I type the sf:: namespace, either. But when I tell VC to open the header files, it has no problems opening them, but apparently something's wrong here.

7
General / Tutorial "Opening a window" code doesn't work righ
« on: November 11, 2011, 11:27:44 pm »
And now another question. How to statically link? all of the .lib are -d.

8
General / Tutorial "Opening a window" code doesn't work righ
« on: November 11, 2011, 10:06:25 pm »
I was dividing by 0, duh. okay, problem solved.

9
General / Tutorial "Opening a window" code doesn't work righ
« on: November 11, 2011, 09:43:54 pm »
Trying to play around with this stuff. This bit of code is supposed to create Triangles at the center of the screen, give them random velocity and spin, then display their movement.

Code: [Select]
#include <SFML/Graphics.hpp>
#include <iostream>
#include <math.h>
#include <time.h>
#include <vector>

sf::Vector2f origin;
sf::Vector2f gravity;
int frames;

float getrand(float a, float b)
{
return ((b-a)*((float)rand()/RAND_MAX))+a;
}


struct Triangle
{
sf::Shape Tri;
sf::Vector2f Pos;
sf::Vector2f Vel;
float Spin;

Triangle()
{
Tri.AddPoint(0,10);
Tri.AddPoint(20,0);
Tri.AddPoint(20,20);
Tri.SetOrigin(10,10);
Tri.SetPosition(origin);
Pos = Tri.GetPosition();
Spin = getrand(-360.f,360.f);
Vel.x = getrand(-.5f,.5f);
Vel.y = getrand(-.5f,.5f);
}

void Draw(sf::RenderWindow &app)
{
app.Draw(Tri);
}
void Physics()
{
Vel = sf::Vector2f(Vel.x + gravity.x/frames ,Vel.y + gravity.y/frames);
Pos = sf::Vector2f(Pos.x + Vel.x/frames ,Pos.y + Vel.y/frames);
Tri.SetPosition(Pos);
Tri.Rotate(Spin/frames);
}
};

int main()
{
srand((unsigned)time(0));
origin.x = 400;
origin.y = 300;
gravity.x = 0;
gravity.y = 3;
std::vector<Triangle*> triangles;

sf::RenderWindow App(sf::VideoMode(800,600,32),"oh man");
int frames = 60;
App.SetFramerateLimit(frames);

    while (App.IsOpened())
    {
        sf::Event Event;
        while (App.PollEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();
            // Escape key : exit
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Escape))
                App.Close();
        }

App.Clear();
Triangle* ptr = new Triangle;
triangles.push_back(ptr);
for (unsigned long x = 0; x < triangles.size(); x++)
{
std::cout<<triangles.at(0)->Pos.x<<" "<<triangles.at(0)->Pos.y<<"\n";
triangles.at(x)->Physics();
triangles.at(x)->Draw(App);
}
App.Display();
    }

    return EXIT_SUCCESS;
}


Two problems. The first is Triangle::Physics(); turns Vel and Pos into
Code: [Select]
+ Pos {x=-1.#IND000 y=1.#INF000 } sf::Vector2<float>
+ Vel {x=-1.#IND000 y=1.#INF000 } sf::Vector2<float>

Am I doing something wrong here?

Second, if I change Triangle::Physics to only increment Pos every time it's called, The call to Triangle::Draw(App); never ends up producing anything onscreen. If I only create one Triangle and never call Physics, it will display at the middle of the screen.

10
General / Tutorial "Opening a window" code doesn't work righ
« on: November 09, 2011, 07:19:00 pm »
Alright, been smooth so far. The differences between the tutorial and the 2.0 library are actually proving to be a good learning tool, gotta dig to figure it out.

anyway, having an issue with sf::Image.load. Getting "Failed to load image "sprite.png". Reason : Unable to open file". sprite.png is in the same directory as the executable. What am I doing wrong?

Code: [Select]
//#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Events");
sf::Image Image;
if(!Image.LoadFromFile("sprite.png"))
{
//std::cout<<"Failed to load";
//return EXIT_FAILURE;
}
    while (App.IsOpened())
    {
        sf::Event Event;
        while (App.PollEvent(Event))
        {
            if (Event.Type == sf::Event::Closed)
                App.Close();
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Escape))
                App.Close();
        }

//if(sf::Keyboard::IsKeyPressed(sf::Keyboard::A)) std::cout<<"A IS PRESSED";

App.Clear();
        App.Display();
    }

    return EXIT_SUCCESS;
}

11
General / Tutorial "Opening a window" code doesn't work righ
« on: November 07, 2011, 11:03:18 pm »
Quote from: "Tex Killer"
That tutorial doesn't treat events, so your window's close event is not used and the window isn't closed. Advance on the tutorials and you shall solve your problem.

So it seems. Missed that line. Oh well. Time to move forward.

12
General / Tutorial "Opening a window" code doesn't work righ
« on: November 07, 2011, 09:25:54 pm »
Quote from: "Laurent"
Something is seriously messed up, it's like you're mixing SFML 1.6 and 2.0.

Remove everything related to SFML and try again.

alright, getting closer. Builds and runs and I get a window, but the window's 'X' close button doesn't seem to work, nor does the minimize, nor can I drag the window around. I can only close it by closing the console it's running from. The debug information says that it doesn't exit with "0" as its return value.

13
General / Tutorial "Opening a window" code doesn't work righ
« on: November 07, 2011, 04:42:21 pm »
Quote from: "Laurent"
Seems like your SFML directory is messed up. Try to download it again.

Something was off with the download. The first time I extracted the .rar, it gave me an error. I downloaded and extracted over again but it kept happening; but if I extracted, got the error, then extracted and replaced all, I didn't get the error and Cmake did its job with no trouble.

But noooooooooow I've built the example and the same thing still happens. When I run the program, it also asks for sfml-window.dll and sfml-system.dll in addition to sfml-window-2.dll and sfml-system-2.dll. I tried using 1.6 dlls to no avail. Copying and renaming the -2.dlls gave errors.

14
General / Tutorial "Opening a window" code doesn't work righ
« on: November 07, 2011, 01:57:12 am »
Oh boy, more problems. I followed the instructions on using Cmake to put everything together, but I get this error:
Code: [Select]
CMake Error at CMakeLists.txt:131 (add_subdirectory):
  add_subdirectory given source "src/SFML" which is not an existing
  directory.


CMake Error at examples/ftp/CMakeLists.txt:8 (sfml_add_example):
  Unknown CMake command "sfml_add_example".


Configuring incomplete, errors occurred!

groan.

15
General / Tutorial "Opening a window" code doesn't work righ
« on: November 06, 2011, 09:07:25 pm »
Quote from: "OniLink10"
Quote from: "Bacu"
Quote from: "Laurent"
=> Known bug ;)

Well, what can I do now? Is the library useless to me until it's fixed or what?
Use SFML2.

I assume that all of the tutorials that are for 1.6 will more or less work for 2.0?

Pages: [1] 2