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

Pages: [1]
1
Graphics / White box on startup
« on: February 09, 2013, 03:39:14 am »
hello, probably something stupid I'm missing with this but I'm sure one of you smart people can help me out. Every time I start-up my game I get a small white box in the upper corner. It is only there for a split second, and one the game goes through a draw cycle it's gone, but it is still off-putting regardless. Basically I have my RenderWindow set to a certain video resolution, then I stretch it in 3X to get a pixel-y look. The white box is the actual video-resolution. Below I have some quick code so you can see what I mean.


#include <SFML/Graphics.hpp>
using namespace std;

int main()
{
    sf::RenderWindow window;
    window.create(sf::VideoMode(320, 240, 32), "test");
    //window.clear(sf::Color::Blue);//Thought I would try and through a clear in a number of points in the code
                                                      //Obviously, it didn't work
    window.setSize(sf::Vector2u(960,720));
    window.setPosition(sf::Vector2i(200,100));
    window.setFramerateLimit(60);
     while (window.isOpen())
     {
         sf::Event event;
         while (window.pollEvent(event))
         {
             if (event.type == sf::Event::Closed)window.close();
         }
     }
    return 0;
}
 

Thx for any quick fixes you may have
-Sam

2
Graphics / Sprite Efficiency
« on: February 04, 2013, 06:44:53 am »
Hola, I was just wondering what, if any, implications creating sprites on the fly has. I would think creating a texture and sprite in the header and then just calling the sprite would be more efficient, but is it ok if I just make the texture in the header and then create sprites and set their parameters on the fly, letting the scope clean them up after every draw? Will this hit the performance enough where I should be worried about it? I prefer making them on the fly for header cleanliness but meh. Any thoughts you may have would be great.

-Sam

3
Graphics / Changing Line Color?
« on: February 02, 2013, 10:54:33 pm »
So after some searching I found out how to draw a line...

sf::Vertex line[2] = {sf::Vector2f(x1,y1), sf::Vector2f(x2,y2)};
screen.draw(line , 2, sf::Lines);

OK easy enough, however this draws a white line. What if I want a line of a certain color or with a certain amount of transparency? I noticed RenderTexture.draw takes a another parameter, renderstate, from the documentation. Can someone explain how I might go about this. I've looked at the documentation for renderstate but still don't understand how I would go about using it in this case, if you use it at all.

Thanks for any help you can give
-Sam

4
Graphics / A quick question about shaders...
« on: January 27, 2013, 06:48:45 am »
Hola, was just a little confused about shaders and was hoping that maybe I could get some things cleared up. So right now I have a simple 2d game where I draw everything to a RenderTexture, display it and then display the RenderWindow with a shader parameter. (Example sorta below)

Not for compiling just for visualization

window.create(sf::VideoMode(320, 240, 32), "Example");   //RenderWindow
screen.create(window.getSize().x,window.getSize().y);      //RenderTexture
effects.setParameter("color", .1f,.9f,.5f);                             //change the effect of the shader?
shaderstate.shader = &effects;                                           //Applying shader to a RenderState

//Loop//
    window.clear(gray);
    screen.clear(gray);
    //draw some stuff to screen rendertexture
    screen.display();
    window.draw(sf::Sprite(screen.getTexture()),shaderstate);
    window.display();
//End Loop//

 

So everything runs fine but it seem the game isn't changed at all. In the many examples I have seen people load a .frag shader and set parameters to that. I'm wondering if there is a simple way to create a "clean slate" shader and just use the params you set to change the window? perhaps I'm missing the point of shaders or something but all I want to do is be able to apply things like a tint, some exposure, etc. Any help you can give is much appreciated.
-Sam

5
Graphics / Controlling Game Speed on Different Computers
« on: January 11, 2013, 06:06:47 am »
Hello there. I know this is a topic that is talked about a lot but I couldn't find too much about it in relation to SFML 2.0. So basically I just want to control the speed of my game so that it runs the same(and smoothly) on all machines. Right now my object moves at slightly different speeds depending on how fast my comp is running. I know about FrameLimiter but this only limits the amount of frames that are drawn it doesn't control game speed.

so I need...

Gameloop()
{
Input();
Update();
//do some check here
Draw();

//The Thinking functions need to be executed a certain number of times per second on every computer
//as long as these thinking function are caught up draw away!(within 60 fps)

}
 

I want to make it clear that I don't want a "velocity" fix. I really don't like this change in velocity depending on time solution. I would much rather have a fixed "time step"(as I've seen cleverly named in other posts) to my entire program.

So are there any functions or posts you could point me to to get this figured out? I don't need the logic so much as the code and syntax. I can figure it all out from there. :)

Thanks for any help you can give!
(Hopefully other people need this too, or don't know they need it till now ;) )



edit: I found this article http://www.koonsolo.com/news/dewitters-gameloop/ which gave me all the info I need gl!

6
Graphics / "Internal OpenGL call" help
« on: January 10, 2013, 07:16:35 am »
Hi everyone, first I must say what a great community! anyways so I recently started with sfml and am self taught in c++ so don't get too technical on me if possible :)

So in my program I have a game class, player class, and graphics class(among others). The program runs fine but I get this error in the console >

An internal OpenGL call failed in Texture.cpp (95) : GL_INVALID_OPERATION, the s
pecified operation is not allowed in the current state
An internal OpenGL call failed in Texture.cpp (95) : GL_INVALID_OPERATION, the s
pecified operation is not allowed in the current state

Process returned 0 (0x0)   execution time : 1.947 s
Press any key to continue.

The strange thing is the program seems to run fine. the code just loads up a texture, turns it in to a sprite then draws it to the screen.

Game class...(part of it)
void Game::GameLoop()
{
    Graphics graphics;
    Player player1;

    while (isRunning)
    {

        player1.Update();

        graphics.ClearWindow();
        graphics.Draw(player1.xposition,player1.yposition,player1.direction);
        graphics.DrawWindow();

        //Close out of the window
        isRunning = graphics.QueryWindow();

    }

    graphics.~Graphics();
}
 
Graphics.h
#ifndef GRAPHICS_H
#define GRAPHICS_H


#include <SFML/Graphics.hpp>

class Graphics
{
    public:
        Graphics();
        ~Graphics();
        void Load();
        void Draw(int xposition,int yposition,char direction);
        void DrawWindow();
        void ClearWindow();
        bool QueryWindow();
        sf::RenderWindow window;
        sf::Texture chartexture;
        sf::Sprite charsprite;
    protected:
    private:
};

#endif // GRAPHICS_H
 
Graphics.cpp
#include "Graphics.h"

Graphics::Graphics()
{
    window.create(sf::VideoMode(800, 600, 32), "SFML works!");
    Load();
}
void Graphics::Load()
{
    chartexture.loadFromFile("data/graphics/characters/old man.bmp");
    charsprite.setTexture(chartexture);
}
void Graphics::Draw(int xposition,int yposition,char direction)
{
    window.draw(charsprite);
}
void Graphics::DrawWindow()
{
    window.display();
}
void Graphics::ClearWindow()
{
    window.clear(sf::Color::Red);
}
bool Graphics::QueryWindow()
{
    sf::Event windowstate;
    while (window.pollEvent(windowstate))
    {
        if(windowstate.type == sf::Event::Closed)return false;
    }
    return true;
}
Graphics::~Graphics()
{
        chartexture.~Texture();
        window.close();

}
 

Any help on how to do away with this would be great. It does't hamper the program but I can see it being problematic down the line...

Pages: [1]
anything