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.


Topics - AdrianM

Pages: [1] 2
1
Window / [MAC OS X - SFML2] GetMouseX() after SetCursorPosition(x,y)
« on: December 06, 2010, 12:31:14 pm »
This example won't output 400,300 after pressing 's'. Why is that? What is the correct way of doing it?

Code: [Select]

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <map>
#include <math.h>



////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{    
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Shader");
   
    // Create a clock to measure the total time elapsed
    sf::Clock clock;
   
    // Start the game loop
    while (window.IsOpened())
    {
        // Process events
        sf::Event event;
        while (window.GetEvent(event))
        {
            // Close window : exit
            if (event.Type == sf::Event::Closed)
                window.Close();

            if (event.Type == sf::Event::KeyPressed)
            {
                // Escape key : exit
                if (event.Key.Code == sf::Key::Escape)
                    window.Close();

                if (event.Key.Code == sf::Key::S)
                {
                    window.SetCursorPosition(400, 300);
                    printf("%d %d\n", window.GetInput().GetMouseX(), window.GetInput().GetMouseY());
                }
            }

            if (event.Type == sf::Event::MouseMoved)
            {
                printf("%d %d\n", event.MouseMove.X, event.MouseMove.Y);
            }
        }

        // Finally, display the rendered frame on screen
        window.Display();
    }
   
    return EXIT_SUCCESS;
}

2
Window / [MAC OS X-SFML2] No mouse moved events while pressing mouse
« on: December 03, 2010, 08:15:12 pm »
This little piece of code won't print anything while pressing either mouse buttons and moving the mouse, why is that?

Code: [Select]

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <map>
#include <math.h>



////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Shader");

    // Create a clock to measure the total time elapsed
    sf::Clock clock;

    // Start the game loop
    while (window.IsOpened())
    {
        // Process events
        sf::Event event;
        while (window.GetEvent(event))
        {
            // Close window : exit
            if (event.Type == sf::Event::Closed)
                window.Close();

            if (event.Type == sf::Event::KeyPressed)
            {
                // Escape key : exit
                if (event.Key.Code == sf::Key::Escape)
                    window.Close();
            }

if (event.Type == sf::Event::MouseMoved)
{
printf("%d %d\n", event.MouseMove.X, event.MouseMove.Y);
}
        }

        // Finally, display the rendered frame on screen
        window.Display();
    }

    return EXIT_SUCCESS;
}

3
Graphics / [MAC OS X] SFML2 & Failed to activate the window's conte
« on: November 30, 2010, 10:50:22 pm »
I'm trying to figure out what's happening here. I just get a white window with this code(the output should be black). Also looking at the console i see that every frame a message is sent: "Failed to activate the window's context." I'm on an INTEL card here(old i know), so what could be wrong?

Code: [Select]

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>
#include <iostream>

////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML OpenGL");

    // Start game loop
    while (window.IsOpened())
    {
        // Process events
        sf::Event event;
        while (window.GetEvent(event))
        {
            // Close window : exit
            if (event.Type == sf::Event::Closed)
                window.Close();

            // Escape key : exit
            if ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::Escape))
                window.Close();
        }
        // Clear the depth buffer & color buffer
        glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

        // Finally, display the rendered frame on screen
        window.Display();
    }

    return EXIT_SUCCESS;
}

4
Window / [Mac OS X] Window creation causes "flashes"
« on: November 30, 2010, 05:38:03 pm »
I have successfully implemented streaming video via apple's QTKit. The setup i'm currently working with is this:

Play the video and when exiting create a SFML Window.

The issue i'm experimenting is the following: in the process of the window creation the resolution changes and there  some flashes appear(black and white screens). I was thinking if there is a way to work around these so the transition from the movie to the sfml application would be smooth and no "flashes" would appear.

EDIT: I tested this with bot sfml 1.6 and sfml 1.7.

5
Window / latest SFML snapshot doesn't restore resolution on linux
« on: January 20, 2010, 08:42:17 pm »
I just downloaded the snapshot from here: http://www.sfml-dev.org/download.php. I'm running on Ubuntu 9.10 and after the application exited the resolution was not restored(it remained under the resolution of the sfml application). Is this a problem with SFML or i am forgetting something?

6
Window / Want to draw an image onto a window and not use OpenGL, how?
« on: January 09, 2010, 04:01:51 am »
Is it possible to draw an image onto the screen using SFML, but not usin OpenGL at all? I'm asking that because i'm streaming some video using theora and i figure uploading the video frame through gdi(on windows) for example would be much faster than uploading it to video memory as a texture, on older less powerful video cards. Can i do this? If not is there a way i can access the hdc for example so i can implement this?

7
SFML projects / Pirate's Treasure & Enchanted Forest
« on: August 18, 2009, 01:00:57 am »
I must say i thank all of you who helped creating SFML and who used it and helped make it a better library. I have succesufully used SFML in two quite similar projects: two arkanoid style games. What follows is a copy-paste from another post i made on gamedev.net(well, i am lazy programmer :) ).

I graduated this year with a Bsc in Computer Science and my graduation coincided with the completion of two casual games i worked on with a few friends.(i was responsible for all the programming). The games are two arkanoid clones with two different themes. They run well on Windows and also Macintosh(ppc or intel). For the development i used C++, a little ObjC, OpenGL, SFML, OpenAL, OpenALSoft(yes this was necessary because OpenAL crashed on Mac OS X sometimes, at that time), ogg and vorbis. You can find more information about the games at http://www.magic-games.net.

The development took a little too long because this was the first time we did something like this and we had a lazy artist, but i guess we met the deadline of me graduating and also completing not one but two games(rather similar :D ). I know there has been a long discussion about game clones and originality but i hope you enjoy the games. You can download them from the above mentioned site(and also PlayFirst.com) but if you do consider on purchasing one of them please support us and do it from http://www.magic-games.net (we use paypal and 2checkout so it's completely safe).

Enjoy and feel free to share any thoughts/suggestions/commentaries you might have.

PS: it seems some images contain artefacts due to the VSync off, these are not present in the actual game.(well they are not visible), also note that the first and last image have their description switched, i am sorry.

Screenshots:















8
Window / [MAC] Unwanted Alert Sound playing when pressing ESCAPE
« on: August 16, 2009, 12:30:00 am »
I have created a simple cocoa application from the template, renamed main.m to main.mm and added the opengl sample from the samples directory which comes with the sfml SDK. I modified it a little bit so that no background image is loaded and when you press escape to not exit. But everytime i press escape an alert sound plays. I don't want this to happen, how can i prevent it?
I want the bundle with the window to use it for registering the application (outside opengl), so this is a must, everything is done and working except for this naughty alert sound. :D. How can i prevent it?

Here is an example project: just run it and press escape, an alert sound will be played. Also i am using SFML 1.5.

http://www.gamesrebirth.com/adrian/alert_test.zip

9
Window / Mac OS X: [NSApplication terminate] does not work
« on: July 09, 2009, 10:36:55 pm »
I created a splash window using Interface builder that is displayed before creating the opengl window for a little game i am developing. All is fine but when i put this splash screen together with the opengl program that uses sfml and links amongst other to the window framework i cannot use calls to NSApplication anymore because they do not seem to work. The splash screen and the opengl program are decoupled and are meant to be displayed one before the other. How can i successufully use NSApplication and [NSApplication sharedApplication] when linking against the window framework ?

10
Graphics / SFML & Fullscreen on windows
« on: April 09, 2009, 05:55:24 pm »
Here's what's happening: on windows when entering full screen mode the taskbar does not dissapear instantly but after a few seconds.

I wonder if there is a way to make it dissapear instantly when entering fullscreen mode.

11
Graphics / SFML startup image
« on: April 03, 2009, 08:26:24 pm »
I noticed than when i create a windows before drawing anything with opengl in it i see some weird images there (memory garbage). I wonder how can this be avoided?

12
Graphics / Triple buffering
« on: March 21, 2009, 10:00:15 pm »
Is there any way to enable triple buffering in sfml? If not is this on a to-do list?

13
Window / Choppy animation & sfml
« on: March 16, 2009, 05:07:39 am »
I was playing with sfml the other day and found something rather peculiar.
I've written a small amount of code and watch it run for a 2-3 minutes: it shows a moving quad on screen. The moving quad sometimes stutters/freezes for a small amount of time. I've tested the code on windows and it freezes less often on my desktop system (GF 9600GT, 4GB RAM, intel pentium quadcore 2.4ghz) than on my macbook(2.1ghz intel pentium core 2 duo, 1gb sdram). On my macbook it stutters/freezes quite annoying and this is also present in a breakout clone i'm developing.
I've also checked the forums and notice someone else may have found the same issue, he called it: sfml is bucking.
I'm wondering what could be the cause of this.
Here's a minimal and complete example that i used to observe the problem:

Code: [Select]


#include <SFML/Graphics.hpp>
int WINAPI WinMain(HINSTANCE hInstance,
  HINSTANCE hPrevInstance,
  LPSTR lpCmdLine,
  int nShowCmd)
{
sf::WindowSettings as;
as.DepthBits = 8;

sf::RenderWindow* pApplication = new sf::RenderWindow;

pApplication->Create(sf::VideoMode(800, 600, 32),
"Ch-ch-choppy",sf::Style::Fullscreen,as);

bool isRunning = true;
while (isRunning && pApplication->IsOpened())
{
/*
sf::Event Event;
while (pApplication->GetEvent(Event))
{
switch (Event.Type)
{
case sf::Event::Closed :
pApplication->Close();
break;

case sf::Event::KeyPressed :
{
if (Event.Key.Code == sf::Key::Escape)
isRunning = false;
}
break;
}
}*/

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, 1.0f, 1.0f, 100.0f);
glMatrixMode(GL_MODELVIEW);

glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -6.0f);

static float timer = 0.0f;
timer += pApplication->GetFrameTime();
glTranslatef( sin(timer*4)*2, 0.0f, 0.0f);

float d = 0.4f;
glBegin(GL_QUADS);
glColor3f(0.0f, 0.0f, 1.0f);
glVertex2f(-d, -d);

glColor3f(0.0f, 1.0f, 1.0f);
glVertex2f(d, -d);

glColor3f(1.0f, 1.0f, 0.0f);
glVertex2f(d, d);

glColor3f(1.0f, 0.0f, 1.0f);
glVertex2f(-d, d);

glEnd();

pApplication->Display();
}

delete pApplication;
}

14
Audio / sf::Music Stop & Play does not play the sound & mem
« on: March 11, 2009, 05:49:04 pm »
I'm using the latest sources from the svn compiled in static libraries. I'm giving a minimal and complete example that causes incorect behaviour on my windows with SP3. I'm just loading a sound, playing it, stopping and then attempting to play it again. The second time it does not start playing which is rather weird. Pause functions as expected.
I searched the forum and there was another post about this issue. The solution there was to expect version 1.3 or get the latest sources from svn. Sadly i did not manage to solve this either way.
Here's the code:

Code: [Select]

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio.hpp>
#include <iostream>

#pragma comment(lib,"sfml-graphics-s.lib")
#pragma comment(lib,"sfml-window-s.lib")
#pragma comment(lib,"sfml-system-s.lib")
#pragma comment(lib,"sfml-audio-s.lib")

int main()
{
    // Load the music from an OggVorbis file
    sf::Music Music;
    if (!Music.OpenFromFile("01.ogg"))
        return EXIT_FAILURE;

    // Play it
    Music.Play();
std::cout<<"Playing the first time" << std::endl;
sf::Sleep(2.0f);
Music.Stop();
std::cout<<"Done & stopped" << std::endl;

Music.Play();
std::cout<<"Playing the second time" << std::endl;
sf::Sleep(2.0f);

std::cout<<"Done" << std::endl;

    std::cout << std::endl;

    // Wait until the user presses 'enter' key
    std::cout << "Press enter to exit..." << std::endl;
    std::cin.ignore(10000, '\n');

    return EXIT_SUCCESS;
}


Also the following code seems to report memory leaks, is it just me or it may be an issue with sfml?

Code: [Select]

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio.hpp>
#include <iostream>

#pragma comment(lib,"sfml-graphics-s-d.lib")
#pragma comment(lib,"sfml-window-s-d.lib")
#pragma comment(lib,"sfml-system-s-d.lib")
#pragma comment(lib,"sfml-audio-s-d.lib")

#include <crtdbg.h>

#ifdef _DEBUG
void* operator new(size_t nSize, const char * lpszFileName, int nLine);
#define DEBUG_NEW new(THIS_FILE, __LINE__)

#define MALLOC_DBG(x) _malloc_dbg(x, 1, THIS_FILE, __LINE__);
#define malloc(x) MALLOC_DBG(x)

#endif // _DEBUG

int main()
{
{
// Load the music from an OggVorbis file
sf::Music Music;
if (!Music.OpenFromFile("01.ogg"))
return EXIT_FAILURE;

// Play it
Music.Play();
std::cout<<"Playing the first time" << std::endl;
sf::Sleep(2.0f);

std::cout<<"Done" << std::endl;
}


#ifdef _DEBUG
_CrtDumpMemoryLeaks();
#endif

    return EXIT_SUCCESS;
}

15
Window / Relative mouse position on mac os x using SetCursorPosition
« on: March 08, 2009, 08:32:57 pm »
I'm trying to create a breakout clone and i'm having problems on mac os x.
I'm calculating a mouse position delta and then using SetCursor pos to position the mouse at the center of the screen. The problem is that i'm getting some stuttering, on mac os x. The PAD moves slow and with big increments in position. Here is some code to replicate the issue:

Edit:

Also with the same code there aren't any problems on windows.

Code: [Select]

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>

#pragma comment(lib,"sfml-graphics-s-d.lib")
#pragma comment(lib,"sfml-window-s-d.lib")
#pragma comment(lib,"sfml-system-s-d.lib")

#pragma comment(lib,"opengl32.lib")
#pragma comment(lib,"glu32.lib")

void Cleanup()
{
}

int main()
{
// Create the main window
sf::RenderWindow *App = new sf::RenderWindow(sf::VideoMode(800, 600, 32), "asda", sf::Style::Close);

    // Create a clock for measuring time elapsed
    sf::Clock Clock;

    // Set color and depth clear value
    glClearDepth(1.f);
    glClearColor(0.f, 0.f, 0.f, 0.f);

    // Enable Z-buffer read and write
    glEnable(GL_DEPTH_TEST);
    glDepthMask(GL_TRUE);

    // Setup a perspective projection
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(90.f, 1.f, 1.f, 500.f);

    // Start game loop
    while (App->IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App->GetEvent(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::Key::Escape))
                App->Close();

            // Resize event : adjust viewport
            if (Event.Type == sf::Event::Resized)
                glViewport(0, 0, Event.Size.Width, Event.Size.Height);
        }

        // Set the active window before using OpenGL commands
        // It's useless here because active window is always the same,
        // but don't forget it if you use multiple windows or controls
        App->SetActive();

        // Clear color and depth buffer
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        // Apply some transformations
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glTranslatef(0.f, 0.f, -200.f);

int dispX = App->GetInput().GetMouseX() - 400;
static int posX = 400;
posX += dispX;
if (posX < 0) posX = 0;
if (posX > 800) posX = 800;

if (dispX != 0)
App->SetCursorPosition(400, 300);

glDisable(GL_TEXTURE_2D);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, 800, 0, 600, -1, 1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();

int w = 100;
int h = 30;
glTranslatef(posX, 20, 0);
glBegin(GL_QUADS);
glVertex2f(-w, -h);
glVertex2f(+w, -h);
glVertex2f(+w, +h);
glVertex2f(-w, +h);
glEnd();

glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glEnable(GL_TEXTURE_2D);

        // Finally, display rendered frame on screen
        App->Display();
    }

delete App;

    return EXIT_SUCCESS;
}

Pages: [1] 2