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

Pages: [1]
1
Graphics / Changes in RenderTextures/Texts?
« on: October 05, 2014, 09:54:05 pm »
I just recompiled SFML from the git master version to continue on a GUI library I was writing a few months ago. I had made several versions of an example program for checking if everything looks correctly.
When I recompiled them with the new SFML version some new problems appeared:
1. One version of the program draws sf::Text strings on a sf::RenderTexture and later assembles some screens from them by drawing them onto a sf::Window using only OpenGL, but the text appears smaller now and on one part are some garbage pixels in same color as the text included.
2. Next version draws directly on a sf::RenderWindow using only SFML graphics. And this looks flawlessly, exactly like before.
3. Third version is like the second, but draws on a single screen-sized sf::RenderTexture and then draws that onto a sf::RenderWindow at once, but this appears mirrored along the horizontal axis.

I just want to know, have there been changes to these SFML classes recently, which could cause this? IIRC the smaller text could be from some recent bugfix I read about? And the mirroring, was that a deliberate change, too?
The garbage pixels, I think, may be from a new size mismatch between the changed text size and the same sized RenderTexture.

PS: No code, cause I'll fix that myself if I get the info that its needed.

2
General / Line Endings
« on: November 27, 2013, 12:29:11 am »
I'm halfway into implementing something for SFML and I found the line endings are inconsistent when suddenly the diff would screw up after a small change (I have autocrlf=false in git so I have got whats in the repository already).
To give a few examples of files I checked using an editor that shows the line endings: Mouse, Texture, RenderTextureImplDefault are LF, but others like RenderTexture, RenderTextureImpl, RenderTextureImplFBO are CRLF.
How would be the best way to handle this, convert to LF or keep as is?

3
SFML website / 236 people a week downloading SFML 1.6
« on: November 21, 2013, 01:16:01 pm »
I stumbled upon the Sourceforge website and was surprised when seeing the shown amounts of the download statistics there. A large number of people seem to read that page as if 1.6 was the newest version and click the 1.6 download link there. :o
Maybe you could add a few words to the description there to tell that page is not updated and they should get a new version from the official website to reduce this?

4
SFML website / Forum not showing up with google link
« on: November 21, 2013, 12:34:29 pm »
For some reason google showed me this https://en.sfml-dev.org/forums/index.php?topic=9458.0 which is in https not http for https://www.google.de/#q=sfml+supported+minimum+opengl+version.
I know its googles wrong doing not yours (and I remember the other thread where you mentioned its difficult to fix), but readers may wonder why they get the site blocked by their browser, have to accept the "wrong" certificate and then get a garbled page (I guess the css does not get loaded).

5
General / Design issues with setActive
« on: November 12, 2013, 10:55:36 pm »
I am writing a GUI library that should draw some things on the current active context, but for doing this it has to sometimes create a texture first using a RenderTexture. The problem is the current context gets deactivated and I found no good way in SFML to reactivate the previous context.

I see a few possible solutions:
- Ideally I would be able to retrieve a reference to a sf::Context for the current active context inside the library from some static method and then later call setActive on it, but I see no way in SFML for doing this. (I think the static ensureGLContext method would just use some hidden context and that would not help me as it would be the wrong one.)
- Next best alternative would be giving the library function a parameter with a reference to an object of a SFML class with the setActive function. The problem there is the inheritance hierarchy in SFML does not allow for casting to a common base class with a virtual setActive function, because its missing in GlResource/RenderTarget and RenderTarget does not even derive from GlResource. That makes it not possible to transparently handle Context, Window, RenderWindow and RenderTexture, because they all freshly declare a new version of the identically named function.
- Another alternative would be if all of Window, RenderWindow and RenderTexture had a function to get a reference to their Context, but there is also no such methods.
- The awkward, last-I-can-think-of and only-one-I-can-implement-myself-without-changing-SFML alternative would be I create a function object class with a pure virtual operator(), then derive a template function-object class from it that gets a reference to one of those SFML objects in the constructor, saves it in a member variable of the templates parameter-type and overrides the operator() to call setActive on the member. Then I would have the library user need to create a function object from the derived template and give the library a casted-to-the-base-class reference or smart pointer to it and the library could then somehow get it into the resource creation function to use it at the appropriate moment, but that function would be needed to be changed into a function object too and then the resource cache using that function as a template parameter would hopefully still work with this after some change to it.

Now I dont really think or know if it was feasible to change SFML for my singular case, though maybe someone got another idea how I could design my library in any other way around this?

6
Graphics / Alpha channel gets lost
« on: November 10, 2013, 08:27:39 pm »
I was trying to do a forum search, but it only yields a Database error, so I try asking. ;)
I wanted to use a sf::RenderTexture, bind it and draw it to a window using OpenGL calls. The problem is I noticed the transparent parts of the Texture overwrite whats on the window when they should be invisible.
In the example code I wrote (I put it together from several classes in my code, added some globals to replace member variables, fixed it up and shortened it) the whole window should stay green, but it shows a red rectangle. It seems the alpha channel gets lost when using the texture or copying it?
#include "SFML/Window.hpp"
#include "SFML/OpenGL.hpp"
#include "SFML/Graphics.hpp"
#include <stdexcept>

int32_t windowx(1024);
int32_t windowy(768);
bool fullscreen(false);
sf::IntRect screenRect(0,0,windowx,windowy);

bool ProcessEvent(sf::Event& event) {
  if(event.type==sf::Event::Resized) {
    windowx=event.size.width;
    windowy=event.size.height;
    screenRect.width=windowx;
    screenRect.height=windowy;
    glViewport(0,0,event.size.width,event.size.height);
  }
  return event.type==sf::Event::KeyReleased;
}

void Draw(sf::Window& window) {
  glClearColor(0.0f,1.0f,0.0f,1.0f); // green
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho(screenRect.left,screenRect.left+screenRect.width,screenRect.top+screenRect.height,screenRect.top,+1024.0,-1024.0);
  glMatrixMode(GL_MODELVIEW);

  sf::RenderTexture rtex;
  if(!rtex.create(32,32))
    throw std::runtime_error("error creating RenderTexture");
  rtex.clear(sf::Color(255,0,0,0)); // transparent red
  rtex.display();

  window.setActive();
  sf::Texture::bind(&(rtex.getTexture()));

  glEnable(GL_TEXTURE_2D);
  glColor4ub(255,255,255,255);
  const sf::IntRect& rect(screenRect);

  glBegin(GL_TRIANGLES);
  glTexCoord2f(0.f,0.f);
  glVertex2i(rect.left           ,rect.top);
  glTexCoord2f(0.f,1.f);
  glVertex2i(rect.left           ,rect.top+rect.height/2);
  glTexCoord2f(1.f,1.f);
  glVertex2i(rect.left+rect.width/2,rect.top+rect.height/2);
  glVertex2i(rect.left+rect.width/2,rect.top+rect.height/2);
  glTexCoord2f(1.f,0.f);
  glVertex2i(rect.left+rect.width/2,rect.top);
  glTexCoord2f(0.f,0.f);
  glVertex2i(rect.left           ,rect.top);
  glEnd();

  glColor4ub(0,0,0,0);
  sf::Texture::bind(nullptr);
  glDisable(GL_TEXTURE_2D);
}

int main(int argc,char* argv[]) {
  sf::Window window(sf::VideoMode(windowx,windowy),"Test",
                    fullscreen ? sf::Style::Fullscreen : sf::Style::Default,
                    sf::ContextSettings(0,0,0,2,1));
  window.setVerticalSyncEnabled(1);
  glViewport(0,0,windowx,windowy);

  sf::Event event;
  while(window.isOpen()) {
    Draw(window);
    window.display();

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

  return 0;
}
 

7
Window / WaitEvent sleeping a bit too often
« on: November 03, 2013, 11:50:19 pm »
When looking through the SFML code I found it is always doing a sleep on waitEvent when the SFML queue is empty, even if process(Joystick)Events can get fresh events from the OS at first try.
Wouldn't it be better to restructure this code from WindowImpl.cpp
bool WindowImpl::popEvent(Event& event, bool block)
{
    // If the event queue is empty, let's first check if new events are available from the OS
    if (m_events.empty())
    {
        if (!block)
        {
            // Non-blocking mode: process events and continue
            processJoystickEvents();
            processEvents();
        }
        else
        {
            // Blocking mode: process events until one is triggered

            // Here we use a manual wait loop instead of the optimized
            // wait-event provided by the OS, so that we don't skip joystick
            // events (which require polling)
            while (m_events.empty())
            {
                processJoystickEvents();
                processEvents();
                sleep(milliseconds(10));
            }
        }
    }

    // Pop the first event of the queue, if it is not empty
    if (!m_events.empty())
    {
        event = m_events.front();
        m_events.pop();

        return true;
    }

    return false;
}
 
a bit, to get this where it does a first try always?
bool WindowImpl::popEvent(Event& event, bool block)
{
    // If the event queue is empty, let's first check if new events are available from the OS
    if (m_events.empty())
    {
        processJoystickEvents();
        processEvents();

        if (!block)
        {
            // Non-blocking mode: stop if no events found
            if (m_events.empty())
                return false;
        }
        else
        {
            // Blocking mode: process events until one is triggered

            // Here we use a manual wait loop instead of the optimized
            // wait-event provided by the OS, so that we don't skip joystick
            // events (which require polling)
            while (m_events.empty())
            {
                sleep(milliseconds(10));
                processJoystickEvents();
                processEvents();
            }
        }
    }

    // Pop the first event of the queue
    event = m_events.front();
    m_events.pop();

    return true;
}
 

8
SFML projects / Winter-Pong
« on: October 30, 2013, 04:59:54 pm »
I think I mentioned already that I'm making a little game to learn Ruby.
Its a Pong game with a few extras and I'll use it for a contest on GameDev. The contest-deadline is approaching(about a day left) and I only got notice of a single person who wanted to try it out, but not if it runs now.
This makes me incredibly nervous as I dont want to get into the situation where the game only runs on my computer and some small quirk prevents it to run on others.
Please, try it out and be so kind as to give a reply. Even something simple like: "I tried it on ... OS with Ruby version ... and it runs/runs not/runs only with additionally having the DevKit installed, because ... ."

For installation on Windows get Ruby 1.9.3 from http://rubyinstaller.org/ and install it in a dir without spaces with the extra options enabled to let it make file associations and add it to the path.
Unpack the game package you can dl from https://www.dropbox.com/s/g7ykbg55jj4w4vn/winter-pong-0.3.zip somewhere, start install-rbSFML.bat from that directory, double click one of the two .rbw files.
The game should run on other OS, but its untested and more involved, having to compile your own version of rbSFML and possibly SFML. Detailed instructions are inside the package.

This is a preview version, I plan on doing an update soon to add/improve a few more things.

9
Audio / Abusing SoundBuffer for file conversion
« on: October 19, 2013, 01:30:32 am »
I just want to make sure that using a quick Ruby script like this is a sensible thing to do and I'm not doing something very wrong.
require 'sfml/audio'
include SFML

fn_in=ARGV[0]+'.flac'
fn_out=ARGV[0]+'.ogg'

sb=SoundBuffer.new
sb.loadFromFile fn_in
sb.saveToFile fn_out
 
What got me a little nervous was that converting some 5MB .wav files with some other program produced nearly 1MB .ogg files and a script like above produced files at about half the size.
Now I know there is most likely just a different encoding quality, though I could not hear a difference and I'm happy about the reduced size from that little experiment with the script. Just to be sure, there are no obvious shortcuts taken like reducing stereo to mono, right?

10
Feature requests / Font Finder
« on: October 18, 2013, 12:27:22 pm »
I'm sure you fear reading that someone wants the default font back, again; but I do not as there were reasons for removing it. :)

Now there is still something lacking: you pretty much have to include a font file in your project, because its difficult to in a crossplatform way find some preinstalled font, which all systems should have.

A good first step would be a function that only finds out the directory where font files are stored and returns a string containing the path, for example "C:/WINDOWS/Fonts/". I think there would be some way available to find that out on all OS, as other programs can do that, too. If that gives no security concern it could help people already a little if they want to try loading some random or less random font from there, otherwise hide it inside the second part.

This second step would be to base a class thats the equivalent of sf::VideoMode for font files on that foundation and give only a few common options like getting some monospace or serif or sans serif or handwriting or ... font, maybe also add the font attributes to choose a premade normal, bold, italic, ... font. This class could then have a method to return a filename to be fed to the font class or maybe just also add another constructor to sf::Font to take advantage of information the font finder class internally collected already.

11
Graphics / RectangleShape vs Sprite
« on: October 12, 2013, 08:41:27 pm »
I tried to find the difference between using a RectangleShape and a Sprite by reading the docs, but they seem to have mostly the same functionality, only that a RectangleShape can have a size, an outline and the option to not use a Texture. I assume a Sprite should just get scaled instead of setting a size?
Whats the usecase where a Sprite should be prefered? Is it just a bit more efficient?

Pages: [1]