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

Pages: 1 2 [3]
31
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 ?

32
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.

33
Graphics / SFML startup image
« on: April 04, 2009, 07:20:07 pm »
Thanks!

34
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?

35
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?

36
Window / Choppy animation & sfml
« on: March 16, 2009, 05:00:14 pm »
Well, i guess it's something with my system then. The stuttering only happens sometimes, not all the time.

37
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;
}

38
Audio / sf::Music Stop & Play does not play the sound & mem
« on: March 14, 2009, 10:07:06 pm »
Quote from: "Laurent"
He sent me a fix for stb_vorbis (please note that he did it in 5 minutes :D), the leaks are now gone.


Cool!

39
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;
}

40
Window / Relative mouse position on mac os x using SetCursorPosition
« on: March 10, 2009, 02:08:30 pm »
Quote from: "Ceylo"

What is exactly the behaviour you wish ? I could make the rectangle follow the mouse or accelerate according to the mouse position without having to prevent the mouse from moving.


Yes that's what i want. I managed to do it finally without centering the mouse, i was wondering why it didn't work without the virtual mouse. :D

41
Window / Relative mouse position on mac os x using SetCursorPosition
« on: March 09, 2009, 12:28:09 pm »
Quote from: "Ceylo"

But.. I wonder why you need to prevent the mouse from moving.


I need to prevent the mouse from moving because i don't want it to go outside the window, when the application is in windowed mode. How can i achieve what i want without reseting the mouse to the center of the screen or by any other means?

Edit:
In the past i used glfw and did not have any issues with this kind of behaviour. Under the hood glfw uses this code to position the mouse:


Code: [Select]

    CGDisplayMoveCursorToPoint( kCGDirectMainDisplay,
                                CGPointMake( x, y ) );


Also, i'm using version 1.4

42
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;
}

43
Graphics / Custom Refresh Rate
« on: March 06, 2009, 11:18:32 pm »
I discovered SFML a few days ago and it seems pretty cool.

I was wondering, is there a way to change the refresh rate to something higher that 60 hz?

Pages: 1 2 [3]
anything