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

Pages: 1 [2] 3 4
16
Feature requests / Request getVerticalSyncEnabled()
« on: March 15, 2012, 07:59:37 am »
Title says it all. ;-)

17
General discussions / Shadowed variables in Rect.inl
« on: March 14, 2012, 01:48:23 pm »
Rect.inl, line 40 and following produce warnings in GCC with -Wshadow enabled.

18
General discussions / sf::Texture crashes when used in a static object
« on: March 13, 2012, 10:01:17 pm »
A lot of SFGUI users experience crashes when the program is exitting. This is due to sf::Texture being destroyed after sf::Context is destroyed and happens because a lock is tried to acquired on a mutex that's static and has already been destroyed, too.

binary1248 did a quick example (and also found this one out). You HAVE TO compile it with MSVC, because the crash doesn't happen with GCC (surprise, surprise ;)).

Here's binary1248's original post, I just append it here: (source: http://sfgui.sfml-dev.de/forum/post316.html#p316)

binary1248 from here on

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

class Singleton {
public:
  static void instanciate() {
    instance.reset( new Singleton );
  }
private:
  static std::tr1::shared_ptr<Singleton> instance;

  sf::Texture texture;
};

std::tr1::shared_ptr<Singleton> Singleton::instance;

int main() {
  Singleton::instanciate();

  return 0;
}


Compiles and crashes on Windows 7 VS2008.

To quote a famous TV personality I find entertaining: Well THERE'S your problem.

Explanation:

In Visual C++ static variables are destroyed in a specific order, this being different from GCC obviously. When trying to destroy the sf::Texture, SFML tries to make sure that it has a valid context to destroy it with. This in turn tries to create a new context because the previous one was already destroyed. When creating a context it has to lock a mutex (a.k.a enter a critical section on windows) which is declared static inside createContext. This requires the critical section to be initialized before use and destroyed after done using. Because the Mutex is static the critical section it contains was destroyed immediately at the end of the application and stupid MSVC can't realize it is trying to access a static variable it already destroyed and doesn't want to initialize a new one. EnterCriticalSection then crashes because it is passed an invalid CRITICAL_SECTION object.

There you go. Another case of MSVC and SFML playing nice together.

I'm too lazy to report this somewhere so if anybody could mention this or link Laurent to this post I would be very very grateful.

19
Graphics / Rendering stars (example)
« on: January 13, 2012, 11:54:59 am »
Hey guys,

an user on IRC recently had some questions about rendering stars with parallex scrolling. I did a quick mashup out of fun and want to share it if anyone's looking for ideas on how to do it. ;) License is WTFPL. You can have multiple layers with different speeds and colors.



Code: [Select]
#include <SFML/Graphics.hpp>
#include <vector>
#include <ctime>
#include <cmath>
#include <iostream>
 
static const std::size_t NUM_TEXTURES = 4;
static const unsigned int TEXTURE_SIZE = 128;
static const std::size_t NUM_STARS_PER_TEXTURE = 20;
static const std::size_t NUM_LAYERS = 6;
static const float SPEED = 150.0f;
static const float SLOWDOWN_FACTOR = 0.5f;
static const float Y_SHIFT = 15.0f;
static const unsigned int COLOR_SHIFT = 40;
 
static const unsigned int SCREEN_WIDTH = 800;
static const unsigned int SCREEN_HEIGHT = 600;
 
struct Layer {
float speed;
sf::Vector2f offset;
std::size_t texture_id;
};
 
typedef std::vector<sf::Texture> TextureArray;
typedef std::vector<Layer> LayerArray;
 
int main() {
sf::RenderWindow window( sf::VideoMode( SCREEN_WIDTH, SCREEN_HEIGHT ), "Stars example" );
 
window.SetFramerateLimit( 60 );
 
// Init randomizer.
std::srand( static_cast<unsigned int>( std::time( 0 ) ) );
 
// Prepare textures.
TextureArray textures( NUM_TEXTURES );
 
for( std::size_t texture_id = 0; texture_id < NUM_TEXTURES; ++texture_id ) {
sf::Image image;
image.Create( TEXTURE_SIZE, TEXTURE_SIZE, sf::Color::Black );
 
// Set stars.
for( std::size_t star_id = 0; star_id < NUM_STARS_PER_TEXTURE; ++star_id ) {
sf::Vector2<unsigned int> star_pos(
std::rand() % TEXTURE_SIZE,
std::rand() % TEXTURE_SIZE
);
 
image.SetPixel( star_pos.x, star_pos.y, sf::Color::White );
image.CreateMaskFromColor( sf::Color::Black );
}
 
textures[texture_id].LoadFromImage( image );
}
 
// Prepare layers.
LayerArray layers( NUM_LAYERS );
 
for( std::size_t layer_id = 0; layer_id < NUM_LAYERS; ++layer_id ) {
layers[layer_id].offset = sf::Vector2f( 0, static_cast<float>( layer_id ) * Y_SHIFT );
layers[layer_id].speed = SPEED / static_cast<float>( layer_id + 1 ) * SLOWDOWN_FACTOR;
layers[layer_id].texture_id = layer_id % NUM_TEXTURES;
}
 
sf::Event event;
while( window.IsOpened() ) {
while( window.PollEvent( event ) ) {
if( event.Type == sf::Event::Closed ) {
window.Close();
}
}
 
float frame_time( static_cast<float>( window.GetFrameTime() ) / 1000.0f );
 
window.Clear();
 
// Update offsets and render.
for( int layer_id = NUM_LAYERS - 1; layer_id >= 0; --layer_id ) {
layers[layer_id].offset.x += layers[layer_id].speed * frame_time;
 
while( layers[layer_id].offset.x >= static_cast<float>( TEXTURE_SIZE ) ) {
layers[layer_id].offset.x -= static_cast<float>( TEXTURE_SIZE );
layers[layer_id].texture_id =
(
layers[layer_id].texture_id +
static_cast<std::size_t>( std::ceil( (static_cast<float>( SCREEN_HEIGHT ) + layers[layer_id].offset.y) / static_cast<float>( TEXTURE_SIZE ) ) ) +
1
) % NUM_TEXTURES
;
}
 
static std::size_t texture_id;
static sf::Vector2f target_pos;
static sf::Sprite sprite;
 
// Init initial texture ID and color.
texture_id = layers[layer_id].texture_id;
 
sprite.SetColor(
sf::Color(
static_cast<sf::Uint8>( 255 - layer_id * COLOR_SHIFT ),
static_cast<sf::Uint8>( 255 - layer_id * COLOR_SHIFT ),
static_cast<sf::Uint8>( 255 - layer_id * COLOR_SHIFT )
)
);
 
for( target_pos.x = -layers[layer_id].offset.x; target_pos.x < static_cast<float>( SCREEN_WIDTH + TEXTURE_SIZE ); target_pos.x += static_cast<float>( TEXTURE_SIZE ) ) {
for( target_pos.y = -layers[layer_id].offset.y; target_pos.y < static_cast<float>( SCREEN_HEIGHT + TEXTURE_SIZE ); target_pos.y += static_cast<float>( TEXTURE_SIZE ) ) {
sprite.SetTexture( textures[texture_id], true );
sprite.SetPosition( target_pos );
window.Draw( sprite );
 
texture_id = (texture_id + 1) % NUM_TEXTURES;
}
}
}
 
window.Display();
}
}

20
SFML projects / FlexWorld
« on: December 07, 2011, 07:19:34 pm »

About

FlexWorld is a flexible open-content 3D single- and multiplayer game with a highly modifiable world.

Originally inspired by Ultima Online and its free-shard community, FlexWorld tries to provide an environment where you can not only play, but also get creative and develop.

The game uses 3D graphics and a fixed grid for its maps, resulting in completely modifiable terrains and structures. Everything in the game is designed to be modular, including 3D models, textures, sound effects and game logics.

For the latter FlexWorld includes the Lua scripting language. Everything that happens in-game can be fully scripted.

Due to the nature of the project, one can't clearly tell what FlexWorld is about in detail, because what you do with it highly depends on the content you're about to use. The first official release will include an RPG-like game mode with 3 tribes, where your goal is to choose between one of them and gain might and power by fighting, trading or improving the tribe's status in other ways.

Current state

FlexWorld has been in development since March 2011 and got a partial rewrite in August/September 2011. The project is still in pre-alpha status which means it's very technical and not very playable yet.

However a lot of internal things are already done and stable, like rendering maps and objects, a graphical user interface, Lua scripts, resource import, multiplayer capatibilities and much more.

For news, media and more information, including how to fund the project or apply as a tester, visit its official website. We'd love to hear from you!

Website: http://flexworld-game.com/

Some details for the techies

SFML is used for OpenGL context creation, window and event management, image loading routines, sound and simple 2D graphics. The 3D graphics are done using a self-written scene-graph called FWSG. Logics are powered by Lua and calculated using a self-written component-based system library. The graphical user interface is rendered by libRocket (a quite dead project, so beware if you're planning to  use it!). Networking is powered by the Boost Asio library.

At the moment of writing this, the project (including libraries that have been developed for it) consists of 19,184 lines of C++ source code (without comments and blank lines, pure code) and follows the test-driven development workflow and is being developed in an agile manner (Pomodoro, Scrum). The team is staffed by 1 C++ developer, 1 web developer, 12 game testers and bug hunters, 1 artist and 1 musician.

21
SFML projects / SFGUI (0.4.0 released)
« on: October 17, 2011, 05:36:34 pm »
SFGUI is a GUI (Graphical User Interface) C++ library especially designed for programs and games that use SFML for rendering.


The library has been designed with flexibility and performance in mind. Several features get you started really quick and make using the library easy: The automatic layout takes care of positioning and sizing widgets properly. Even if you have to deal with different screen resolutions, SFGUI will always try to pick the best layout.

Included are a lot of widgets, like buttons, toggle buttons, check buttons, radio buttons, drop down boxes, entries, scrollbars and some more. At any time you can extend the library by custom widgets.

The widgets' visuals are completely separated from their implementations. SFGUI makes use of so called "widget rendering engines" to create the visuals. One engine is included in the release, called BREW, which uses simple shapes and solid colors to paint the widgets. The shapes, colors, fonts etc. can be modified by setting style properties, which can be done directly in C++ or by loading external theme files, which look similar to CSS.


Features
  • Basic widgets: Window, Button, Entry, Scrollbar, Scale, ScrolledWindow, Label, ToggleButton, CheckButton, ProgressBar, ComboBox.
  • Layouters: Bin, Box, Table, Fixed
  • Replaceable widget rendering engines that decide how widgets are rendered.
  • Properties with selectors similar to CSS (e.g. "Window#main > Button.fancy").
  • Consistent size and positioning procedures, no need to manually fiddle around with positioning and (re)sizing your forms.
  • Custom OpenGL renderer for great performance.

Download
Download from here.

Contact
Website: https://github.com/TankOs/SFGUI/wiki

22
Feature requests / sf::Image -> sf::Texture, sf::Image
« on: June 24, 2011, 01:50:51 pm »
Hey,

is it planned to separate sf::Image into image data and OpenGL texture? I'm currently having a big issue loading images in a separate thread randomly killing my application due to parallel access to the OpenGL context.

Splitting up loading images and creating textures wouldn't just avoid that problem, but also increase the separation between data and view. Or is there any way I missed to prevent sf::Image creating the texture directly after loading the image data from file?

23
Window / Sync problem with SetCursorPosition() and GetMouse*()
« on: May 25, 2011, 09:02:13 pm »
Hey,

when setting the mouse cursor position manually by calling sf::Window::SetCursorPosition(), the next call to GetMouseX/Y() returns exactly that position, even if the mouse has moved during that time (needed by mouse look/mouse grabbing, for example).

I haven't checked how it's implemented, yet, therefore I'm asking if the delay is too short so that sf::Window (or even the OS/window manager) isn't able to fetch the mouse move event in-time.

Here's a minimal example to reproduce the problem. It prints out the relative position from the window's center when the mouse has moved + one iteration after that.

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

int main() {
sf::RenderWindow window( sf::VideoMode( 800, 600, 16 ), "Minimal" );
sf::Event event;
const sf::Input& input( window.GetInput() );
unsigned char print_count( 0 );

window.EnableVerticalSync( true );

while( window.IsOpened() ) {
while( window.PollEvent( event ) ) {
if( event.Type == sf::Event::Closed ) {
window.Close();
}
}

// Get mouse movement delta values.
sf::Vector2i mouse_delta(
input.GetMouseX() - (800 / 2),
input.GetMouseY() - (600 / 2)
);

if( mouse_delta.x || mouse_delta.y ) {
print_count = 2;

// Reset mouse cursor to window center (fake grabbing).
window.SetCursorPosition( 800 / 2, 600 / 2 );
}

// Print 'em.
if( print_count ) {
std::cout << mouse_delta.x << ", " << mouse_delta.y << std::endl;
--print_count;
}

window.Clear();
window.Display();
}
}


The example shows that the mouse deltas are always (0, 0) after each mouse move which results in stuttering mouse looks. Any ideas?

24
Graphics / glCullFace makes SFML blind
« on: March 25, 2011, 08:40:48 am »
Hi guys,

it just happened to me that when enabling GL_CULL_FACE (with GL_BACK), SFML won't display its stuff anymore.

A workaround is to disable culling around the SFML rendering, however I'm just wondering if that should happen in SFML itself. Of course it means another call every cycle, I don't know how high the impact is.

Greetings.

25
SFML website / Forum URL
« on: March 12, 2011, 01:11:36 pm »
Hi Laurent,

could you please either
1) point the forum link on the mainpage to www.sfml-dev.org/forum/ or
2) set sfml-dev.org/forum/ as forum URL in the forum configuration?

This seems to be related to the "double login bug" I'm getting. Login happens at sfml-dev.org/forum/, redirection goes to www.sfml-dev.org/forum/, therefore the set cookie gets invalid.

Greetings.

26
General discussions / General Open Source babble
« on: November 12, 2010, 10:56:21 am »
Continued from http://www.sfml-dev.org/forum/viewtopic.php?t=978 .

Quote from: "Groogy"
Suited for the industry... Not to a 100%... Got real world examples.

Without going into detail here, my opinion is that Open Source is the *only* way software can work. Unfortunately the world's economy is not yet ready for such a radical change, so I'm fine with people saying I'm an idealist. ;)

Quote
Legal issues are a pain. Massive Entertainment got sued for using a Open-Source implementation of Python.

Because of what? Didn't they follow the license text? Seriously, in this case Open Source isn't the bad thing, it's the company violating the rules. That's why licenses like the GPL stand for real freedom (in contrast to zlib, for example), because they enforce all users using code to release it under similar conditions

Quote
Most companies lawyers start to cold-sweat if you mention Open-Source. Several game studios has been and will be screwed by the Open Source resulting in fee's much more expensive than just buying something properly licensed.

Same reason here: Companies not seem to understand that Open Source doesn't mean just "free as in free beer". You can't just take Open Source software, use it and ignore the conditions. And that's why lawyers get headaches, because often they need to mix licenses which can't work together.

Quote
Also several Open Source projects are not stable enough for the industry or even the public.

That's not quite true. Open Source often seems to be "work in progress" because IT IS work in progress -- always. There's usually no release cycle like "Okay, not here is Microsoft Visual Studio 2007", "Here is 2010" etc. The reason is simple: Open Source software is created on demand, without the goal to earn money. Therefore Open Source software usually supports the stuff the creator (or users) NEED. If you're unhappy with a product, the philosophy is "Do it yourself" -- and give your changes back to the origin. This turned out to work very well.

Quote
OOo is a classical example.

I agree, Open Office is badly designed IMHO. Still it's more and more used by authorities and other instances in many countries. It reduces costs and bugs.

Quote
Something else would be Open-Source IDE. Most things you find out there does not cut it for at least the Game Development Industry. Also the support for it is not as good as something you pay for.

Well, if there isn't an IDE suiting for a special type of developer, then either nobody really needed one in the past, or there always have been alternatives that work. Xorlium mentioned two, Code::Blocks and Kdevelop. There's also QtCreator and a bunch of others. Others use a console and vim and are very productive with those. If there's a demand, it's highly possible that there will be a solution. And when not, jump in and create it if you want.

Quote
Open-Source projects are mostly maintained by hobbyists, nonprofessionals, and people who have studied the field but never actually practiced it. *aerhm* my previous teacher *aerhm*. I'm no exception to this rule. I like Open Source, I support the concept. But as the community is now, it can't compete with the non-open-source world.

That is just not true, in all points. At first, Open Source projects are mostly maintained by enthusiasts, and those kinds of people are everything but pure hobbyists or non-professionals, they do their work by heart, not because of money interests. Also, especially in the field of programming, you are already practicing your passion whilst studying it. Without getting arrogant and with a good conscience I claim that I'm better than much guys working in the industry, for pure money -- and I'm very sure that a lot of other people who love their "hobby" are much better than industry guys.

Quote
To quote Niklas Hansson (former Lead Developer at Massive Entertainment): Open Source has it's rare diamonds, but most of it is garbage.

I call that disrespectful. Do you have more of that crazy guy than that quote? I'd like to understand why he says something like that.

Quote
Have you used an IDE like Code::Blocks or kdevelop? In my opinion, Code::Blocks is just as good as Visual Studio (with the added benefit that it runs on Linux, Mac, whatever), and kdevelop is massively better (although harder to use, once you get used to it, it's waay better).

I think that's often a matter of taste. Personally I write all my stuff with (g)vim. Years ago I used MSVC6 and was happy with it, but nowadays I completely dislike the idea of allrounder IDEs. Everyone has to choose his preferred tool.

Quote
I do give that closed-source software is generally easier to use for the average user though, but to say "has its rare diamonds, but most of it is garbage" is a very misleading (if probably true) statement. Because there are sooooo many open source projects, and maybe 10% of them aren't garbage, which means there are many, many good open source projects. Sure, they aren't always so easy to find.

Closed Source software often just *seems* to be easier to use. Good example (again): vim and Visual C. 95% of all developers claim that vim is non-intuitive and hard to use -- indeed that's not true, it's different and you need to learn the way how it works. Another example is Blender: once you get used to the interface, you recognize how cool it was designed.
I think the main reason why closed source software seems to be easier to use is that companies are following semi-established human interface guidelines. They don't care about what works best for them, but for the majority of possible customers who are already used to processes that have been established in the past (like the Start menu of Windows, or even the Windows key on your keyboard).
Another point is habituation: When you've worked with Windows for 10 years for example, it will be incredibly hard to switch to another operating system like Linux in the beginning. Because of that many call it "geekish" and my question is always the same: What do you think would you say when you've learned to use Linux for 10 years and would then switch to Windows? Think about it. ;)

Quote
Apparently you haven't worked that much with Visual Studio. There's nothing on the market that beats it's debugger interface.

Again a matter of taste. A lot of people don't even use the debugger, only in rare cases. Speaking of me, I only use it when my console throws a "Segmentation fault" at me. Then I fire up gdb or ddd and check it. Nothing I miss there, but it depends on personal expectations, I guess.

Quote
Just like they did with their Office package.

You mean you think that MS Office is a successful thing? I think it is not. It has forced many people to get used to bad habbits for years. No separation between data and visual representation (of course it's possible, but do you know people who really take care of it?) and closed data formats (which isn't only bad for Open Source, but also e.g. for countries that don't have the money to power their computers with expensive software like MS Office) to just name two.

Whoops! That's a lot of text, hehe. I'm sorry, but I find such discussions very interesting. ;)

27
Graphics / glScissor() before/after/between Draw() calls
« on: November 06, 2010, 06:03:24 pm »
Hey guys,

I'm currently stuck on implementing some simple clipping I need for SFGUI. When a widget gets rendered, it's done so by running a rendering chain which consists of one or more sf::Drawables.

My natural feeling was that it should be possible to use glScissor() to enable a clipping before the first drawable gets rendered and disable it when I'm done.

However this just doesn't seem to work which I think has to do with coordinates. Since Draw() does a lot of magic and doesn't care of my manipulations with OpenGL directly, I'm asking myself if there's a solution.

To summarize: I want to clip certain Draw() calls:
- glEnable( GL_SCISSOR_TEST )
- Call Draw() for some drawables.
- glDisable( GL_SCISSOR_TEST)

28
SFML website / Login bug?
« on: October 30, 2010, 11:20:12 am »
Okay I've had this bug for several weeks now and I ask myself if it only happens to me: Sometimes I need to login twice to be actually logged in. It's not quite a problem, but after logging in the first time, phpBB still recognizes that somehow and resets the "last time logged in" timestamp, so I won't see new post markings in the index.

I'm using Chromium. (on two computers, also happens with Firefox)

29
Graphics / sf::Shape::Line displacement
« on: October 15, 2010, 05:09:28 pm »
Hi guys, hey Laurent,

just discovered that sf::Shape::Line() procudes a line with wrong coordinates. I constructed an sf::Shape like this:

Code: [Select]
sf::Shape  line( sf::Shape::Line( 0.f, 0.f, 0.f, 100.f, 1.f, sf::Color( 255, 255, 0 ) );

Didn't see anything. ;) Then I moved it by one unit to the right and it appeared.

I remember I had that problem once with sf::Shape::Rectangle(), too. But when I wanted to reproduce it when I found the problem described above, everything seemed to work just fine.

30
General discussions / SFML2 library filename
« on: October 04, 2010, 03:16:45 pm »
Hi guys, hi Laurent,

like already discussed a little in another thread, I'm personally very confused by the new library filename for SFML2 since you switched over to CMake.

On Linux, every library has a .so name, which basically looks like "lib<name>.so.<version>". The active library is then symlinked to "lib<name>.so". On that platform, another library name is therefore not needed and would lead to inconsistencies.

Libraries that are separately released (e.g. Apache 1.6 and Apache 2.0 in the past) are often also released separately in most Linux' distributions. I think this is an unnecessary confusion. For example, when you do a search with Debian à la "apt-cache search libsfml", there'll popup several versions. Not a bad thing at a first glance, but as a result mechanism that work with .so names won't work anymore -- but besides that potential interested people will just not know why there're two versions and which to prefer (why is there still a 1.6? More stable? 2.0 discontinued?)

Speaking of Windows, I can understand your choice a bit better since there's no version naming for libraries (it's just "sfml-system.dll"). However, this has also been the case for all SFML version up to 1.6. The biggest problem here is of course distribution: When one library version isn't compatible with a previous one, the application/game has to include the library with the release.

However, at the time when packing a release, nobody knows when a library will get outdated by a newer, incompatible version. ;) Therefore this problem will *always* exist (as long the MS guys don't choose to add versioning, too).

As a logical consequence, you had to name all your releases like "sfml-system-1.6.dll" to avoid version clashes. I know, this is not the common case on Windows, but isn't it an option? I.e. .so naming on Linux (Mac OSX does it the same way, right?) and pseudo naming on Windows. ;)

Pages: 1 [2] 3 4
anything