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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - inzombiak

Pages: [1]
1
General / iOS Crash
« on: May 06, 2016, 06:28:33 pm »
I recently started trying to port my game to iOS. At first I couldn't event get SFML to run (I made a forum post about that issue here http://en.sfml-dev.org/forums/index.php?topic=20273.0, but I managed to get it to work. Now I've run into an odd issue, my game opens and runs the first time with the following errors:

An internal OpenGL call failed in Texture.cpp (64) : GL_INVALID_ENUM, an unacceptable value has been specified for an enumerated argument
An internal OpenGL call failed in Texture.cpp (556) : GL_INVALID_ENUM, an unacceptable value has been specified for an enumerated argument

These errors are somehow related to the GL context creation but I cant figure out where and how. Even though I get the errors the game runs fine.
After I close the game and open it again the game crashes after loading and starts printing these errors after the first two:

An internal OpenGL call failed in RenderTarget.cpp (98) : GL_INVALID_FRAMEBUFFER_OPERATION, the object bound to FRAMEBUFFER_BINDING is not "framebuffer complete"
An internal OpenGL call failed in RenderTarget.cpp (278) : GL_INVALID_FRAMEBUFFER_OPERATION, the object bound to FRAMEBUFFER_BINDING is not "framebuffer complete"

After this the RenderTarget.cpp (278) error is repeated. After I terminate the program, my phone becomes unresponsive and I need to restart it, if I dont it starts to get very very hot and I can't run the program again.

I should note that the game works fine on PC and Mac. Any help would be appreciated.

EDIT: I've tracked down the first known OpenGL issues, it occurs the instant a sf::Context is created and arises in GlContext::initalize()

void GlContext::initialize()
{
    // Activate the context
    setActive(true);

    // Retrieve the context version number
    int majorVersion = 0;
    int minorVersion = 0;

    // Try the new way first
    glGetIntegerv(GL_MAJOR_VERSION, &majorVersion);
    glGetIntegerv(GL_MINOR_VERSION, &minorVersion);

    if (glGetError() != GL_INVALID_ENUM)
    {
        m_settings.majorVersion = static_cast<unsigned int>(majorVersion);
        m_settings.minorVersion = static_cast<unsigned int>(minorVersion);
    }
    else
    {
        // Try the old way
        const GLubyte* version = glGetString(GL_VERSION);
        if (version)
        {
            // The beginning of the returned string is "major.minor" (this is standard)
            m_settings.majorVersion = version[0] - '0';
            m_settings.minorVersion = version[2] - '0';
        }
        else
        {
            // Can't get the version number, assume 1.1
            m_settings.majorVersion = 1;
            m_settings.minorVersion = 1;
        }
    }

    // 3.0 contexts only deprecate features, but do not remove them yet
    // 3.1 contexts remove features if ARB_compatibility is not present
    // 3.2+ contexts remove features only if a core profile is requested

    // If the context was created with wglCreateContext, it is guaranteed to be compatibility.
    // If a 3.0 context was created with wglCreateContextAttribsARB, it is guaranteed to be compatibility.
    // If a 3.1 context was created with wglCreateContextAttribsARB, the compatibility flag
    // is set only if ARB_compatibility is present
    // If a 3.2+ context was created with wglCreateContextAttribsARB, the compatibility flag
    // would have been set correctly already depending on whether ARB_create_context_profile is supported.

    // If the user requests a 3.0 context, it will be a compatibility context regardless of the requested profile.
    // If the user requests a 3.1 context and its creation was successful, the specification
    // states that it will not be a compatibility profile context regardless of the requested
    // profile unless ARB_compatibility is present.
   
    m_settings.attributeFlags = ContextSettings::Default;

    if (m_settings.majorVersion >= 3)
    {
        // Retrieve the context flags
        int flags = 0;
        glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
       
        if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
            m_settings.attributeFlags |= ContextSettings::Debug;

        if ((m_settings.majorVersion == 3) && (m_settings.minorVersion == 1))
        {
            m_settings.attributeFlags |= ContextSettings::Core;

            glGetStringiFuncType glGetStringiFunc = reinterpret_cast<glGetStringiFuncType>(getFunction("glGetStringi"));

            if (glGetStringiFunc)
            {
                int numExtensions = 0;
                glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);

                for (unsigned int i = 0; i < static_cast<unsigned int>(numExtensions); ++i)
                {
                    const char* extensionString = reinterpret_cast<const char*>(glGetStringiFunc(GL_EXTENSIONS, i));

                    if (std::strstr(extensionString, "GL_ARB_compatibility"))
                    {
                        m_settings.attributeFlags &= ~static_cast<Uint32>(ContextSettings::Core);
                        break;
                    }
                }
            }
        }
        else if ((m_settings.majorVersion > 3) || (m_settings.minorVersion >= 2))
        {
            // Retrieve the context profile
            int profile = 0;
            glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &profile);

            if (profile & GL_CONTEXT_CORE_PROFILE_BIT)
                m_settings.attributeFlags |= ContextSettings::Core;
        }
    }

    // Enable antialiasing if needed
    if (m_settings.antialiasingLevel > 0)
        glEnable(GL_MULTISAMPLE);
}
 

The issues I've tracked down are:
1.  glGetIntegerv(GL_MAJOR_VERSION, &majorVersion) and glGetIntegerv(GL_MINOR_VERSION, &minorVersion) set the values to 0, which means glGetString(GL_VERSION) is called
and the value received is "OpenGL ES 2.0 Apple A9 GPU - 77.14" and the proceeding operations set the major and minor versions to 31 and 53 respectively.
2. glGetIntegerv(GL_CONTEXT_FLAGS, &flags) returns the error GL_INVALID_ENUM.

2
General / Re: Black Screen [iOS]
« on: May 05, 2016, 01:48:30 pm »
Thanks for the reply.
I'm aware of that, but it should still display something before the program exits right? I've tried the same code in a "while(true)" loop with  the clear/draw/display steps, but it didnt help. I started from scratch, but now I get a "An internal OpenGL call failed in RenderTarget.cpp (355) : GL_INVALID_ENUM, an unacceptable value has been specified for an enumerated argument" error at rw.display(). At first I was getting the same error in Texture.cpp, but after updating the libjpeg.a file for arm64, that one went away.

EDIT: Never mind, still get the Texture.cpp error after calling rw.clear(sf::Color::Red). The error I get is
"An internal OpenGL call failed in Texture.cpp (556) : GL_INVALID_ENUM, an unacceptable value has been specified for an enumerated argument"

EDIT 2: Managed to fix the errors by adding this line #import <OpenGLES/ES2/gl.h>, still getting a black screen.

Edit 3: Got it working. Turns out you HAVE to poll for events on iOS or at least that's what fixed it for me. Here's my code in case anyone needs it in the future.

#import <iostream>
#import <OpenGLES/ES2/gl.h>
#include <SFML/Main.hpp>
#include <SFML/Graphics.hpp>

#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>


int main(int argc, char * argv[])
{
    sf::RenderWindow rw(sf::VideoMode(700, 1334), "Hi", sf::Style::Fullscreen ,sf::ContextSettings(32));
    bool running = true;
    sf::RectangleShape rect;
    rect.setSize(sf::Vector2f(50, 50));
    rect.setPosition(sf::Vector2f(100, 100));
    rect.setFillColor(sf::Color::Green);
   
    while (running)
    {
        // handle events
        sf::Event event;
        while (rw.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                // end the program
                running = false;
            }
            else if (event.type == sf::Event::Resized)
            {
                // adjust the viewport when the window is resized
                glViewport(0, 0, event.size.width, event.size.height);
            }
        }
       
        rw.clear(sf::Color::Red);
       
        rw.draw(rect);
       
        rw.display();

    }
    return 0;
}

3
General / Black Screen [iOS] [SOLVED]
« on: May 04, 2016, 05:56:07 pm »
I've been working with SFML for a while now and I love it. I recently decided to test it out on iOS and while I know its not fully functional I wanted to see how feasible it was.
I read the forums and managed to compile SFML and get it working. The problem is, the screen on my iPhone goes black.

Here is the code I have.
#import <iostream>
#include <SFML/Main.hpp>
#include <SFML/Graphics.hpp>

int main(int argc, char * argv[])
{

    std::cout << "HELLo" << std::endl;

    sf::RenderWindow rw;
    rw.create(sf::VideoMode(700, 1334), "Hi");
    rw.setPosition(sf::Vector2i(50, 50));
    rw.clear(sf::Color::Red);
    rw.display();

    sf::RectangleShape rect;
    rect.setSize(sf::Vector2f(50, 50));
    rect.setPosition(sf::Vector2f(100, 100));
    rect.setFillColor(sf::Color::Green);

    rw.draw(rect);
    rw.display();

    return 0;
}
 


Anyone know what I'm doing wrong? I dont get any errors and the cout works.

Pages: [1]