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

Pages: 1 [2]
16
Graphics / How might I implement a "subtraction" blend mode?
« on: January 05, 2011, 09:23:54 am »
While looking through the SFML tutorials, I've noticed that it offers some blending modes. I was wondering if it is possible to create a blending mode that subtracts the values of the source from the destination? Is there a way to do this for a Sprite? I know an entire shader can be written but is there a way to do such a thing for just one Sprite object? I'm trying to create the effect of transparent material layers that darken. Something like how stacking colored plastic sunglasses lenses gives a darker result.  8)

17
Graphics / SFML line drawing method produces odd results...
« on: December 31, 2010, 09:45:42 pm »
I've noticed that drawing angular lines in SFML often produces lines of inconsistent width. Shown below, some of the lines have odd double pixel thick areas which occur during certain angles. These lines are drawn with a 1.0 thickness value.


18
General discussions / SFML's OOP handling of primitives.
« on: December 31, 2010, 10:45:33 am »
I know I've touched on this briefly before but I am curious about primitives being objects. I can see polygons as objects because most of the time the programmer needs to store points and data. Lines seem a bit odd however to make objects for a graphics library.

I've been pondering making a game with line style graphics (like we see in the 80's). It seems like kind of a waste to keep beating on the RAM frame after frame making multiple calls to create line objects just to have an image. I can understand sprites and polygons being good objects to model with static data but perhaps we could be given lower level access to simply drawing directly to the window without creating many many simple line objects? It seems a bit wasteful to have to store a line in memory just to render it to a window.

I'm just curious about the need for objectless drawing commands for more simple and dynamic shapes that must be constantly changed.

I'm very new to SFML so I don't have a lot of room to speak, I'd just like to know if there is any interest in directly rendering to a window without storing data in an object first.

Speaking of drawing directly to a window, is there a possibility of using fast raster warping and distortion effects without dabbling into OpenGL?

Thanks

19
General / Please evaluate my code for correctness + Visual C++ 2010
« on: December 18, 2010, 08:47:56 am »
I've been hard at work trying to learn different functions and such. For some odd reason my computer is running this demonstration at around 45 frames per second according to FRAPs. Now, I'm using Visual C++ 2010 in debug mode. I watched the installation video on Youtube to recompile the 2008 files.

I have several beginners questions.
1. How do I create a release version of a program with SFML? Currently I just use the -s-d extensions as shown in the video.

2. Any ideas why this runs at 45 frames per second when I have locked it to 60? (Windows XP Service pack 3, 2 GB RAM, AMD Athlon 64 processor.)

3. Please let me know any bad habits I have started here while trying to teach myself this library.

Code: [Select]


#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>



class Player
{
public:
//positions
int x;
int y;
// for grabbing parent window events
sf::RenderWindow * parent_window;

Player(int start_x, int start_y, sf::RenderWindow * window)
{
x = start_x;
y = start_y;
parent_window = window;
}

void update()
{
// move the player in the window
const sf::Input& input = parent_window->GetInput();


// use the sums of the key directions to figure out movement
x -= (input.IsKeyDown(sf::Key::Left)-input.IsKeyDown(sf::Key::Right)) * 8;
y -= (input.IsKeyDown(sf::Key::Up)-input.IsKeyDown(sf::Key::Down)) * 8;

sf::Shape my_shape = sf::Shape::Circle(x,y, 16, sf::Color(255,0,255));
parent_window->Draw(my_shape);

}

~Player(){};
};

int main()
{

sf::RenderWindow main_window(sf::VideoMode(800, 600, 32), "Demo");
main_window.SetFramerateLimit(60);
main_window.UseVerticalSync(true);

Player the_player(400,300,&main_window);

while(main_window.IsOpened())
{
main_window.Clear();
sf::Event main_window_event;

// Process events
        while (main_window.GetEvent(main_window_event))
        {
            // Close window : exit
            if (main_window_event.Type == sf::Event::Closed)
{
                main_window.Close();
}
        }

// update the player
the_player.update();

        // Display window contents on screen
        main_window.Display();
}

    return 0;
}


20
General / Is it possible to make a multi monitor game?
« on: December 16, 2010, 10:12:40 pm »
I was really happy to find that SFML allows for multiple rendering windows.

I've always enjoyed the game Battlezone which is a first person wireframe tank game designed in the 80's. I know that SFML is up to the challenge of rendering some wireframe models (With OpenGL if necessary). My dream for some time is to make a Battlezone game for 3 people. I know it could be done with some networking but I don't have much training in that area. Instead I was wondering if I could use a single machine and output to 3 different monitors at once, each holding the view of a different player. I would plan on using Windows XP as the operating system. I heard that SFML supports 4 joysticks now. This would be great for this project.

Would it be possible to construct a game that dynamically renders 3 different viewports to 3 monitors from a single machine?

21
Graphics / Drawing with shape and color objects.
« on: December 15, 2010, 09:35:23 am »
First let me say that SFML will be my first venture into multimedia with C++. I'm a college student and I have toyed with C++ off and on for some time. SMFL presents an exciting way to actually DO something with a programming language.  :D

Now I have looked through the tutorials a bit and have been adding and playing with the different functions. My biggest question is the use of the graphics objects and the color objects. Am I supposed to make a new graphics object and color object every time I want to draw something? Isn't this quite a lot of overhead? I guess I'm used to the state machine approach where the set color affects all following routines untill changed.

Here is my code, please tell me if I am abusing something here.

Code: [Select]


#include <SFML\System.hpp>
#include <SFML\Window.hpp>
#include <SFML\Graphics.hpp>


int main()
{
// Create the main rendering window
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
// use a set framerate
App.UseVerticalSync(true);
App.SetFramerateLimit(60);

// incrimenter
float inc = 0;

// 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();
}

// Clear the screen (fill it with blue color)
App.Clear(sf::Color(0,0,64));
inc += .25; // move the counter
if(inc >= 360)
{
inc -= 360;
}

// wavy warp effect
float step = 0;
for(float i = 0; i<360; i += 3)
{
step = i/32;
sf::Color my_color(0,255 - i/360 * 255, i/360 * 255);
sf::Shape my_line = sf::Shape::Line(cos(inc+step)*32+32, i, cos(inc+step)*32+480, i, 1, my_color, false, my_color);
App.Draw(my_line);
}
// Display window contents on screen

App.Display();
}

return EXIT_SUCCESS;
}

Pages: 1 [2]