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

Pages: 1 [2] 3
16
Graphics / RenderWindow not showing OpenGL elements
« on: June 04, 2008, 12:17:37 am »
Upgrading to the latest SVN yesterday seems to have got rid of the unhandled exception I was getting when pressing a key to end the program.

17
Audio / Delays / program locks after playing sounds
« on: June 04, 2008, 12:14:23 am »
I recently added some sounds to my current project and noticed that there were some very brief delays in my display and then several seconds later a much longer pause  - basically the program locks up for a few seconds. It was very noticeable as it's a scrolling 3D view drawn with OpenGL. I'm tried WAV and OGG files and the result is the same. The sounds themselves seem to play fine.

I've tried adding a simple sound to play in the SFML OpenGL example of the white cube and got the same results. I added these lines just before the start game loop:

sf::SoundBuffer doorBuffer;
sf::Sound doorSound;
doorBuffer.LoadFromFile("datas/audio/door.wav");
doorSound.SetBuffer(doorBuffer);
doorSound.Play();

I'm using Windows XP, the latest SVN and Visual Studio. I haven't had the chance to test this on another PC yet.

Thanks.

18
Graphics / Using GetRect and GetWidth to find string pixel width
« on: May 24, 2008, 07:08:29 pm »
Quote from: "Laurent"
You've found the solution, so... what's the purpose of this post ?


I wasn't sure if that was the correct way to achieve it until you confirmed it. I'll try them out.

Thanks.

19
Graphics / RenderWindow not showing OpenGL elements
« on: May 24, 2008, 05:39:12 pm »
I simplified some of my code and found some additional references to RenderWindow in my code which was causing the OpenGL elements to not show up.

So everything is working ok now except that I still get an unhandled exception error when I press Escape if I define my window as follows:

#include <SFML/Graphics.hpp>

sf::RenderWindow App;

int main()
{
   // Create main window
   App.Create(sf::VideoMode(640, 480, 32), "SFML");

// Process events
sf::Event Event;
while (App.GetEvent(Event))
{

// Close window : exit
if (Event.Type == sf::Event::Closed) Running = false;

// Escape key : exit
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code ==       sf::Key::Escape)) Running = false;


Closing the window doesn't generate any errors. The VS2005 debugger points at:

////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////
RenderWindow::~RenderWindow()
{
    // Nothing to do...
}

Can anybody suggest what I'm doing wrong here?

Many thanks.

20
Graphics / Using GetRect and GetWidth to find string pixel width
« on: May 24, 2008, 05:27:01 pm »
Hi,

Could somebody provide me with a simple example of how I can obtain the pixel width of a sf:string object please? I see that there is a string GetRect method which I'm guessing can be used (with the Rect GetWidth method) to achieve this.

I'd like to use these to centre some text and menus.

Many thanks.

21
Graphics / RenderWindow not showing OpenGL elements
« on: May 18, 2008, 12:03:44 pm »
Quote from: "Laurent"
Which SFML version ? Which OS ?

If you create the window in main() (using App.Create(...)), do the problems disappear ?


I'm using SFML 1.2, with Visual Studio 2005 and Windows XP.

I still seem to get the same issues with App.Create within main() and if I define sf::RenderWindow App; outside my main().

I'll try simlifying my code as it's spread across a number of source files just now.

Thanks.

22
Graphics / RenderWindow not showing OpenGL elements
« on: May 17, 2008, 06:17:01 pm »
I've also noticed that I get an unhandled exception if I press the Escape key in this case.

23
Graphics / RenderWindow not showing OpenGL elements
« on: May 17, 2008, 05:17:07 pm »
#include <SFML/Graphics.hpp>
#include "display.h"

sf::RenderWindow App(sf::VideoMode(800, 600), "SFML OpenGL");

void mainLoop()
{
   ...my code...

Defining my RenderWindow outside my functions as above is causing me a problem - only my 2D SFML drawing is working (fonts, images). My OpenGL stuff doesn't show up. I'm wanting to be able to refer to App from numerous different functions.

Am I doing something wrong?

Thanks.

24
Graphics / Make stuff big. Really big.
« on: May 12, 2008, 01:50:40 pm »
Quote from: "deps"
Works just great. :)

Got a new little problem...

I have a lot of tiles in one texture and only wants to draw one at a time instead of the whole image. After some digging around in the docs I came up with this. But the result is a bit wrong.

The left one is the one produced by SFML, the right one is what I was expecting.
As you can see, the left one only got half of the edge pixels drawn.

The relevant code used:
Code: [Select]

tiles_gfx = Image.new("tiles.png")
tiles_gfx.setSmooth( false )
tiles = Sprite.new( tiles_gfx )

# ... later in the source

tiles.setSubRect( IntRect.new(0,0,8,8) )
win.draw( tiles )


Assuming that you're trying to set a rectangle of 8 x 8 pixels should your rectangle be 0,0,7,7? I'm doing the same in one of my projects and this seems to work fine (for a 32x32 image):

Tile.SetSubRect(sf::IntRect(tileX, tileY , (tileX+32), (tileY+32)));

25
SFML projects / Demon's Eye
« on: March 05, 2008, 01:30:36 pm »
Quote from: "dbest"
Looking forward to this game...

I think i would also try something similar using SFML....


It's been on hold for a while. I'm moving house and that's taking all my time up just now.

26
Graphics / OpenGL and SFML 1.2
« on: January 19, 2008, 03:03:38 pm »
Quote from: "Laurent"
I've just fixed it. Thank you very much for your feedback.


Thanks for the quick solution. I managed to download and recompile the grpahics library and everything seems to work fine.

Thanks.

27
Graphics / OpenGL and SFML 1.2
« on: January 18, 2008, 11:32:35 pm »
There's an example here:

http://bp0.blogger.com/_nChu-_iqbBA/R5Em6ETV9kI/AAAAAAAAAFI/shHXXCfwsQY/s1600-h/Image1.png

Here is a slightly amended version of the OPenGL sample that produces the shot above:

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

int main()
{
    // Create main window
    sf::RenderWindow App(sf::VideoMode(800, 600), "SFML OpenGL");

    // Create a sprite for the background
    sf::Image BackgroundImage;
    if (!BackgroundImage.LoadFromFile("data/sky2.png"))
        return EXIT_FAILURE;
    sf::Sprite Background(BackgroundImage);

    // Load an OpenGL texture.
    // We could directly use a sf::Image as an OpenGL texture (with its Bind() member function),
    // but here we want more control on it (generate mipmaps, ...) so we create a new one
    GLuint Texture = 0;
    {
        sf::Image Image;
        if (!Image.LoadFromFile("data/crate.png"))
            return EXIT_FAILURE;
        glGenTextures(1, &Texture);
        glBindTexture(GL_TEXTURE_2D, Texture);
        gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, Image.GetWidth(), Image.GetHeight(), GL_RGBA, GL_UNSIGNED_BYTE, Image.GetPixelsPtr());
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    }

    // Enable Z-buffer read and write
    glEnable(GL_DEPTH_TEST);
    glDepthMask(GL_TRUE);
    glClearDepth(1.f);

// Set The Viewport To The Top Left 1/4
glViewport (16, 284, 400, 300); // was 300
glMatrixMode (GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity (); // Reset The Projection Matrix
gluPerspective(60.f, 1.f, 0.1f, 500.f); // was 45 degrees

    // Bind our texture
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, Texture);
    glColor4f(1.f, 1.f, 1.f, 1.f);

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

    // Start game loop
    bool Running = true;
    while (Running)
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                Running = false;

            // Escape key : exit
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                Running = false;
        }

        // Draw background
        App.Draw(Background);

// App.BeginOpenGL();

        // Clear depth buffer
        glClear(GL_DEPTH_BUFFER_BIT);

        // Apply some transformations
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glTranslatef(0.f, 0.f, -200.f);
        glRotatef(Clock.GetElapsedTime() * 50, 1.f, 0.f, 0.f);
        glRotatef(Clock.GetElapsedTime() * 30, 0.f, 1.f, 0.f);
        glRotatef(Clock.GetElapsedTime() * 90, 0.f, 0.f, 1.f);

        // Draw a cube
        glBegin(GL_QUADS);

            glTexCoord2f(0, 0); glVertex3f(-50.f, -50.f, -50.f);
            glTexCoord2f(0, 1); glVertex3f(-50.f,  50.f, -50.f);
            glTexCoord2f(1, 1); glVertex3f( 50.f,  50.f, -50.f);
            glTexCoord2f(1, 0); glVertex3f( 50.f, -50.f, -50.f);

            glTexCoord2f(0, 0); glVertex3f(-50.f, -50.f, 50.f);
            glTexCoord2f(0, 1); glVertex3f(-50.f,  50.f, 50.f);
            glTexCoord2f(1, 1); glVertex3f( 50.f,  50.f, 50.f);
            glTexCoord2f(1, 0); glVertex3f( 50.f, -50.f, 50.f);

            glTexCoord2f(0, 0); glVertex3f(-50.f, -50.f, -50.f);
            glTexCoord2f(0, 1); glVertex3f(-50.f,  50.f, -50.f);
            glTexCoord2f(1, 1); glVertex3f(-50.f,  50.f,  50.f);
            glTexCoord2f(1, 0); glVertex3f(-50.f, -50.f,  50.f);

            glTexCoord2f(0, 0); glVertex3f(50.f, -50.f, -50.f);
            glTexCoord2f(0, 1); glVertex3f(50.f,  50.f, -50.f);
            glTexCoord2f(1, 1); glVertex3f(50.f,  50.f,  50.f);
            glTexCoord2f(1, 0); glVertex3f(50.f, -50.f,  50.f);

            glTexCoord2f(0, 1); glVertex3f(-50.f, -50.f,  50.f);
            glTexCoord2f(0, 0); glVertex3f(-50.f, -50.f, -50.f);
            glTexCoord2f(1, 0); glVertex3f( 50.f, -50.f, -50.f);
            glTexCoord2f(1, 1); glVertex3f( 50.f, -50.f,  50.f);

            glTexCoord2f(0, 1); glVertex3f(-50.f, 50.f,  50.f);
            glTexCoord2f(0, 0); glVertex3f(-50.f, 50.f, -50.f);
            glTexCoord2f(1, 0); glVertex3f( 50.f, 50.f, -50.f);
            glTexCoord2f(1, 1); glVertex3f( 50.f, 50.f,  50.f);

        glEnd();

 // App.EndOpenGL();

        // Draw some text on top of our OpenGL object

        sf::String Text("This is a rotating cube");
        Text.SetSize(20.f);
Text.SetFont("data/Celtic Garamond.ttf");
Text.SetPosition(230.f, 300.f);
        Text.SetColor(sf::Color(255, 255, 255));
        App.Draw(Text);

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

    // Don't forget to destroy our texture
    glDeleteTextures(1, &Texture);

    return EXIT_SUCCESS;
}

28
Graphics / OpenGL and SFML 1.2
« on: January 18, 2008, 05:13:06 pm »
Yes. So if I set the pixel size of text to say 20 then this will be shrunk down to about 5 pixels on the game screen within the viewport (which is only 1/4 of the screen) instead of being drawn within the full game window at 20 pixels.

It's possible that my OpenGL code isn't correct as there are a lot of blanks in my knowledge but I suspect this isn't the case.

I can post a screenshot later if that would help or send you my example project / code.

Thanks.

29
Graphics / OpenGL and SFML 1.2
« on: January 18, 2008, 03:11:17 pm »
Hi,

I'm wanting to setup an OpenGL viewport within my game of say a quarter of the screen and use SFMLs graphics features to be able to draw on top of this area and within the rest of the game window

In SFML 1.1 this worked just the way I've described but I've noticed with 1.2 that any images or text I display are scaled down and drawn within the OpenGL viewport.

Is this by design?

Oh and the improvements to fonts look great!

Thanks

30
Window / Reading key presses into a String
« on: November 28, 2007, 02:03:36 pm »
I've been trying to read a single key to add it to a string editing routine but don't seem to be able to get this to work. Am I taking the wrong approach to this? Should events only be checked as part of the main loop? (where this seems to work fine).

Thanks.

--

std::string readAlphaKey()
{  
      sf::Event keyEvent;
      std::string keyString;
      bool done = false;

      while (!done)
      {
         while (App.GetEvent(keyEvent))
         {
               if ((keyEvent.Type == sf::Event::KeyPressed) && (keyEvent.Key.Code == sf::Key::Return)) { keyString="RETURN"; done = true; }
            if ((keyEvent.Type == sf::Event::KeyPressed) && (keyEvent.Key.Code == sf::Key::Back)) { keyString="BACKSPACE"; done = true; }
         }
         
         if ( keyEvent.Type == sf::Event::TextEntered )
         {
            if (( keyEvent.Text.Unicode < 0x80 ) && (!done)) // it's printable
            {
               keyString = (char)keyEvent.Text.Unicode;
               done = true;   
            }
         }         
      }
      return(keyString);  
}

Pages: 1 [2] 3
anything