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

Author Topic: Thor 2.0 cmake build error OS X 10.7  (Read 23409 times)

0 Members and 1 Guest are viewing this topic.

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: Thor 2.0 cmake build error OS X 10.7
« Reply #15 on: September 03, 2012, 04:44:06 pm »
I've just been building GCC 4.7. I still had to comment out the check for CMAKE_COMPILER_IS_GNUCXX and I added the following a bit after the beginning of the CMakeLists.txt file:
Code: [Select]
INCLUDE (CMakeForceCompiler)
SET(CMAKE_SYSTEM_NAME Generic)
CMAKE_FORCE_C_COMPILER   (gcc4.7 GCC)
CMAKE_FORCE_CXX_COMPILER (g++4.7 GXX)
Then I could successfully build Thor. I was also surprised to see the program "works" although I built it with Clang whereas Thor was built with GCC, especially considering that Clang can't build Thor at the moment.

However BigTexture isn't working as expected: it can load image file that sf::Texture is already able to handle but if I try to load an image whose size is greater than 4096 pixels wide, it displays garbage. I used the following code:
int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Fractales", sf::Style::Close);
    window.setFramerateLimit(60);
   
    thor::BigSprite spr;
    thor::BigTexture tex;
   
    if (!tex.loadFromFile("test.png"))
    {
        std::cout << "error loading image file" << std::endl;
        return 1;
    }
   
    spr.setTexture(tex);
   
    sf::View view = window.getDefaultView();
    view.zoom(10);
    window.setView(view);
   
    while (window.isOpen())
    {
        sf::Event ev;
       
        while (window.pollEvent(ev))
        {
            if (ev.type == sf::Event::Closed or
                (ev.type == sf::Event::KeyPressed and ev.key.code == sf::Keyboard::Escape))
            {
                window.close();
            }
        }
       
        window.clear();
        window.draw(spr);
        window.display();
    }
   
    return 0;
}
It does look like the texture limit isn't correctly retrieved, but maybe there's something wrong on SFML's side.
Want to play movies in your SFML application? Check out sfeMovie!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0 cmake build error OS X 10.7
« Reply #16 on: September 03, 2012, 05:38:03 pm »
I still had to comment out the check for CMAKE_COMPILER_IS_GNUCXX
Why exactly? What happens if you leave the configuration file unchanged? I haven't tested g++ version 4.7 yet, but 4.6 works for me...

However BigTexture isn't working as expected: it can load image file that sf::Texture is already able to handle but if I try to load an image whose size is greater than 4096 pixels wide, it displays garbage.
Hm, I have used thor::BigTexture successfully in Airport. Also I tested quickly for a 10000x5600 image (with a texture limit of 8192), it is displayed correctly.

But maybe there is a problem with Macs, I have never tested it there. What do you mean with garbage? What does sf::Texture::getMaximumSize() return?
« Last Edit: September 03, 2012, 05:42:37 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: Thor 2.0 cmake build error OS X 10.7
« Reply #17 on: September 03, 2012, 05:55:48 pm »
Why exactly? What happens if you leave the configuration file unchanged? I haven't tested g++ version 4.7 yet, but 4.6 works for me...
Because otherwise the -std=c++0x flag isn't used, because the test fails. And without the flag the compiler complains that you're using C++11 features. I guess this is because I forced it to use "some" compiler and CMake does not know whether it's a GNU C++ compiler, thus CMAKE_COMPILER_IS_GNUCXX becomes unreliable.

Hm, I have used thor::BigTexture successfully in Airport. Also I tested quickly for a 10000x5600 image (with a texture limit of 8192), it seems to be displayed correctly.

But maybe there is a problem with Macs, I have never tested it there. What do you mean with garbage? What does sf::Texture::getMaximumSize() return?
sf::Texture::getMaximumSize() returns 8192, and Apple specs say the max texture size for my graphics card is indeed 8192 (see MAX_TEXTURE_SIZE for HD Graphics 3000) but texture won't display on my laptop if they're bigger than 4096 pixels wide. In Thor's sources I divided all of your results for sf::Texture::getMaximumSize() by 2 and it allowed me to use BigTexture for any image size.

What I mean with garbage is this:



instead of this:



In these pictures the texture size is 10800x9600.
Want to play movies in your SFML application? Check out sfeMovie!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0 cmake build error OS X 10.7
« Reply #18 on: September 03, 2012, 08:28:50 pm »
I guess this is because I forced it to use "some" compiler and CMake does not know whether it's a GNU C++ compiler, thus CMAKE_COMPILER_IS_GNUCXX becomes unreliable.
That's annoying. Do you think I can do something about it? Looks rather like a CMake bug if g++ isn't recognized correctly (or the corresponding variables are not set). In this case we should perhaps write a bug report...

sf::Texture::getMaximumSize() returns 8192, and Apple specs say the max texture size for my graphics card is indeed 8192 [...] but texture won't display on my laptop if they're bigger than 4096 pixels wide..
Have you tried to create a texture of 8000x8000 pixels (or the like) directly with SFML? Thor relies on the texture limit returned by sf::Texture::getMaximumSize(). I assumed it to be correct, no idea why your graphics has problems with a texture size that it officially should support :-\

By the way, thanks a lot for your feedback, Ceylo. I really appreciate people who take the time to test Thor on other systems.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: Thor 2.0 cmake build error OS X 10.7
« Reply #19 on: September 03, 2012, 08:47:16 pm »
That's annoying. Do you think I can do something about it? Looks rather like a CMake bug if g++ isn't recognized correctly (or the corresponding variables are not set). In this case we should perhaps write a bug report...
You should not bother with this, as I had to rebuild GCC. I don't think you'll see much OS X users doing so. What would be really useful is fixing Thor so that it can be built with Clang.

Have you tried to create a texture of 8000x8000 pixels (or the like) directly with SFML? Thor relies on the texture limit returned by sf::Texture::getMaximumSize(). I assumed it to be correct, no idea why your graphics has problems with a texture size that it officially should support :-\

By the way, thanks a lot for your feedback, Ceylo. I really appreciate people who take the time to test Thor on other systems.
Yes I have also tried to use big textures (like 6000x6000) directly with SFML, and I'm having the same issue. That's why I thought I had reached my CG texture size limit, which is also why I've been looking for a BigTexture class, that I found in Thor.

I don't know either why I can only load textures that are half the officially supported size. I didn't notice anything weird in SFML's Texture implementation. But anyway, SFML or my drivers are buggy, not Thor :) .

Anyway, the purpose was to render fractals at huge resolutions so that I could zoom in and enjoy the result (ok, I was also kinda proud of seeing multithreaded rendering in action ;D), but I don't think it's the way to go. I'd better rendering efficiently at 1:1 scale and re-render the zoomed in areas. With this way, as long as SFML can handle textures of at most the screen size it's ok.
Want to play movies in your SFML application? Check out sfeMovie!

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Thor 2.0 cmake build error OS X 10.7
« Reply #20 on: September 04, 2012, 10:42:51 am »
I just saw this thread today, so here are a few general thoughts :

SFML still use Legacy OpenGL profile (and not Core) so the GC specifications are here : https://developer.apple.com/graphicsimaging/opengl/capabilities/GLInfo_1080.html (I didn't compare the two specs but I guess there are some differences between the two. However MAX_TEXTURE_SIZE has the same value in both specs.)

Quote
But anyway, SFML or my drivers are buggy, not Thor  .
I'm betting it's OS X's fault since the related code is really simple.  :P

If you have plenty of time you could open on issue on Apple's bug tracker. However if you don't want to I would totally understand as it took them one whole year to answer one of my issue, and by answer I mean "we won't fix this"...


C++11 with clang on Mac indeed needs libc++ to work. With SFML (§C++11) you can simply edit your cmake cache; in fact the user should not have to edit any files. Something similar can probably be done in Thor.
SFML / OS X developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0 cmake build error OS X 10.7
« Reply #21 on: September 04, 2012, 11:30:14 am »
What would be really useful is fixing Thor so that it can be built with Clang.
Indeed. I need to reorganize bigger parts of the Triangulation code, it may take some time until I find a clean solution.

C++11 with clang on Mac indeed needs libc++ to work. With SFML (§C++11) you can simply edit your cmake cache; in fact the user should not have to edit any files. Something similar can probably be done in Thor.
Okay, good to know. It would still be interesting to recognize Clang automatically, but I don't know how (there is no corresponding CMake variable).

Anyway, it sucks completely that CMake, claimed to be a cross-platform make tool, always requires compiler-specific case differentiations in order to work correctly. This partially defeats its original purpose...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Thor 2.0 cmake build error OS X 10.7
« Reply #22 on: September 04, 2012, 12:27:35 pm »
Quote
It would still be interesting to recognize Clang automatically, but I don't know how (there is no corresponding CMake variable).
You can check the compiler ID (CMAKE_COMPILER_ID?).
Laurent Gomila - SFML developer

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: Thor 2.0 cmake build error OS X 10.7
« Reply #23 on: September 04, 2012, 12:53:39 pm »
If you have plenty of time you could open on issue on Apple's bug tracker. However if you don't want to I would totally understand as it took them one whole year to answer one of my issue, and by answer I mean "we won't fix this"...
First I'm trying to load a texture without using SFML to see what happens. I must have forgotten something though because for now I only get a white square on a red background ::) . Once it works I'll test with much bigger sizes. If anyone sees what's wrong here...
    // init function
    glClearColor(1, 0, 0, 1);
   
    unsigned width = 128;
    unsigned heigth = 128;
    unsigned char *data = malloc(width * heigth * 4);
    assert(data != NULL);
   
    for (unsigned x = 0; x < width;x++)
    {
        for (unsigned y = 0; y < heigth;y++)
        {
            if ((y * width + x) % 2 == 0)
            {
                data[(y * width + x) * 4 + 0] = 0;
                data[(y * width + x) * 4 + 1] = 0;
                data[(y * width + x) * 4 + 2] = 255;
                data[(y * width + x) * 4 + 3] = 255;
            }
            else
            {
                data[(y * width + x) * 4 + 0] = 255;
                data[(y * width + x) * 4 + 1] = 0;
                data[(y * width + x) * 4 + 2] = 0;
                data[(y * width + x) * 4 + 3] = 255;
            }
        }
    }
   
    glEnable(GL_TEXTURE_2D);
    glGenTextures(1, &textureId);
    glBindTexture(GL_TEXTURE_2D, textureId);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, heigth, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
 

    // draw function
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   
    glBindTexture(GL_TEXTURE_2D, textureId);
   
    glPushMatrix();
    glTranslatef(0.1, 0.1, 0);
    glScalef(0.8, 0.8, 0.8);
   
    glBegin(GL_QUADS);
    glTexCoord2f(0.0f, 0.0f); glVertex2f(-1.0f, -1.0f);  // Bottom Left Of The Texture and Quad
    glTexCoord2f(1.0f, 0.0f); glVertex2f( 1.0f, -1.0f);  // Bottom Right Of The Texture and Quad
    glTexCoord2f(1.0f, 1.0f); glVertex2f( 1.0f,  1.0f);  // Top Right Of The Texture and Quad
    glTexCoord2f(0.0f, 1.0f); glVertex2f(-1.0f,  1.0f);  // Top Left Of The Texture and Quad
    glEnd();
   
    glPopMatrix();
   
    [[self.glView openGLContext] flushBuffer];
 
Want to play movies in your SFML application? Check out sfeMovie!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0 cmake build error OS X 10.7
« Reply #24 on: September 04, 2012, 06:38:25 pm »
Laurent, thanks for the hint.

Ceylo, can you tell me what the following CMake code outputs for Clang?
message("CMake compiler = [${CMAKE_CXX_COMPILER}]")
message("CMake compiler ID = [${CMAKE_CXX_COMPILER_ID}]")

Concerning the OpenGL code, you don't call glMatrixMode(). And I think, also glLoadIdentity() before other transforms is necessary.
« Last Edit: September 04, 2012, 06:42:52 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: Thor 2.0 cmake build error OS X 10.7
« Reply #25 on: September 04, 2012, 08:35:59 pm »
CMake outputs this:
Code: [Select]
CMake compiler = [/usr/bin/c++]
CMake compiler ID = [Clang]

As for the OpenGL code... I tried what you said (although I'm not sure where to put these calls) but I still get a white square instead of my texture:
glClearColor(1, 0, 0, 1);

unsigned width = 128;
unsigned heigth = 128;
unsigned char *data = malloc(width * heigth * 4);
assert(data != NULL);

for (unsigned x = 0; x < width;x++)
{
    for (unsigned y = 0; y < heigth;y++)
    {
        if ((y * width + x) % 2 == 0)
        {
            data[(x * heigth + y) * 4 + 0] = 0;
            data[(x * heigth + y) * 4 + 1] = 0;
            data[(x * heigth + y) * 4 + 2] = 255;
            data[(x * heigth + y) * 4 + 3] = 255;
        }
        else
        {
            data[(x * heigth + y) * 4 + 0] = 255;
            data[(x * heigth + y) * 4 + 1] = 0;
            data[(x * heigth + y) * 4 + 2] = 0;
            data[(x * heigth + y) * 4 + 3] = 255;
        }
    }
}

glEnable(GL_TEXTURE_2D);
glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_2D, textureId);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, heigth, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glBindTexture(GL_TEXTURE_2D, textureId);

glRotatef(1, 0, 0, 5);
glPushMatrix();
glTranslatef(0.1, 0.1, 0);
glScalef(0.8, 0.8, 0.8);

glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex2f(-1.0f, -1.0f);  // Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex2f( 1.0f, -1.0f);  // Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex2f( 1.0f,  1.0f);  // Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex2f(-1.0f,  1.0f);  // Top Left Of The Texture and Quad
glEnd();

glPopMatrix();

[[self.glView openGLContext] flushBuffer];

After checking the OpenGL errors I noticed it says "GL_INVALID_OPERATION, the specified operation is not allowed in the current state" (ok I copied SFML glCheck function ::) ) on the glEnd(); call but I don't know why...
Want to play movies in your SFML application? Check out sfeMovie!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Thor 2.0 cmake build error OS X 10.7
« Reply #26 on: September 04, 2012, 09:54:30 pm »
Maybe you can post your full code so that we can test it?
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0 cmake build error OS X 10.7
« Reply #27 on: September 05, 2012, 12:33:38 am »
CMake outputs this:
Code: [Select]
CMake compiler = [/usr/bin/c++]
CMake compiler ID = [Clang]
Thanks, this allows me to check for "Clang" in my CMake scripts. I also heard they might change the ID in the future, but well, I don't have a better option ;)

Just to make sure Clang 3.1's problem is really related to recursive iterator types: Could you compile the following minimal code and tell me if there are error messages (and which ones)?
#include <list>

struct Triangle
{
    std::list<Triangle>::iterator i;
};

int main() {}
With the online compiler of Clang 3.0, the code compiles.
« Last Edit: September 05, 2012, 01:57:00 am by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: Thor 2.0 cmake build error OS X 10.7
« Reply #28 on: September 05, 2012, 02:24:18 am »
Just to make sure Clang 3.1's problem is really related to recursive iterator types: Could you compile the following minimal code and tell me if there are error messages (and which ones)?
It does compile fine without any error/warning message.
Want to play movies in your SFML application? Check out sfeMovie!

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: Thor 2.0 cmake build error OS X 10.7
« Reply #29 on: September 05, 2012, 02:42:44 am »
And here's a fully "working" sample code based on GLUT: http://pastebin.com/arkhyg7q
Want to play movies in your SFML application? Check out sfeMovie!

 

anything