SFML community forums

Help => General => Topic started by: JunkerKun on January 02, 2015, 03:32:44 pm

Title: Strange OpenGL bug thingy and problems
Post by: JunkerKun on January 02, 2015, 03:32:44 pm
I just hope anyone here uses SFML as a framework to make 3D games.
There are few problems I have.
First when I try to bind a texture with sf::Texture::bind, it gives me errors on the console. The texture gets binded anyway but that kinda bugs me since errors are bad.
Second is when I try to set normalization. It says "OpenGL error 1280".
And the third is not an error but some strange bahaviour. When I'm far away from a mesh it gives nive 1200 FPS. When I'm very close FPS drops down to 800. It's noticable on integrated Intel HD video chip. On GeForce 860M it drops down for 40 FPS.
Your thoughts on that?
Title: Re: Strange OpenGL bug thingy and problems
Post by: Ixrec on January 02, 2015, 03:52:59 pm
Like any other issue, we're going to need to see complete and minimal examples before we can do anything besides blind guessing.

Also, you can very easily google error 1280.  From the results I see, that error almost certainly means you made a mistake in your code somewhere.
Title: Re: Strange OpenGL bug thingy and problems
Post by: Laurent on January 02, 2015, 03:58:05 pm
Show code and exact error messages. A vague description of your problems won't help anyone to solve them.

Quote
And the third is not an error but some strange bahaviour. When I'm far away from a mesh it gives nive 1200 FPS. When I'm very close FPS drops down to 800.
More pixels are shown on screen, so it takes "longer". But a drop from 1200 FPS to 800 FPS is negligible, don't measure performances with FPS, especially when they are high, because FPS are not a linear scale (remember, they are 1/x).
Title: Re: Strange OpenGL bug thingy and problems
Post by: JunkerKun on January 02, 2015, 04:20:55 pm
Show code and exact error messages. A vague description of your problems won't help anyone to solve them.

Quote
And the third is not an error but some strange bahaviour. When I'm far away from a mesh it gives nive 1200 FPS. When I'm very close FPS drops down to 800.
More pixels are shown on screen, so it takes "longer". But a drop from 1200 FPS to 800 FPS is negligible, don't measure performances with FPS, especially when they are high, because FPS are not a linear scale (remember, they are 1/x).
Ah, that would be the logical case, yes, but I have another "room" mesh that already takes the whole screen. Also, it happens when I'm REALLY close to the first mesh, when its single triangle takes the whole screen.
And delta time gets bigger as well, not only FPS.
Title: Re: Strange OpenGL bug thingy and problems
Post by: Ixrec on January 02, 2015, 04:25:37 pm
Well, obviously deltaTime goes up when FPS go down, they're inverses of each other.  It's still not a significant difference.  Like Laurent said, at FPS that high (or deltaTimes that low) these kinds of differences really don't mean anything other than you aren't drawing much yet.  Don't worry about it until you're falling below 60.

Still need minimal & complete examples for the real issues.
Title: Re: Strange OpenGL bug thingy and problems
Post by: JunkerKun on January 02, 2015, 04:35:11 pm
Well, obviously deltaTime goes up when FPS go down, they're inverses of each other.  It's still not a significant difference.  Like Laurent said, at FPS that high (or deltaTimes that low) these kinds of differences really don't mean anything other than you aren't drawing much yet.  Don't worry about it until you're falling below 60.

Still need minimal & complete examples for the real issues.
Okay then. Gotta stop worrying about FPS dropping from 1200 to 800 ^__^

As for examples:
bool GLManager::Render() {
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glMultMatrixf(camera->GetTransformationMatrix());

        float position[4] = {camera->GetPosition().x,camera->GetPosition().y,camera->GetPosition().z,1};
        glLightfv(GL_LIGHT0, GL_POSITION, position);

        glEnableClientState(GL_NORMALIZE);
        glEnableClientState(GL_VERTEX_ARRAY);
        glEnableClientState(GL_NORMAL_ARRAY);
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
        std::vector<ObjectClass*>* objects = coreManager->GetObjectsManager()->GetObjectsToDraw();
        for (int i=0;i<objects->size();i++) {
                ObjectClass* object = objects->at(i);
                object->Render();
        };
        glDisableClientState(GL_VERTEX_ARRAY);
        glDisableClientState(GL_NORMAL_ARRAY);
        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
        glDisableClientState(GL_NORMALIZE);
        return true;
};

This thing ives me an error on normalization.

bool SkinnedMeshClass::Render() {
        if (!visible) return true;
        msModel* mesh = static_cast<SkinnedMeshDataClass*>(meshData)->GetMesh();
        glPushMatrix();
        glMultMatrixf(transformationMatrix);
        std::vector<SkinnedMeshGroup*>* groups = static_cast<SkinnedMeshDataClass*>(meshData)->GetGroups();
        for (int i=0;i<groups->size();i++) {
                sf::Texture* texture = groups->at(i)->texture;
                ms3d_material_t* material = groups->at(i)->material;
                bool hasTexture = (texture!=NULL);
                bool hasMaterial = (material!=NULL);
                if (hasTexture) {
                        sf::Texture::bind(texture);
                };
                if (hasMaterial) {
                        if (material->mode & HASALPHA) {
                                glEnable(GL_BLEND);
                                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                        } else {
                                glDisable(GL_BLEND);
                        };
                };
                std::vector<sf::Vector2f>* texCoords = &groups->at(i)->texCoords;
                std::vector<unsigned short>* indices = &groups->at(i)->indices;
                glVertexPointer(3, GL_FLOAT, 0, groups->at(i)->vertexArray);
                glNormalPointer(GL_FLOAT, 0, groups->at(i)->normalArray);
                glTexCoordPointer(2, GL_FLOAT, 0, &texCoords->at(0));
                glDrawElements(GL_TRIANGLES, indices->size(), GL_UNSIGNED_SHORT, &indices->at(0));
        };
        sf::Texture::bind(NULL);
        glPopMatrix();
        return true;
};

This thing gives me 1280 error.