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

Pages: [1] 2 3 4
1
Window / window.display() Creates Memory Leak with VBOs
« on: October 21, 2012, 05:35:06 am »
I am having some issues with the memory with a very simple OpenGL application that I wrote to learn VBOs. The memory it uses readily increases the longer it is open.  Below is code the duplicates what I am seeing using Windows Task Manager:

   
#include <windows.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <SFML/Graphics.hpp>
#include <glew.h>
#include <gl/gl.h>
#include <gl/glu.h>

using namespace std;

class Scene {
public:
    void resize( int w, int h ) {
        // OpenGL Reshape
        glViewport( 0, 0, w, h );
        glMatrixMode( GL_PROJECTION );
        glLoadIdentity();
        gluPerspective( 120.0, (GLdouble)w/(GLdouble)h, 0.5, 500.0 );
        glMatrixMode( GL_MODELVIEW );
    }
};
int main() {

    sf::RenderWindow window(sf::VideoMode(800, 600, 32), "Test");

    ///Setup the scene, materials, lighting
    Scene scene;
    scene.resize(800,600);

    glEnable(GL_DEPTH_TEST);
    glEnable(GL_LIGHTING);
    glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION);
    glEnable(GL_COLOR_MATERIAL);
    glShadeModel(GL_FLAT);
    glEnable(GL_LIGHT0);
    float XL = .5, YL = .1, ZL = 1;
    GLfloat ambientLight[] = { 0.2f, 0.2f, 0.2f, 1.0f };
    GLfloat diffuseLight[] = { 0.8f, 0.8f, 0.8, 1.0f };
    GLfloat specularLight[] = { 0.5f, 0.5f, 0.5f, 1.0f };
    GLfloat lightpos[] = {XL, YL, ZL, 0.};
    glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
    glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight);
    glLightfv(GL_LIGHT0, GL_POSITION, lightpos);

    glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)wglGetProcAddress("glGenBuffersARB");
    glBindBufferARB = (PFNGLBINDBUFFERARBPROC)wglGetProcAddress("glBindBufferARB");
    glBufferDataARB = (PFNGLBUFFERDATAARBPROC)wglGetProcAddress("glBufferDataARB");
    glBufferSubDataARB = (PFNGLBUFFERSUBDATAARBPROC)wglGetProcAddress("glBufferSubDataARB");
    glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)wglGetProcAddress("glDeleteBuffersARB");
    glGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC)wglGetProcAddress("glGetBufferParameterivARB");
    glMapBufferARB = (PFNGLMAPBUFFERARBPROC)wglGetProcAddress("glMapBufferARB");
    glUnmapBufferARB = (PFNGLUNMAPBUFFERARBPROC)wglGetProcAddress("glUnmapBufferARB");

    ///Each vertex is in order for what is needed
    GLfloat vertices[] = { .5, .5, .5,  -.5, .5, .5,  -.5,-.5, .5,  .5, -.5, .5};

    GLuint VBOID;
    glGenBuffersARB(1, &VBOID);
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBOID);
    glBufferDataARB(GL_ARRAY_BUFFER_ARB, 48, vertices, GL_STATIC_DRAW_ARB);

    ///Start loop
    cout << "Starting" << endl;
    while( window.isOpen() ) {
        sf::Event event;
        while( window.pollEvent( event ) ) {
            if( event.type == sf::Event::Closed )
                window.close();
        }

        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluPerspective(50.0, 1.0, 1.0, 50);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        gluLookAt(5, 5, 5, 0, 0, 0, 0, 1, 0);

        glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBOID);
        glEnableClientState(GL_VERTEX_ARRAY);

        glVertexPointer(3, GL_FLOAT, 0, 0);
        glDrawArrays(GL_QUADS, 0, 4);

        glDisableClientState(GL_VERTEX_ARRAY);

        ///Reset env settings for SFML
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

        window.display();
    }

    return 1;
}

 

Commenting out all event polling changes nothing. The window clearing doesnt seem to make a difference if I use window.clear() or opengl's clear function.

With further commenting out I was able to figure out that the one line of code, window.display(), is causing my memory leak. Its not much with the little bit of data I have, increases about 2,000 KB per second for me using Windows Task Manager to track the applications memory consumption.

2
Graphics / Re: Sprites with Different Textures
« on: September 16, 2012, 01:11:29 am »
Thank you, specifying rects fixed my problem :)

Edit: I don't know what you are trying to do with it, but why not use both textures? That way you could use both of them as many times as you like without constantly charging an image and setting a new rect.

For what I am doing, I am not sure it would work, but Ill give it a go :)

3
Graphics / Sprites with Different Textures
« on: September 16, 2012, 12:26:59 am »
Hello. I have a need to change the texture of a sprite from one to another. Now that is easy to do with a simple .setTexture(texture). However, it seems that if the textures differ in size, there is a problem.

For example, if I initialize a sprite with a small texture and then change it to a large texture, only a portion of the large texture is assigned to the sprite, a portion exactly the same size as the smaller texture.
Small:

Large:


If I initialize the texture with a large texture and change it to a small texture, the small texture will display with horizonal and vertical lines;
Large:

Small:


Additionally, it seems that the sprite's dimensions can not be changed from what they are initialized to with the first texture. Is there a way to change the textures correctly and be able to force a resize of the sprite to the correct dimensions?

Info: large_texture is a 65 x 65 .jpg, small_texture is a 32 x 32 .jpg

Source code that replicates my problem, using SFML 2.0:
#include <windows.h>
#include <SFML/Graphics.hpp>

using namespace std;

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

     sf::Texture large_texture;
     large_texture.loadFromFile("res\\Items\\stone.png");
     sf::Texture small_texture;
     small_texture.loadFromFile("res\\Items\\stonedust.png");

     sf::Sprite sprite1;
     sprite1.setTexture(small_texture);//change to either small or large
                                       //for initializing
     bool UsingLargeTexture(false);

     while (App.isOpen())
     {
         if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space))
         {
             bool decision(false);
             if(UsingLargeTexture == true && decision == false)
             {
                 sprite1.setTexture(small_texture);
                 UsingLargeTexture = false;
                 decision = true;
             }
             if(UsingLargeTexture == false && decision == false)
             {
                 sprite1.setTexture(large_texture);
                 UsingLargeTexture = true;
                 decision = true;
             }
             Sleep(500);
         }

         App.clear();

         App.draw(sprite1);

         App.display();
     }

     return EXIT_SUCCESS;
 }
 

4
Window / Re: [SOLVED] RenderWindow::PreserveOpenGLStates
« on: July 17, 2012, 11:07:46 pm »
Thank you both for helping me out. By setting the glTexEnvf settings back to their default state, the graphical errors cleared up :)

5
Window / Re: RenderWindow::PreserveOpenGLStates
« on: July 17, 2012, 02:45:59 am »
1. Don't use GLUT and SFML at the same time, SFML is a superset of GLUT and should be used by itself.
Ah, okay. Didnt know SFML was a superset of GLUT.

2. glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL) is messing SFML texturing up. pushGLStates and popGLStates pushes the texture environment but resetGLStates doesn't reset it AFAIR. Right now you would have to take care of resetting it back to the default yourself whenever you use SFML to draw some textured stuff.
3. Not sure but the same might apply for glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION) as well.
Well how would you reset it completely then if resetGLStates (popGLStates) doesnt do the job?

Quote
Maybe a list of stuff that resetGLStates resets in the docs would save them the trip through source
Good idea :)
I second that  ;)

6
Window / Re: RenderWindow::PreserveOpenGLStates
« on: July 16, 2012, 01:01:03 am »
I tried what you suggested, but still have not had any success. Here is some minimal code that reproduces what I am seeing:

#include <windows.h>
#include <SFML/Graphics.hpp>
#include <math.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>

#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>

class Scene {
public:
        Scene() {
                // Init OpenGL states
                glEnableClientState( GL_VERTEX_ARRAY );
                glEnableClientState( GL_TEXTURE_COORD_ARRAY );
                glEnable( GL_TEXTURE_2D );
        }
        ~Scene() {
                // Reset OpenGL states
                glDisableClientState( GL_VERTEX_ARRAY );
                glDisableClientState( GL_TEXTURE_COORD_ARRAY );
                glDisable( GL_TEXTURE_2D );
        }
        void resize( int w, int h ) {
                // OpenGL Reshape
                glViewport( 0, 0, w, h );
                glMatrixMode( GL_PROJECTION );
                glLoadIdentity();
                gluPerspective( 120.0, (GLdouble)w/(GLdouble)h, 0.5, 500.0 );
                glMatrixMode( GL_MODELVIEW );
        }
};


float angle = 0.0f;
float lx = 0.0f, lz = -1.0f;
float x = 0.0f, z = 15.0f;
float deltaAngle = 0.0f;
float deltaMove = 0;

using namespace std;

int main(int argc, char **argv) {

    sf::RenderWindow window(sf::VideoMode(800, 600, 32), "SFML/OpenGL Tester");

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);

    Scene scene;
    scene.resize(800,600);

    sf::Image img1;
    img1.loadFromFile("texture.bmp");
    GLuint texture1;
    glGenTextures(1, &texture1);
    glBindTexture(GL_TEXTURE_2D, texture1);
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
    glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, img1.getSize().x, img1.getSize().y, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const GLvoid*)img1.getPixelsPtr() );

    sf::Text text1("Some test text colored red");
    text1.setPosition(230,550);
    sf::Color Red(255,0,0);
    text1.setColor(Red);

    sf::Texture tex1;
    tex1.loadFromFile("hud.png");
    sf::Sprite sprite1;
    sprite1.setTexture(tex1);
    sprite1.setPosition(50,50);

    glEnable(GL_DEPTH_TEST);
    glEnable(GL_LIGHTING);
    glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION);
    glEnable(GL_COLOR_MATERIAL);
    glShadeModel(GL_SMOOTH);

    float Y = 1.0f;

    while( window.isOpen() ) {
        sf::Event event;
        while( window.pollEvent( event ) ) {
            if( event.type == sf::Event::Closed )
                window.close();
        }

        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluPerspective(50.0, 1.0, 1.0, 70.0);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        gluLookAt(      x, Y, z,//eye's position
                    x + lx, Y,  z + lz, //where the eye is looking (point)
                    0.0f, 1.0f,  0.0f);//translations

        glColor3f(0.5, 0.2, 0.2);

        glBegin(GL_QUADS);
            glEnable(GL_TEXTURE_2D);
            glBindTexture( GL_TEXTURE_2D, texture1 );

            glTexCoord2d(0.0,0.0);
            glVertex3f(0,0,0);
            glTexCoord2d(1.0,0.0);
            glVertex3f(0,1,0);
            glTexCoord2d(1.0,1.0);
            glVertex3f(1,1,0);
            glTexCoord2d(0.0,1.0);
            glVertex3f(1,0,0);

            glDisable(GL_TEXTURE_2D);
        glEnd();

                window.pushGLStates();
                window.draw(text1);
                window.draw(sprite1);
                window.popGLStates();

        window.display();
    }
    return 1;
}
 

This minimal code produces this:


Sprite 1, the non-green picture, where-ever you see white is actually supposed to be transparent. Text 1 also seems to have some problems aswell, as though where the transparent parts should be are colored what the text color is set to. The green square is a textured quad.

7
Window / [SOLVED] RenderWindow::PreserveOpenGLStates
« on: July 15, 2012, 07:51:12 pm »
I am still getting used to SFML 2.0 and was wondering how the 2.0 version of RenderWindow::PreserveOpenGLStates can be invoked to make sure that OpenGL content can work with SFML content so that this doesnt happen:



That white stuff is an sf::Text, and the green is a textured quad.  Im hoping that by preserving the OpenGLStates I can make the text appear as normal, but I can't find the appropriate reference in the 2.0 docs.

8
General / Re: Mixing SFML with OpenGL
« on: June 21, 2012, 10:53:31 pm »
After a few days of fooling around with it I got it to work. Turns out that I was actually just calculating the camera transformations incorrectly and forgot to initialize OpenGL lol...

Code for those who want it (SFML 2 with OpenGL 3.3):
#include <windows.h>
#include <SFML/Graphics.hpp>
#include <math.h>
#include <iostream>
#include <fstream>
#include <sstream>

#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>

// angle of rotation for the camera direction
float angle = 0.0f;
// actual vector representing the camera's direction
float lx=0.0f,lz=-1.0f;
// XZ position of the camera
float x=0.0f, z=5.0f;
// the key states. These variables will be zero
//when no key is being presses
float deltaAngle = 0.0f;
float deltaMove = 0;

void resizeGL( int w, int h ) {
        glViewport( 0, 0, w, h );
        glMatrixMode( GL_PROJECTION );
        glLoadIdentity();
        gluPerspective( 120.0, (GLdouble)w/(GLdouble)h, 0.5, 500.0 );
        glMatrixMode( GL_MODELVIEW );
}

void computePos(float deltaMove) {

        x += deltaMove * lx * 0.1f;
        z += deltaMove * lz * 0.1f;
}

void computeDir(float deltaAngle) {

        angle += deltaAngle;
        lx = sin(angle);
        lz = -cos(angle);
}

int main(int argc, char **argv) {

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

        // init GLUT
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);

        glEnable(GL_DEPTH_TEST);

        sf::Text testtext("HELLO OPENGL");

        while( window.isOpen() ) {
            sf::Event event;
                while( window.pollEvent( event ) ) {
                        if( event.type==sf::Event::Closed )
                                window.close();
                }
                window.setActive();

                deltaAngle = 0.0f, deltaMove = 0.0f;
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) deltaAngle = -0.01f;
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) deltaAngle = 0.01f;
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) deltaMove = 1.0f;
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) deltaMove = -1.0f;

        computeDir(deltaAngle);
        computePos(deltaMove);

        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
                glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluPerspective(50.0, 1.0, 1.0, 70.0);
                glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        gluLookAt(      x, 1.0f, z,//eye's position
                    x+lx, 1.0f,  z+lz,//where the eye is looking (point)
                    0.0f, 1.0f,  0.0f);//translations

        glColor3f(0.9f, 0.9f, 0.9f);
        glBegin(GL_QUADS);
            glVertex3f(-10.0f, 0.0f, -10.0f);
            glVertex3f(-10.0f, 0.0f,  10.0f);
            glVertex3f( 10.0f, 0.0f,  10.0f);
            glVertex3f( 10.0f, 0.0f, -10.0f);
        glEnd();

        glColor3f(0.4f, 0.4f, 0.4f);
        glTranslatef(0,2,0);
        glutSolidTeapot(.5);

        window.pushGLStates();
        window.draw(testtext);
        window.popGLStates();

        window.display();

        }
        return 1;
}
 

9
General / Mixing SFML with OpenGL
« on: June 18, 2012, 12:30:33 am »
I have been playing around with OpenGL with SFML and have run into a couple problems.  Minimal example:

#include <windows.h>
#include <SFML/Graphics.hpp>
#include <math.h>
#include <iostream>
#include <fstream>
#include <sstream>

#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>

using namespace std;

int main() {

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

    ///Text to show coords
    sf::Text text("X Coord");
    sf::Text text2("Y Coord");
    sf::Text text3("Z Coord");

    text2.setPosition(0,30);
    text3.setPosition(0,60);

    ///OpenGL Commands
        glClearColor(0.2,0.7,0.9,0);
        glEnable(GL_DEPTH_TEST);

        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glViewport(0, 0, 800, 600);
        gluPerspective(120.0, (GLdouble)800/(GLdouble)600, 0.5, 500.0);
        glMatrixMode(GL_MODELVIEW);

    float x = -10, y = 10, z = -10;

    ///Main loop
    while (App.isOpen())
    {
        sf::Event Event;
        while (App.pollEvent(Event))
        {
            if (Event.type == sf::Event::Closed)
                App.close();
        }

        ///Clear the screen and create a reference sphere
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
                glLoadIdentity();
        glColor3d( 1.0,0.0,0.0 );
        glutSolidSphere(1,30,30);

        ///Change the view with the arrow and W/S keys
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))  x = x + .1;
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) x = x - .1;
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up))  y = y + .1;
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) y = y - .1;
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::W))  z = z + .1;
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::S)) z = z - .1;

        ///Camera
        glLoadIdentity();
        gluLookAt(x,y,z, 0,0,0, 0,1,0);

        ///Change text with current coords and display
        std::stringstream stream1;
        stream1 << x;
        text.setString(stream1.str());

        std::stringstream stream2;
        stream2 << y;
        text2.setString(stream2.str());

        std::stringstream stream3;
        stream3 << z;
        text3.setString(stream3.str());

        App.pushGLStates();
        App.draw(text);
        App.draw(text2);
        App.draw(text3);
        App.popGLStates();

        App.display();
    }
        return EXIT_SUCCESS;
}
 

The first is that when I comment out the lines:

App.pushGLStates();
App.draw(text);
App.draw(text2);
App.draw(text3);
App.popGLStates();
 

Then the sphere appears very close to the camera. When I keep them in the code, the sphere appears far away. I think this has something to do with keeping GL context through SFML, but I am not sure.

The second problem may not be meant for these forums, but I'll ask anyway just in case. The code provided above is supposed to create a sphere, which it does, and then should allow the user to move the camera's position around using the arrow and W/S keys. However, while the coords change, the view does not.

Any help at all would be much appreciated :)

10
Graphics / Cant use Vectors for RenderTextures?
« on: May 31, 2012, 06:27:34 am »
I am trying to make an array of rendertextures using vectors (with SFML 2.0), but I am getting some odd errors involving:

sf::NonCopyable& sf::NonCopyable::operator=(const sf::NonCopyable&)' is private
 
 

Is using a vector not possible for what I am trying to do? Below is a minimal example that reproduces the errors:

#include <SFML/Graphics.hpp>

 int main()
 {
     sf::RenderWindow App(sf::VideoMode(800, 600), "RenderTexture");

     ///Number of chunks along the x and y axis of the map
     int NumberOfChunks = 3;

     ///Vector for the rendertexture
     std::vector<sf::RenderTexture> bg; bg.resize(NumberOfChunks * NumberOfChunks);

     ///Create the size of the rendertexture
     for(int i = 0; i < NumberOfChunks * NumberOfChunks; i++) bg[i].create(3, 3);

     ///Some code here that assigns stuff drawn to the rendertextures

     ///Display the rendertextures
     for(int i = 0; i < NumberOfChunks * NumberOfChunks; i++) bg[i].display();

     ///Assign the rendertextures to sprites
     std::vector<sf::Sprite> WorldChunk; WorldChunk.resize(NumberOfChunks * NumberOfChunks);

     ///Some code here the positions the sprites

     while (App.isOpen())
     {
         sf::Event Event;
         while (App.pollEvent(Event))
         {
             if (Event.type == sf::Event::Closed)
                 App.close();
         }

         App.clear();

         ///Display the sprites
         for(int i = 0; i < NumberOfChunks * NumberOfChunks; i++) App.draw(WorldChunk[i]);

         App.display();
     }
     return EXIT_SUCCESS;
 }
 

11
Graphics / Understanding .getGlobalBounds().contains
« on: May 27, 2012, 02:45:05 am »
What is strange is that the following works:

if(Sprite1.getGlobalBounds().intersects(Sprite2.getGlobalBounds())) {//Do something}
 

But not something like:

if(Sprite1.getGlobalBounds().contains(Sprite2.getGlobalBounds())) {//Do something}
 

But get the error:
no matching function for call to 'sf::Rect<float>::contains(sf::FloatRect)'

Am I using the contain function incorrectly? And does the contain function just look for Sprite2 being within Sprite1 or does it also look for intersecting?  I ask because I want to have an if statement that turns true if a sprite is within or intersecting another sprite.

12
Graphics / Re: sf::RenderTexture positioning?
« on: May 24, 2012, 07:07:37 am »
Nevermind, I figured it out. Feel free to delete this topic since it appears I can not.

13
Graphics / sf::RenderTexture positioning?
« on: May 24, 2012, 05:31:12 am »
I am creating a simple tile generator using sf::RenderTexture and have run into an odd problem.  The below code (minimal example) should produce a nice small patch of grass, but nothing appears but a blank screen.  Am I using the rendertexture incorrectly or is this a bug?

#include <SFML/Graphics.hpp>
#include <iostream>
#include <sstream>
#include <fstream>
#include <math.h>

using namespace std;

 int main()
 {
     sf::RenderWindow App(sf::VideoMode(800, 600), "Upgrading to SFML 2.0 Testing Environment");

     sf::Texture grassimg;
     if(!grassimg.loadFromFile("img\\Terrain\\new_grass_tile.png")) {cout << "Error" << endl;};
     sf::Sprite Tile(grassimg);
     Tile.setPosition(0,0);

     float GridX = 3, GridY = 5, CountX = 0, CountY = 0, Iso = 0;
     float TileX = grassimg.getSize().x;
     float TileY = grassimg.getSize().y;
     sf::RenderTexture bg;
     bg.create(800, 800);

     for(int i = 1; i < GridX * GridY + 1; i++)
     {
         Tile.setPosition((TileX * CountX) + (TileX/2 * Iso), (TileY/2) * CountY);
         bg.draw(Tile);

         CountX++;
         if(CountX > GridX + 1 && Iso == 0) CountX = 0, CountY++, Iso = 1;
         if(CountX > GridX + 1 && Iso == 1) CountX = 0, CountY++, Iso = 0;
     }

     sf::Sprite grassobj;
     grassobj.setTexture(bg.getTexture());
     grassobj.setPosition(0,0);

     while (App.isOpen())
     {
         sf::Event Event;
         while (App.pollEvent(Event))
         {
             if (Event.type == sf::Event::Closed)
                 App.close();
         }

         App.clear();

         App.draw(grassobj);

         App.display();
     }
     return EXIT_SUCCESS;
 }
 

14
System / Re: Very low FPS
« on: May 23, 2012, 01:19:35 am »
you can use a profiler in order to know where your application spend most its CPU time.
Thanks, this helped me find the problem.

15
System / Very low FPS
« on: May 22, 2012, 07:36:47 pm »
So I have been upgrading my game from SFML 1.6 to SFML 2.0 and have noticed that my FPS has dropped from over a hundred (frame rate not limited) to a constant FPS of 10 in SFML 2.0. Ive been browsing the forum for solutions and tried them.

I am not using any polling events for the joystick.

I have the same result in Release as in Debug.

Is there something in SFML 2.0 that drastically changes FPS performance from SFML 1.6? Because all I have done really is change the code to fit the syntax of SFML 2.0.

Pages: [1] 2 3 4