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

Author Topic: RenderImage : unexpected segfault...  (Read 7469 times)

0 Members and 1 Guest are viewing this topic.

Gibgezr

  • Newbie
  • *
  • Posts: 33
    • View Profile
RenderImage : unexpected segfault...
« Reply #15 on: April 08, 2011, 04:08:08 pm »
Looking at your code, you are creating the RenderImage as a temporary local variable in your function, then passing back a Sprite that uses it. The problem is that your RenderImage is then destroyed when the function returns, so the Sprite is no longer valid (it is based on a now deleted RenderImage).

Right?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
RenderImage : unexpected segfault...
« Reply #16 on: April 08, 2011, 04:22:36 pm »
Where do you see a sprite??

Anyway, the image is returned by copy, it's not a reference to the render-image's internal one. So as long as the calling code stores the result it's fine.
Laurent Gomila - SFML developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
RenderImage : unexpected segfault...
« Reply #17 on: April 08, 2011, 04:27:26 pm »
I think the very minimal code that reproduce the problem is the following :

Code: [Select]
#include <SFML/Graphics.hpp>

int main(int, char**) {
 { sf::RenderImage ri; ri.Create(100, 100); }
 { sf::RenderImage ri; ri.Create(100, 100); }
 return 0;
}


Can you confirm this ?

If I'm right the line of code I sent you, Laurent, should fix that.
SFML / OS X developer

Gibgezr

  • Newbie
  • *
  • Posts: 33
    • View Profile
RenderImage : unexpected segfault...
« Reply #18 on: April 08, 2011, 04:28:38 pm »
Quote from: "Laurent"
Where do you see a sprite??

Anyway, the image is returned by copy, it's not a reference to the render-image's internal one. So as long as the calling code stores the result it's fine.


Doh! That's what I get for reading too quickly, lol.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
RenderImage : unexpected segfault...
« Reply #19 on: April 08, 2011, 04:29:50 pm »
Quote
If I'm right the line of code I sent you, Laurent, should fix that.

I don't think so, for two reasons:
- it happens on the first call, not the second one
- there's a window that lives in main() so the internal OpenGL context is not destroyed between two calls to getFlatennedImage()
Laurent Gomila - SFML developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
RenderImage : unexpected segfault...
« Reply #20 on: April 08, 2011, 04:38:04 pm »
Ho, you're right! Apparently I read the topic too quickly. My bad.
SFML / OS X developer

chocobn

  • Newbie
  • *
  • Posts: 39
    • View Profile
RenderImage : unexpected segfault...
« Reply #21 on: April 08, 2011, 05:02:37 pm »
@Hiura : yeah it does the same segfault!

So, does anyone know what am i doing wrong? Or is it a sfml bug?

Laurent i haven't found the shader example your talking about --'

I've upgraded my sfml version yesterday or the day before. I can upgrade it again, if it is helpful.

I downloaded a snapshot with a folder inside called "LaurentGomila-SFML-cb1f938". I think it's the version number that you want.

Fred_FS

  • Newbie
  • *
  • Posts: 48
    • View Profile
RenderImage : unexpected segfault...
« Reply #22 on: April 08, 2011, 05:32:53 pm »
Your code works fine for me with Visual Studio. So I don't think, that it is a SFML-Bug. Probably there is something wrong with your libs(or Code Blocks doesn't like your code ;) - but I rather don't think so) or build-options. Unfortunately I have not enough experience with Code Blocks, to give you any advice. But I definitely don't think, that there is something wrong with SFML.

chocobn

  • Newbie
  • *
  • Posts: 39
    • View Profile
RenderImage : unexpected segfault...
« Reply #23 on: April 08, 2011, 05:37:07 pm »
I'm using Make and gcc on an quite up to date Ubuntu Linux... It shouldn't be like that, that is definitly weird :/

I tried to make a minimal cmakelist.txt
Code: [Select]

set(CMAKE_BUILD_TYPE CMAKE_CXX_FLAGS_DEBUG)
project(Programme)

find_package(SFML REQUIRED COMPONENTS graphics)

add_executable(
Programme
main.cpp
)

target_link_libraries(Programme ${SFML_GRAPHICS_LIBRARY_DEBUG})

INSTALL_TARGETS( /bin Programme)