Hello Guest

Author Topic: Missing Images when distibuting  (Read 52352 times)

0 Members and 1 Guest are viewing this topic.

saint11

  • Member
  • Posts: 3
    • View Profile
Missing Images when distibuting
« on: June 15, 2014, 02:25:47 PM »
I got this weird bug. Sometimes, when I distribute my game, it will run normally, but some images will not be rendered, I have no idea why... Does anyone have any clues of what might be causing that?

Kyle

  • Administrator
  • Member
  • Posts: 258
    • View Profile
Re: Missing Images when distibuting
« Reply #1 on: June 15, 2014, 04:59:23 PM »
Are they totally invisible?

paste0x78

  • Member
  • Posts: 9
    • View Profile
Re: Missing Images when distibuting
« Reply #2 on: June 15, 2014, 06:59:03 PM »
I seem to have this issue too. Though it could be that I've just started using otter and am doing it wrong. I found Eric's tutorial http://ericmbernier.tumblr.com/post/74896213201/otter-2d-top-down-adventure-tutorial-part-2 and my text and images are not showing. Looking at your Pong youtube video I can draw rectangles, so I'm not sure whats wrong.
I did apply your text fix from dev but it doesn't seem to be a positioning problem. Could be an OSX thing since I did have trouble getting that running. I'll have to dig deeper and report back.


Kyle

  • Administrator
  • Member
  • Posts: 258
    • View Profile
Re: Missing Images when distibuting
« Reply #3 on: June 15, 2014, 07:08:36 PM »
I've seen some people having weird issues with textures that were fixed when they updated their video card drivers, I don't now if this is the same thing.  (I definitely had a friend who for some reason couldnt get any text to render until he updated his video card drivers.)

paste0x78

  • Member
  • Posts: 9
    • View Profile
Re: Missing Images when distibuting
« Reply #4 on: June 15, 2014, 08:38:11 PM »
So while trying to see if it was even loading the texture I decided to save out a copy to a file and notice that my texture is now rendering in-game when adding this modification to Texture.cs.

Texture.cs : Line 78
Code: [Select]
        /// <summary>
        /// Load a texture from a file path.
        /// </summary>
        /// <param name="source">The file path to load from.</param>
        /// <param name="useCache">Determines if the cache should be checked first.</param>
        public Texture(string source, bool useCache = true) {
            if (useCache) {
                texture = Textures.Load(source);
texture.CopyToImage (); //Adding this made my image appear, which in C++ calls sf::Texture::copyToImage
//Console.WriteLine (texture.CopyToImage().SaveToFile("otterlogo2.png"));
            }
            else {
                texture = new SFML.Graphics.Texture(source);
            }
            Source = source;

            if (Game.Instance != null) {
                texture.Smooth = Game.Instance.SmoothAll;
            }
        }

My TitleScene.cs class
Code: [Select]
public const string TITLE_IMG = "Assets/otterlogo.png";

...

public Image titleImage = new Image(Assets.TITLE_IMG);

public TitleScene ()
{
// Center the title picture
titleImage.CenterOrigin();
titleImage.X = Global.MAIN.HalfWidth;
titleImage.Y = Global.MAIN.HalfHeight;
AddGraphic(titleImage);
}

Now I also tried to just call update to see if that did anything after loading but nothing changed. Looking into the  actual c++ function, other than making a copy of the pixels and returning an image sf::Texture::copyToImage does set this ...

SFML / src / SFML / Graphics / Texture.cpp
https://github.com/LaurentGomila/SFML/blob/a3484284763ac9783fad385111d097204ecadb01/src/SFML/Graphics/Texture.cpp#L264
Code: [Select]
        // Make sure that the current texture binding will be preserved
        priv::TextureSaver save;

Being new to sfml and sfml.net I'm not sure if thats anything or of any help but they render now :D
I'll attempt more tomorrow.

EDIT:
I lied. Trying more things now. It also seems to fix text rendering as well.

« Last Edit: June 15, 2014, 09:21:49 PM by paste0x78 »

Kyle

  • Administrator
  • Member
  • Posts: 258
    • View Profile
Re: Missing Images when distibuting
« Reply #5 on: June 15, 2014, 11:05:39 PM »
Wow that's really interesting.  I wonder if this happens in just a bare bones SFML example?  If so, I think the folks at the SFML forums would love to take a look at this as well.

Kyle

  • Administrator
  • Member
  • Posts: 258
    • View Profile
Re: Missing Images when distibuting
« Reply #6 on: June 15, 2014, 11:24:29 PM »
Yeah so unfortunately CopytoImage is really intense to use in that spot, since all textures being loaded are being copied to memory which eats up ram and performance.

So it looks like what might be happening is that the video card may be losing the texture binding for certain renders somehow?  But that doesn't make any sense either, because if that were the case then I feel like what should be happening is that you would be seeing a bunch of colored rectangles where your textures should appear, and instead you're just getting nothing?  Is that correct?

Also could you guys let me know what video cards you're using that you see this problem on?

paste0x78

  • Member
  • Posts: 9
    • View Profile
Re: Missing Images when distibuting
« Reply #7 on: June 16, 2014, 05:16:02 AM »
Ya theres no way I want to call my problem "fixed" by using copyToImage. I was thinking the same thing that my texture was getting lost along the way somewhere.
Well I am going from Otter -> SFML.Net -> Mono -> SFML, so it could be anywhere in the chain but I'm going to try a barebones SFML and SFML.net example tonight and see what happens.

As for Otter, when calling texture.CopyToImage (); I see the texture and text and when I don't I see a blank screen as in still black, no funky colors or anything.

I think I'm also going to try and recompile the dylibs and add in a method that just calls  priv::TextureSaver save;  on a texture with no other mcpy or anything and make that available to .Net.

Heres my Specs:

Code: [Select]
Mac Pro:    Early 2009
Processor:  2 x 2.26 GHz Quad-Core Intel Xeon
Memory:     14 GB 1066 MHz DDR3 ECC
Graphics:   4 x NVIDIA GeForce GT 120 512 MB
Software:   OS X 10.8.5 (12F45)

Kyle

  • Administrator
  • Member
  • Posts: 258
    • View Profile
Re: Missing Images when distibuting
« Reply #8 on: June 16, 2014, 12:22:46 PM »
ah I see, so your issue is only happening in OS X?  (Or, you only have access to OS X so you don't know if it's also a Windows problem.)  I didn't even notice that you posted a screen shot of what is clearly not Windows, hahah

paste0x78

  • Member
  • Posts: 9
    • View Profile
Re: Missing Images when distibuting
« Reply #9 on: June 16, 2014, 07:13:34 PM »
ah I see, so your issue is only happening in OS X?  (Or, you only have access to OS X so you don't know if it's also a Windows problem.)  I didn't even notice that you posted a screen shot of what is clearly not Windows, hahah

I haven't tried it on Windows since I primarily use OSX. I get get to do a SFML.net test using the same DLL's and DYLIB's and got a texture to render.



Program.cs
Code: [Select]
using System;
using SFML;
using SFML.Graphics;
using SFML.Window;

namespace SFML.net
{
class Program
{
static void Main(string[] args)
{
MySFMLProgram app = new MySFMLProgram();
app.StartSFMLProgram();
}
}
class MySFMLProgram
{
RenderWindow _window;
public void StartSFMLProgram()
{
_window = new RenderWindow(new VideoMode(400, 400), "SFML window");
_window.SetVisible(true);
_window.Closed += new EventHandler(OnClosed);

// Load the texture and initialize the sprite
Texture myTexture = new Texture("otterlogo.png");
Sprite mySprite = new Sprite(myTexture);

while (_window.IsOpen())
{
_window.DispatchEvents();
_window.Clear(Color.Black);
_window.Draw (mySprite);
_window.Display();
}
}
void OnClosed(object sender, EventArgs e)
{
_window.Close();
}
}
}


So I don't think theres a problem with the the dll or the c++ implementation because a couple of months ago I did a couple of SFML projects and those rendered fine. From at least this basic test I can say that SFML.net works when trying to load a basic texture. Maybe theres something in the way Otter is prepping the texture for display that OSX doesn't like?
I'll poke around a little more to see if I can get this thing going, I'd really like to use it.

paste0x78

  • Member
  • Posts: 9
    • View Profile
Re: Missing Images when distibuting
« Reply #10 on: June 16, 2014, 07:47:01 PM »
I did a little debugging and noticed that right before the renderstate gets passed to the dll the shader is null. Is there supposed to be a default shader? Especially if the blend mode is set to alpha?
The texture (Otter.Graphic) does have pixels in it by the way and they are not set to alpha 0.


paste0x78

  • Member
  • Posts: 9
    • View Profile
Re: Missing Images when distibuting
« Reply #11 on: June 16, 2014, 08:02:29 PM »
I got this weird bug. Sometimes, when I distribute my game, it will run normally, but some images will not be rendered, I have no idea why... Does anyone have any clues of what might be causing that?

So I just realized that until now I've been building in "Release" mode instead of "Debug". In debug everything works as expected but switch that to release and no textures. Just like saint11 stated in the beginning of this thread. This is with without including my CopyImage hack in Texture.cs.

Kyle

  • Administrator
  • Member
  • Posts: 258
    • View Profile
Re: Missing Images when distibuting
« Reply #12 on: June 17, 2014, 04:01:28 AM »
I don't think Shader being null is an issue, I believe SFML uses its default shader in that case?  I can look into it though.

It's really weird that it would work in debug, but not release... also some things to consider: SFML doesn't require power of 2 textures and that might freak out some video cards, maybe?  Also, I wonder if it's the RenderTexture that is having problems and not all textures.  Can you do a test of a RenderTexture in your bare bones SFML program?

One difference between debug and release is the console: Debugger.cs.  It's not available in release mode unless a specific flag is set to true (I think Game.ForceDebugger() has to be called before Game.Start() to get a console in release mode.)  I'm not sure if that could possibly effect anything though.

paste0x78

  • Member
  • Posts: 9
    • View Profile
Re: Missing Images when distibuting
« Reply #13 on: June 17, 2014, 05:25:53 PM »
So the debugger seems be the culprit. When in "Debug" mode with the debugger = null my textures aren't drawn. I'm still looking as to why this is. There may be some accidental dependency. In "Release" mode with ForceDebugger on the textures render fine.

In debug mode with the debugger on and the rendering loop commented out this happens when the console is not up. Still need some searching needed to see where the connection is.

This may be nothing.

EDIT:
Another thought, the debugger may be slowing it down enough to fix some race condition. That could be why sometimes for others it works in release.
« Last Edit: June 17, 2014, 05:31:43 PM by paste0x78 »

Kyle

  • Administrator
  • Member
  • Posts: 258
    • View Profile
Re: Missing Images when distibuting
« Reply #14 on: June 17, 2014, 05:44:50 PM »
Hahah what is going on in that screenshot!  It looks like for the text that the font texture is not being properly built, and the otter texture just seems to be garbage data being fed into a texture somehow?

The debugger is being rendered to its own Surface, and the game is rendered to a different Surface... so maybe that has something to do with it.  Not sure what the race condition could be that could result in nothing being rendered... hm