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

Pages: [1] 2 3 ... 6
1
General / Re: Slow startup
« on: November 17, 2012, 04:52:51 pm »
maybe as you said, your initial frame time is too large. You may change your collision code to check if the ball pass the bat instead of colliding.

For example if previously the ball is on top of the bat, and in the next frame the ball is below the bat a possible collision might have occurred. (Another check is necessary to determine if this is a false positive)

Next you can then resolve the a 2D line intersection equation to check the exact location of collision with the bat. The first line is from the current ball position to the next ball position. The second line would be your bat.

If an intersection occur, then it means a collision has occur.

Using this method, the collision is not so dependent on the time step being small.

Not sure if this helps

2
General / Re: Slow startup
« on: November 17, 2012, 05:30:06 am »
if possible, may I know how you did the collision detection between the bat? It might be due to the collision detection algo.

3
Window / [OSX] Window.getPosition return wrong coords
« on: November 16, 2012, 05:42:47 am »
In OSX, Window.getPosition() always return the coord (0, 900) despite manually setting or moving the window.

Here is a code example

#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#include <iostream>

int main(int argc, char** argv)
{
    sf::ContextSettings context_settings(16, 0, 0, 3, 1);

    sf::Window window(sf::VideoMode(1024, 768),
        "SFML - OpenGL Test", sf::Style::Default, context_settings);

    window.setPosition(sf::Vector2i(50, 50));

    glClearColor(0.39f, 0.58f, 0.93f, 1.0f);

    bool running = true;

    while (running)
    {
        sf::Event event;

        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                running = false;
            }
            else if (event.type == sf::Event::Resized)
            {
                glViewport(0, 0, event.size.width, event.size.height);
            }
            else if (event.type == sf::Event::KeyPressed)
            {
                if (event.key.code == sf::Keyboard::A)
                {
                    printf("Window Position - %i, %i\n",
                        window.getPosition().x, window.getPosition().y);
                }
            }
        }

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        window.display();
    }

    return EXIT_SUCCESS;
}
 

Pressing the key 'A' always prints the following output:
Window Position - 0, 900
Window Position - 0, 900
 

I am using the build from the source repository.

P.S another side question. I notice that setPosition takes a signed integer. Does it means it can accept negative coords. If it does, how does the negative coord affect window placement? In OSX, if i do setPosition({-50, -50}) the window wrap to the bottom right instead of the top left.

4
General / Re: need help with a weird problem (working with files)
« on: November 11, 2012, 04:42:55 am »
//
// Common values for folder_id
//     FOLDERID_Documents
//     FOLDERID_LocalAppData
//     FOLDERID_RoamingAppData
//     FOLDERID_ProgramData
//
sf::String GetSpecialFolderPath(REFKNOWNFOLDERID folder_id)
{
    LPWSTR wide_string = nullptr;

    if (FAILED(SHGetKnownFolderPath (folder_id, KF_FLAG_CREATE, nullptr, &wide_string)))
    {
         throw std::bad_typeid;
    }

    sf::String path(wide_string);

    // Free the memory that was allocated by the function
    CoTaskMemFree(wide_string);

    return path;
}
 

I think something like that will do. There might be error as I am typing from memory. For the exception, you can throw any exception you like or just abort the function. Depending on your choice of error handling mechanism.

P.S I no longer have a windows machine. So let me know if you are getting any error. I assume sf::String can take wide strings. If it can't then just use std::wstring.

5
General / Re: need help with a weird problem (working with files)
« on: November 10, 2012, 05:35:18 pm »
It is quite long since i used it. Not sure if it is the same. In windows there is this function call

SHGetKnownFolderPath(...)

You can use that function to get the path to the user documents folder.

Here is a link to msdn. Do note this would need vista and above

http://msdn.microsoft.com/en-us/library/bb762188%28VS.85%29.aspx

regards

6
General / Re: Get mouse position without event
« on: November 09, 2012, 10:05:33 pm »
Why not use the X and Y field in the mouse button event to check for mouse coords too?

if(event.type == sf::Event::MouseButtonPressed)
{
        click = true;
        mouseX = event.mouseButton.x;
        mouseY = event.mouseButton.y;
}
if(event.type == sf::Event::MouseMoved)
{
        mouseX = event.mouseMove.x;
        mouseY = event.mouseMove.y;
}
 

7
General / Re: need help with a weird problem (working with files)
« on: November 09, 2012, 09:35:56 pm »
Your video upload is wrong. You uploaded the shortcut instead of the actual video.

Where are you writing the file to? As Sui stated, have you tried writing to My Documents or Application Data instead?

8
General / [OSX] sfml 2.0 RC and opengl 3.2
« on: November 09, 2012, 08:56:12 am »
Following this thread

http://en.sfml-dev.org/forums/index.php?topic=9083.msg61236#msg61236

and after adding the following code to SFContext.mm to the function SFContext::createContext

// Add support for OpenGL 3.2 on Mac OS X Lion and later
    if (settings.majorVersion > 3 || (settings.majorVersion == 3 && settings.minorVersion >= 2)) {
        attrs.push_back(NSOpenGLPFAOpenGLProfile);
        attrs.push_back(NSOpenGLProfileVersion3_2Core);
    } else {
        attrs.push_back(NSOpenGLPFAOpenGLProfile);
        attrs.push_back(NSOpenGLProfileVersionLegacy);
    }

 

It gives the following error upon attempting to create a opengl 3.2 context

2012-11-09 15:42:08.715 sfml-test-d[8498:5503] invalid share context
2012-11-09 15:42:08.717 sfml-test-d[8498:5503] invalid context
Error. Unable to create the context.
Failed to activate the window's context
Failed to activate the window's context
......

My mac does support opengl 3.2 core profile.

9
General / Re: VS 11, and variadic templates with std::thread
« on: November 06, 2012, 08:47:04 pm »
A bit late to this post. Your original code don't work because std::thread requires a function to execute not a member function.

void LoadingScreens::RunLoadingScreen(LoadingScreen LS,EngineWindow& glWindow);

is a member function of class LoadingScreens. Now in C++ in order to execute a member function (i.e non-static function) there must aways be a calling class object. Notice how to call a class member function, you have to create a class object and call using it e.g

LoadingScreens screens_1;
LoadingScreens* screens_2 = new LoadingScreens;
screens_1.SuperFuncOne();
screens_2->SuperFuncOne();

by simply passing in only the function signature &LoadingScreen::RunLoadingScreen to the std:thread constructor, it still requires a vital piece of information to run the member. Which is of course from which class object should this member function be called from?

Following Nexus point, this is where stuff from the <functional> header comes into play. First you have to convert the member function into a regular function. this is where std::mem_fn is used. By calling

auto thread_friendly_func = std::mem_fn(&LoadingScreens::RunLoadingScreen);

thread_friendly_func is now a regular function pointer which points to a function similar to below:

MyNewFunc(LoadingScreens* object, LoadingScreen LS,EngineWindow& glWindow);

Now that we have a regular function, we can easily pass that function signature to std::thread and set the arguments for it.

std::thread RunningLoadingScreen(thread_friendly_func, screens_1, CurrLoadScreen, glWindow);

P.S I have no idea if in your original post LoadingScreens and LoadingScreen are the different or just a typo error. I treat them as different.

regards

10
Graphics / [OS X] Lion and opengl 3
« on: October 31, 2011, 05:03:30 am »
Is it possible to choose to create in Core profile instead? I would like to create in 3.2 profile while in OS X.

regards

11
Graphics / [OS X] Lion and opengl 3
« on: October 29, 2011, 08:18:44 pm »
After looking around the web, it seems that Lion only supports the 3.2 core profile.

http://www.opengl.org/wiki/Core_And_Compatibility_in_Contexts

Quote

"The 3.0 form of context creation allows the user to ask for a profile. Initially, only one profile was available: core. In 3.2, a new profile was added: compatibility. An implementation is only required to define core, so compatibility is not guaranteed to be available. However, it's a safe bet that it is (unless you're using Mac OSX 10.7, in which case 3.2 core or 2.1 are your only choices)."


Furthermore using this program [1] revealed that my current OS Lion would support up to 3.2 core profile. However it does not have support for 3.2 compatibility profile.

As I have not used SFML for quite awhile. I was wondering if SFML is trying to create the context in compatibility profile? Is this the reason or am I missing something?

[1] http://itunes.apple.com/us/app/opengl-extensions-viewer/id444052073?mt=12

regards

12
Graphics / [OS X] Lion and opengl 3
« on: October 29, 2011, 12:18:22 pm »
Hi, just wanted to ask any mac user out there if Lion officially support opengl 3 contexts?

I heard rumors on the web that Lion have supports up till 3.2 contexts.

However I can't seems to create SFML using a 3.[0|1|2] context. It always defaults to a 2.1 context

My hardware does support opengl 3.3 as I have created a 3.3 context in windows using boot camp

regards

13
General / How to link to SFML 2.0 statically
« on: October 29, 2011, 10:16:35 am »
just curious, is it not possible to include them all in an umbrella framework?

I know the apple page discourages it. But would that work?

regards

14
General / How to link to SFML 2.0 statically
« on: October 29, 2011, 09:35:18 am »
Thanks for the help.

Now I rebuild SFML with the BUILD_FRAMEWORK options checked. However during the linking stage, it seems to be not able to find certain symbols eg. sf::VideoMode etc

Code: [Select]

make -f ./build.makefile config=config.makefile

g++ -c -fmessage-length=0 -DDEBUG -O0 -g3 -gdwarf-2  -Wall -Wno-missing-braces main.cpp -o debug/main.o

g++ -c -fmessage-length=0 -DDEBUG -O0 -g3 -gdwarf-2  -Wall -Wno-missing-braces -MM -MP -MT debug/main.o main.cpp -o debug/main.d

g++ -framework SFML -framework OpenGL -framework Cocoa -gdwarf-2   -o debug/sfml-test-d debug/main.o

Undefined symbols for architecture x86_64:
  "sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)", referenced from:
      _main in main.o
  "sf::Window::Window(sf::VideoMode, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, sf::ContextSettings const&)", referenced from:
      _main in main.o
  "sf::Window::PollEvent(sf::Event&)", referenced from:
      _main in main.o
  "sf::Window::Display()", referenced from:
      _main in main.o
  "sf::Window::~Window()", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[1]: *** [debug/sfml-test-d] Error 1
make: *** [tests] Error 2


edit: if I compile with just the shared libraries it works (i.e with the -l options). How do I get it to compile using the framework option?

15
General / How to link to SFML 2.0 statically
« on: October 28, 2011, 03:51:44 am »
Hi Hirua,

the problem I have is that my end product is not an app so I can't bundle as a an application bundle (.app). My end product is another set of library (dylib) that is distributed to the customer to used. The customers are the ones that create the bundle (.app).

For example my final product is XYZ.dylib, where customer then dynamically link to it to use it in their own software.

However XYZ.dylib uses SFML for its backend drawing. If I am to link to SFML shared lib, when distributing the XYZ.dylib, I have to distribute the SFML.dylib together, which I have to tell the customer to install the SFML.dylib in a particular place where the system can find it.

Just an additional note on the XYZ.dylib that we are creating. XYZ.dylib(dll) is cross platform. A goal was to create it with a C API so our customer can place the lib in any location they want and use dlopen/dlsym(on unixes) or LoadLibrary(on windows) to load the contents. However it would defeat the purpose if we have to specifically tell the customers where to place the SFML.dylib so it would run.

We are doing in such a manner to achieve dylib loading via a relative path. Hence if we copy the project folder from one computer to another computer it will still work or compile without the need to place the dylib in the /Library/Frameworks/ folder

This was the reason why we wanted to add SFML as a static lib. I am not sure if there is other way to solve it by including it as a shared lib.

regards

Pages: [1] 2 3 ... 6
anything