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 - Lowest0ne

Pages: [1]
1
General / Re: Link error due to object files (I think)
« on: April 24, 2013, 05:46:55 pm »
Ah, sweet.  Thank you very much :)

2
General / [SOLVED] Link error due to object files (I think)
« on: April 24, 2013, 05:32:00 pm »
My friends and I are having some trouble getting a project to statically link to SFML.

I happen to have a different project that links just fine (statically).  So I've been trying to figure out differences.  For my computer (WindowsXP, MinGW), the issue seems to stem from making a .o.

main.cpp:
#include <SFML/Graphics.hpp>
int main()
{
    sf::RenderWindow window;
    return 0;
}

I can compile with this command line:
Code: [Select]
g++ -I../../include main.cpp -o test.exe -DSFML_STATIC -L../../lib/sfml -lsfml-graphics-s -lsfml-window-s -lsfml-system-s
However, if I do this:
Code: [Select]
g++ -I../../include -c main.cpp -o main.o
g++ -I../../include main.o -o test.exe -DSFML_STATIC -L../../lib/sfml -lsfml-graphics-s -lsfml-window-s -lsfml-system-s
I get link errors: Undefined reference to sf::RenderWindow

Is there something that I am missing?

Thanks


3
Window / Re: Getting key pressed events to work
« on: July 16, 2012, 07:30:40 pm »
Strange how copy pasting code to make it clear for someone else finds the bug itself.
while (app.pollEvent(pEvent))
I sent more than one event when I hit Escape.  The first being the KeyPress of escape, the second I don't know (27), and then the KeyRelease of escape.  Of course, the key press set open to false, but the others set to true!

while (app.pollEvent(pEvent) && open)

As a side, I noticed:
while (app.pollEvent(pEvent))
{
        open = prgEvent(pEvent);
        print1(pEvent.key.code); // This prints the X location of the mouse on the window
}

Also, is there a link to how I can figure out what that mysterious 27 was?

4
Window / Re: Getting key pressed events to work
« on: July 16, 2012, 06:08:06 pm »
Putting breaks after the returns doesn't do anything.

Edit:  Okay, so in the main() message loop:
        while (app.pollEvent(pEvent))
        {
                open = prgEvent(pEvent);
                print1(open);
        }
 

I am getting a zero printed when I hit escape.  ?? case sf::Event::Closed: return false; quits my program ?


Edit2:  However this:
std::ofstream out("test.txt");
while (open)
{              
        while (app.pollEvent(pEvent))
        {
                open = prgEvent(pEvent);
        }
        out << open << std::endl;
        display();
        app.display();
}
out.close();

Prints a whole bunch of 1s to test.txt with only a zero from when I acitvate sf::Event::Closed:

What the heck is going on?  it's like I lost scope.

5
Window / Getting key pressed events to work
« on: July 16, 2012, 04:54:18 pm »
Hi all,

I'm teaching myself OpenGL, using SFML for a context.  I've finally gotten to the point where I want to be able to move the camera.  So you know, press 'w' and the camera's "move foward" becomes true.

I'm having a problem getting the input to actually trigger something though.  My guess is there is something simple I'm just missing, perhaps some one can help.
// My main function is where the message loop is:
sf::Event pEvent;
bool open = (app.isOpen()? true : false);
while (open)
{              
        while (app.pollEvent(pEvent))
        {
                open = prgEvent(pEvent);                               
        }
        display();
        app.display();
}
app.close();
delete model;
delete terra;
delete cam;
return 0;

// prgEvent(pEvent) takes the event and splits it into types,
// returning false if program should end
bool prgEvent(sf::Event& pEvent)
{
        //  A false return signals the end of the program
        switch (pEvent.type)
        {
        case sf::Event::KeyPressed: return prgKeyPressed(pEvent.key.code);
        case sf::Event::Closed: return false;  // Note that this works
        }
        return true;
}

//prgKeyPressed() makes a switch on the actual key

#define print1(x) std::cout << x << '\n'
bool prgKeyPressed(sf::Keyboard::Key& kpCode)
{
        // A false return signals the end of the program
        switch (kpCode)
        {

        case sf::Keyboard::Escape: print1(kpCode); return false;
        }
        return true;
}
 
@Exploiter: Like those tags? :)

So, in the case of sf::Keyboard::Escape I print kpCode (which is 36), and then return false, right?

I get 36 printing on console, but the program doesn't quit.  Like I said, I must be missing something here.

Thanks

6
General / Re: Runtime Errors - WinXP, MinGW (not code::blocks)
« on: July 09, 2012, 02:24:41 am »
Only a Visual Studio just-in-time-debug message.  I turned it off, but now I only get an error saying that it isn't turned on...

Perhaps I need to restart the computer.

7
General / Runtime Errors - WinXP, MinGW (not code::blocks)
« on: July 08, 2012, 08:42:26 pm »
Hi all,

I'm having some troubles getting SFML up and running with MinGW.  I'm very new to MinGW/Coding/makefiles/sfml, so any help is appreciated.

Here is enough info (I think) to at least point out a maybe.


I have all the needed .dlls in the folder, and I also get this crash when I run the exe not in msys.

I've tried just about every Win32 release (1.6 and 2.0) trying to get them to work.  I've noted that the 2.0 example programs (well, pong) don't work on my computer.  I thought I had 1.6 working, but now back to the drawing board.

I guess I'll try getting this working in VS and see if I can replicate it for MinGW?

Thanks.

8
General / Re: Beginner - SFML wait for message
« on: July 01, 2012, 12:29:06 am »
Quote
Why couldn't you have said that in your opening question?
Just because I figured the question had been asked a lot.  Anyway...

Basically, a display function is given to GLUT to use: glutDisplayFunc(myRenderSceneFunction).

glutIdlefunc() is given a function to do whenever the program is idle.  Most beginner tutorials have this function calling "MyRenderSceneFunction", so basically the graphics card catches on fire.

The solution is to set up a timer and use glutPostRedisplay, which would call the function defined with glutDisplayFunc().  Here's the code for the timer function that I have right now:
Code: [Select]
void update(int value) {


if (camera.moving())
{
camera.moveX();
camera.moveZ();
camera.moveY();
glutPostRedisplay(); //Tell GLUT that the scene has changed

}
//Tell GLUT to call update again in 25 milliseconds
glutTimerFunc(25, update, 0);
}

It is a very simple program.  The main thing is that rendering is never done unless there is something to render.  The timer simply ensures that framerate stays low.

I imagine something like this is possible with SFML, however it isn't with the way the tutorial code is presented, basically:
Code: [Select]
bool Running = true;
while (Running)
{
    App.Display();
}

We can limit framerate, but this still doesn't solve the fact that if nothing is happening, the frame shouldn't be updated.

9
General / Re: Beginner - SFML wait for message
« on: June 30, 2012, 06:45:03 pm »
I appreciate the help, but not the attitude.

Coming from GLUT, there are two very different functions: glutIdleFunc() and glutPostRedisplay().  Framerate/Sleeping has nothing to do with it.  Using Idle will loop as fast as told to (Framerate/Sleeping), and PostRedisplay is called when drawing is needed.

I'm looking to see if SFML has something similar.  If not, then I might as well just stick with the "more complex" APIs.

10
General / Re: Beginner - SFML wait for message
« on: June 29, 2012, 05:58:56 pm »
I did look for an answer, here and elsewhere.

Like the topic says, I'm a beginner.  Right now I am making the data structures for a game, so although I'm mostly doing GUI right now I don't want to have been locked into the Win32 API.  On the other hand, a program like VLC media player (which uses hardware rendering I would guess), doesn't use %50 of the CPU when paused.

I'll look into sf::Sleep.  Windows' Sleep is not good, because it makes the whole program unresponsive for that amount of time. 

Is 2.0 stable?

11
General / Beginner - SFML wait for message
« on: June 28, 2012, 10:03:19 pm »
Hi all, I just installed SFML and went through the "make a window" tutorial.  Almost everything is okay :)

I'm sure this question is asked a lot...  The program using all of the computer's resources (100% of a CPU and 1000 FPS).  I would like to be able to make the program do nothing unless it gets a message to do something (you know, like notepad).  Is this possible?

Pages: [1]