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

Author Topic: Resource textures  (Read 3117 times)

0 Members and 2 Guests are viewing this topic.

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Resource textures
« on: April 14, 2015, 05:38:31 pm »
Hi!  :)

My question is how to load images from resources of .exe file, as you know VS2012 supports it. But how can i do it if sfml can load from image-file and stream. Am i missing something in my head? Can SFML load from .exe resources with loadFromStream() or loadFromMemmory()?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Resource textures
« Reply #1 on: April 14, 2015, 05:54:59 pm »
You're asking the wrong question and the wrong people. SFML can load from a stream or memory. The question you should be asking is: How do you get a stream or a pointer to the memory of the resources in an exe file?
And instead of asking us, you should probably ask at a place where a lot more Windows developers are hanging out and I'd actually bet that this questions has been answered many times. How much time did you spend trying to figure it out on your own by googling? ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Red-XIII

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Advanced Protocol
    • Email
Re: Resource textures
« Reply #2 on: April 14, 2015, 07:14:23 pm »
If you figure this out, could you post a link to the answer?  :)

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Resource textures
« Reply #3 on: April 14, 2015, 09:33:35 pm »
Not sure if this is exactly what you are looking for but if you can use Gimp, it can export images as c source code which can be included in a header file and referenced via loadFromMemory().

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Resource textures
« Reply #4 on: April 14, 2015, 10:36:55 pm »
If you figure this out, could you post a link to the answer?  :)

Can't you follow eXpl0it3r's advice and just google? There is many resources on this and all of them show how to load a resource and get a pointer to the data. Its not exactly rocket science.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Red-XIII

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Advanced Protocol
    • Email
Re: Resource textures
« Reply #5 on: April 14, 2015, 10:52:21 pm »
It's not rocket science, you're right, but I merely asked for a link. I've looked up on how to do it before, but nothing really came up that were helpful to me. Gimp no longer does C Exporting by the way, I already tried, I am however working on alternative with Paint.Net as a File Type Plugin, if you would like a copy of the plugin when i'm finished just PM me.
« Last Edit: April 14, 2015, 11:01:48 pm by Red-XIII »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Resource textures
« Reply #6 on: April 15, 2015, 08:46:01 am »
There are millions of small utilities or source codes that do it on the internet (Google "file to C array", for example). And even if you had to write it yourself, it's just ~15 lines of code for the whole program. That could be a good exercise ;)
Laurent Gomila - SFML developer

Red-XIII

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Advanced Protocol
    • Email
Re: Resource textures
« Reply #7 on: April 15, 2015, 09:02:34 am »
I can tell you, it was not 15 lines of code, but it was a nice experience, lol. If you want to see how far mine turned out, here it is.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Laurent Gomila - SFML developer

Red-XIII

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Advanced Protocol
    • Email
Re: Resource textures
« Reply #9 on: April 15, 2015, 06:31:22 pm »
That's a nice bit of code. I did mine in C# for obvious reasons, lol. By the way I find that using characters for the image data uses less memory, and is more compact, I think Gimp did that exact thing.