Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Rotating images on OSX (10.5) and sfml 1.6  (Read 2751 times)

0 Members and 1 Guest are viewing this topic.

tsiegel

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • http://www.softcon.com/mac/
Rotating images on OSX (10.5) and sfml 1.6
« on: August 12, 2010, 05:20:35 am »
I'm having some trouble with a program I was putting together for my wife, just some quick graphical functions, such as flipping, rotating, shading, etc.  It seems that rotating is broken on osx using sfml 1.6 (or I'm doing something wrong)
When I call the code to rotate a sprite 90 degrees, it does nothing the first time, a second attempt splits the image into two, and subsequent pairs of calls produce another image.  Rotating the other direction undoes the buplicates, but still, no rotation takes place.
Am I doing something wrong? I don't initialize any parts of the sprite, everything is left at the loaded defaults.
Also, when I call resize on the sprite, increasing the y value by 0.1 units, the picture breaks up into a scattering of shapes (mostly squares).  I can't explain it any better than that, because that's all my Daughter says about it, and she's only 5, but my wife confirmed that's the behavior (whatever that means).
So, should I be initializing the the sprite values to something particular to stop this behavior, or is there a bug in the osx version of 1.6 sfml libs? And if so, how do I get around it (calling opengl directly?)
The picture I'm using is one from:
http://commons.wikimedia.org/wiki/File:Crude_Blue_Parrot.png
Just displaying the parrot works just fine, flipping the x or y axis works fine, although trying to save the newly flipped/reversed image doesn't work either.  I couldn't get anyone to tell me what the error message said, though I'll keep working on that one.  I realize that part isn't terribly helpful, but I thought I'd toss it in just in case it's relevant.  Only increasing the y value by 0.1 causes graphical misbehavior, and as I said, trying to rotate it does nothing until it's been rotated more than once.  Any assistance would be appreciated, and please be specific, as code is all I have to work with, since the graphics aren't for my benefit, since I can't see them anyhow. :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Rotating images on OSX (10.5) and sfml 1.6
« Reply #1 on: August 12, 2010, 08:30:50 am »
Hi

As far as I know, there's no such a bug in SFML 1.6 on Mac OS X. You should show us a complete and minimal code that reproduces this problem.

Quote
although trying to save the newly flipped/reversed image doesn't work either

You flip the sprite, but the source image remains the same ;)
Laurent Gomila - SFML developer

tsiegel

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • http://www.softcon.com/mac/
Rotating images on OSX (10.5) and sfml 1.6
« Reply #2 on: August 12, 2010, 08:27:06 pm »
Quote from: "Laurent"
Hi

As far as I know, there's no such a bug in SFML 1.6 on Mac OS X. You should show us a complete and minimal code that reproduces this problem.


I managed to get most of the issues solved.  The expanding/compressing the picture was due to using increments too small, then resetting the values before the next attempt to resize.  That part works now.  The problem with having the screen break into shapes was a result of spaces launching (osx by default uses f8 for spaces) I've turned that off, so that works too.
However, I'm still having the problem of artifacts when rotating.  With all other functions, I don't need to clear the screen or update background or anything, just app.draw(sprite) and app.display() and the new image gets displayed properly.  I'm told that when rotating though, the picture gets duplicated, (or at least portions of it do anyway) and that's where the confusion for my daughter was coming from.  Is there something else I should be doing to make sure the screen gets updated properly upon rotate that isn't necessary on increasing/decreasing size, or moving the picture around?


Quote from: "Laurent"
Quote
although trying to save the newly flipped/reversed image doesn't work either

You flip the sprite, but the source image remains the same ;)


Right, which is why I assigned the new sprite to another image, then try to save that image.  (actually, I was initially using the screen capture function to grab the picture, but that doesn't work either)
I get no file output at all either from screen capture then savetofile, or from assigning a new sprite, then savetofile.
The screen capture code I use was taken directly from the tutorial on sprites on the sfml documentation page.  The assign to sprite then save was my own code, but it doesn't work either, so not much point in posting. :)
So, any and all assistance is appreciated.
(btw, it's really hard making graphical programs when you gotta rely on what others say about the screen) :-).

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Rotating images on OSX (10.5) and sfml 1.6
« Reply #3 on: August 12, 2010, 10:40:32 pm »
Quote
Is there something else I should be doing to make sure the screen gets updated properly upon rotate that isn't necessary on increasing/decreasing size, or moving the picture around?

You should always clear the window before drawing anything. If you don't need to do it for other transformations, it means that the new size/position completely overlaps the pixels previously taken by the sprite.

Quote
actually, I was initially using the screen capture function to grab the picture, but that doesn't work either

What does the SaveToFile function return? If it's true, then the image was successfully created, but it is maybe not located where you think it is ;)
Laurent Gomila - SFML developer

tsiegel

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • http://www.softcon.com/mac/
Rotating images on OSX (10.5) and sfml 1.6
« Reply #4 on: August 13, 2010, 11:59:22 pm »
Quote
You should always clear the screen before drawing anything. If you don't need to do it for other transformations, it means that the new size/position completely overlaps the pixels previously taken by the sprite.

Ahh, gotcha.  That makes sense, sorry I didn't think of that, should have realized that was what was happening.
Quote
What does the SaveToFile function return? If it's true, then the image was successfully created, but it is maybe not located where you think it is ;)

Again, you were right on this one too, (though not as you thought) :) The key I was using to do the file save apparently is another one used by osx.  When I changed it to something else, it worked properly.  Your idea to show the status of the save to see if it was successful gave me absolutely nothing in return, so at that point, I figured out that osx was taking my key.  Changing the key used for the function solved the problem.
Whew, kind of a hassle competing with the os for key realestate. :-).
Thanks for your help, I'm sure there will be more when I get to adding additional features that aren't built-in by default.

 

anything