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

Author Topic: Strange OpenGL bug thingy and problems  (Read 2276 times)

0 Members and 1 Guest are viewing this topic.

JunkerKun

  • Newbie
  • *
  • Posts: 35
    • View Profile
Strange OpenGL bug thingy and problems
« 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?

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Strange OpenGL bug thingy and problems
« Reply #1 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Strange OpenGL bug thingy and problems
« Reply #2 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).
Laurent Gomila - SFML developer

JunkerKun

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Strange OpenGL bug thingy and problems
« Reply #3 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.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Strange OpenGL bug thingy and problems
« Reply #4 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.

JunkerKun

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Strange OpenGL bug thingy and problems
« Reply #5 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.