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

Pages: [1]
1
Feature requests / Re: ability to use rotated images with setTextureRect
« on: August 10, 2014, 11:29:37 am »
Locking rotations to multiples of 90 degrees sounds too much like catering to a specific subset of packers. After all, there might be obscure packers that rotate sprites in angles that are not multiples of 90 degrees... what do we do then?

I don't think this makes sense. Rotating 90 degrees you're guaranteed to be able to fit all the pixels in there perfectly and pretend that you never rotated the texture. Any other value and you give up 1:1 pixel mapping.

2
Feature requests / Re: ability to use rotated images with setTextureRect
« on: August 09, 2014, 08:52:04 pm »
Why is this needed so much when in the end the output from rotating the texture coordinates would look the same as rotating the sprite? Some adjustment to client code would always be needed when using such a weird rotating texture packer.

It's not weird. Many texture packers have this feature.

3
Feature requests / Re: ability to use rotated images with setTextureRect
« on: August 06, 2014, 06:21:33 pm »
Hmm there are some problems by making this rotation function. First of all, what point should it rotate around? Lets say that it should just rotate around the center. If you then say the coordinates are like this

x: 0, y: 0, width: 50, height 25

When rotating this around the center you will get a wrong x coordinates outside the texture.

There's no problem here. Don't think of it like a rotation point, think of it as simply storing the image sideways. It's just a matter of different UV coords. Example from SFML:

Before:


void Sprite::updateTexCoords()
{
    float left   = static_cast<float>(m_textureRect.left);
    float right  = left + m_textureRect.width;
    float top    = static_cast<float>(m_textureRect.top);
    float bottom = top + m_textureRect.height;

    m_vertices[0].texCoords = Vector2f(left, top);
    m_vertices[1].texCoords = Vector2f(left, bottom);
    m_vertices[2].texCoords = Vector2f(right, top);
    m_vertices[3].texCoords = Vector2f(right, bottom);
}

After:

void Sprite::updateTexCoords()
{
    float left   = static_cast<float>(m_textureRect.left);
    float right  = left + m_textureRect.width;
    float top    = static_cast<float>(m_textureRect.top);
    float bottom = top + m_textureRect.height;

    if (r90) {
      m_vertices[0].texCoords = Vector2f(right, top);
      m_vertices[1].texCoords = Vector2f(left, top);
      m_vertices[2].texCoords = Vector2f(right, bottom);
      m_vertices[3].texCoords = Vector2f(left, bottom);
    } else {
      m_vertices[0].texCoords = Vector2f(left, top);
      m_vertices[1].texCoords = Vector2f(left, bottom);
      m_vertices[2].texCoords = Vector2f(right, top);
      m_vertices[3].texCoords = Vector2f(right, bottom);
    }
}

4
Feature requests / Re: ability to use rotated images with setTextureRect
« on: August 06, 2014, 05:57:14 pm »
The other option is of course to modify SFML source for yourself but that doesn't help anyone else...

I'm happy to submit a patch. This feature would be straightforward to write and small. I only want the blessing of the project leader(s) that they agree with the feature.

5
Feature requests / Re: ability to use rotated images with setTextureRect
« on: August 06, 2014, 04:57:53 pm »
One could just make a rotation calculation on the coordinates or just get the new coordinates from the packed texture. In my opinion its better to use the right coordinates than start rotating them to get right ones. But of course, its not up to me to make that decision.

I don't think I'm communicating clearly. Consider a spritesheet like this:



Note that it has images that are normal and also images that are rotated 90 degrees. This is to make the spritesheet more efficient.

So I'm not using "wrong" coordinates. I'm using efficient texture packing, and it's easy to read the image from the texture in the correct orientation by adjusting the UV coords.

SFML just needs to let me call updateTexCoords manually or provide an API that understands rotation.

6
Feature requests / ability to use rotated images with setTextureRect
« on: August 06, 2014, 04:43:49 pm »
Some texture packers rotate images 90 degrees clockwise or counter-clockwise for efficient packing. When loading textures, the OpenGL code would look something like this:

GLfloat coords[4][2];
if (info->r90) {
    coords[0][0] = (info->x + info->width) / textureWidth;
    coords[0][1] = info->y / textureHeight;

    coords[1][0] = info->x / textureWidth;
    coords[1][1] = info->y / textureHeight;

    coords[2][0] = (info->x + info->width) / textureWidth;
    coords[2][1] = (info->y + info->height) / textureHeight;

    coords[3][0] = info->x / textureWidth;
    coords[3][1] = (info->y + info->height) / textureHeight;
} else {
    coords[0][0] = info->x / textureWidth;
    coords[0][1] = info->y / textureHeight;

    coords[1][0] = info->x / textureWidth;
    coords[1][1] = (info->y + info->height) / textureHeight;

    coords[2][0] = (info->x + info->width) / textureWidth;
    coords[2][1] = info->y / textureHeight;

    coords[3][0] = (info->x + info->width) / textureWidth;
    coords[3][1] = (info->y + info->height) / textureHeight;
}
glBindBuffer(GL_ARRAY_BUFFER, info->texCoordBuffer);
glBufferData(GL_ARRAY_BUFFER, 4 * 2 * sizeof(GLfloat), coords, GL_STATIC_DRAW);
glEnableVertexAttribArray(spritesheet.attribTexCoord);
glVertexAttribPointer(spritesheet.attribTexCoord, 2, GL_FLOAT, GL_FALSE, 0, NULL);

With SFML, I want to do something like this:

sf::Sprite sprite;
sprite.setTexture(spritesheet);
sprite.setTextureRect(sf::IntRect(info->x, info->y, info->width, info->height), info->r90 ? sf::Clockwise90 : sf::NoRotation);

So SFML would check the second parameter which might inform it to set slightly different UV coords taking into account this rotation.

Alternate API could be
sprite.setTextureRectRotation(sf::Clockwise90)
.

Another alternative would simply be making updateTexCoords public instead of private.

I looked into SFML's code and it looks very clean and understandable. I would be happy to implement this feature. What I want to know is, are you interested in this feature? Should I make a pull request?

7
General / Using SFML on an XBOX, Wii, PS3
« on: March 02, 2010, 10:15:00 am »
Has anyone used SFML successfully on any of these platforms? Will I be able to support these platforms in the future if I depend on SFML?

Pages: [1]