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

Pages: [1]
1
General / Multiple Events Running At the Same Time?
« on: December 15, 2011, 11:49:25 pm »
Quote from: "Contadotempo"
What's wrong with using if? Unless you meant else if?


Suppose the user pressed two keys very fast, faster than one frame. If you use if to check new events, this way:

Code: [Select]
while (running)
{
  sf::Event event;
  if (window.GetEvent(event))
  {
    // Process event here
  }
  // Drawing here
  window.Display();
}


You will get only one event per frame. There will be a delay of one frame between the time when the user pressed the second key and the time when the program process it. If you use while:

Code: [Select]
while (running)
{
  sf::Event event;
  while (window.GetEvent(event))
  {
    // Process event here
  }
  // Drawing here
  window.Display();
}


All available events will be processed every frame. No event will remains to be processed by the next frame. This is the right way.

2
General / Multiple Events Running At the Same Time?
« on: December 15, 2011, 09:08:06 pm »
Use it as is explained on tutorials and everything should work fine. To events that happens at the same time will generate two events, but one will always be the first. As all available events are handled every frame, they will be processed at the same time, in the point-of-view of the end-user of your application.

Code: [Select]
sf::Event event;
while (window.GetEvent(event)) // It must be a while.
{
    // Process your event here, you can use ifs, or a switch to check event type.
}

3
SFML projects / SFGUI
« on: December 15, 2011, 02:22:21 pm »
Quote from: "Tank"
If anyone wants to donate some CPU resources to SFGUI for a different architecture/operating system...


I have a Linux 32-bits (GCC) and a Windows 32-bits (MinGW). Are these useful? How can I help?

4
General / Installing ruby-opengl on Windows and Ruby 1.9.
« on: December 01, 2011, 05:46:20 pm »
First: Follow this tutorial: https://groups.google.com/d/msg/rubyinstaller/vMR5mQVA_88/aZqLyjyQiSYJ (by Tomasz Błajek).

You will get an error with last step (building the gem). At this point you should have this directory tree:

Code: [Select]
(folder) doc
(folder) examples
(folder) ext
(folder) lib
(folder) test
 (file)  metadata
 (file)  Rakefile


Open "metadata" and add after line 13:

Code: [Select]
licenses: []

Then run:

Code: [Select]
gem build metadata

After you will have to download and install Glut to the devkit. Download it here: http://user.xmission.com/~nate/glut.html (the bin option).

Unpack and move 'glut.h' to "<devkit path>\mingw\include\GL", 'glut32.lib' to "<devkit path>\mingw\lib" and 'glut32.dll' to "C:\Windows\System32".

Now run:

Code: [Select]
gem install ruby-opengl-0.60.1.gem

You shouldn't get any errors.

(I'm now testing it with rbSFML.)

5
SFML projects / HQx Magnification Filter
« on: August 12, 2011, 01:16:02 am »
This is a extension to apply the HQ2x/HQ3x/HQ4x algorithm with SFML images. The interface is pretty simple, with this methods:

Code: [Select]
namespace sfe {
  using namespace sf;
 
  // Initializes the HQx algorithm. Takes about one second and 64MB of RAM.
  // This is called automatically by the methods below, if necessary.
  inline void InitHQx();
 
  // Receives a sf::Image and returns a 2-times bigger sf::Image, using the
  // HQ2x magnification algorithm.
  Image HQ2x(const Image& input);
 
  // Receives a sf::Image and returns a 3-times bigger sf::Image, using the
  // HQ3x magnification algorithm.
  Image HQ3x(const Image& input);
 
  // Receives a sf::Image and returns a 4-times bigger sf::Image, using the
  // HQ4x magnification algorithm.
  Image HQ4x(const Image& input);
 
}


Here's a code sample:

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

int main() {
  sf::Image img, hq2x, hq3x, hq4x;
  img.LoadFromFile("test.png");
 
  sfe::InitHQx(); // Unnecessary
 
  hq2x = sfe::HQ2x(img);
  hq2x.SaveToFile("hq2x.png");
 
  hq3x = sfe::HQ3x(img);
  hq3x.SaveToFile("hq3x.png");
 
  hq4x = sfe::HQ4x(img);
  hq4x.SaveToFile("hq4x.png");
 
  return 0;
}


Samples: (HQ3x)

   

           

This is my first open-source code. I got the HQx code from here, and I did some modifications in it to make it working with 32-bit colors. Also, don't try to use it with images that has some pixel with alpha channel other than 255.

Download link: Click Here

6
Graphics / Drawing TextBox.
« on: July 02, 2011, 07:02:49 pm »
Cool! It is exactly what I was wanting. Thank you!

7
Graphics / Drawing TextBox.
« on: July 02, 2011, 03:37:09 pm »
But how to draw just a part of the string (splitting glyphs)?

Sample:



Note that it don't shows the entire "r", just a half. I think it should be done with some kind of viewport.

8
Graphics / Drawing TextBox.
« on: July 02, 2011, 03:07:04 am »
I'm trying to draw a textbox with SFML (2.0). It, basicly a box drawed as background, a sf::Text with the contents and a sf::Sprite with the cursor. My problem is to limit the drawed text to the box, to don't show any text outside the textbox. I tryed to do it with sf::View but I failed. I'm also thinking on blit (pixel by pixel) each glyph in an sf::Image and draw it. It probably works, but is not a fast way. What is the best way to do it?

Also, a possible interesting function to be added is a Drawable::SetClipRect(IntRect), to draw just a part of the object. It can be useful for tiled images or for cases like mine.

Pages: [1]
anything