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

Author Topic: OpenGL - Question concerning Image::bind() a bit  (Read 6003 times)

0 Members and 1 Guest are viewing this topic.

ravenheart

  • Full Member
  • ***
  • Posts: 148
    • View Profile
OpenGL - Question concerning Image::bind() a bit
« on: January 15, 2010, 11:02:55 am »
Hello, i wanted to create a billard-ball with a texture,

thats the code:

Code: [Select]

    GLUquadricObj* quadric;

    sf::Image img;
    img.LoadFromFile("10ball.jpg");
    img.Bind();
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {

        }

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


        quadric = gluNewQuadric();
        //gluQuadricNormals(quadric, GLU_SMOOTH);
        gluQuadricTexture(quadric, GL_TRUE);
        gluSphere(quadric, 30.0, 1000, 500);

        App.Display();
    }


but i can see the border of the texture.

Someone told me that cube-mapping might help.

I didnt really find out how i could do this, can someone help me?

It seems that Bind() decides the way it is mapped, what is standard and how can i change it?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
OpenGL - Question concerning Image::bind() a bit
« Reply #1 on: January 15, 2010, 11:07:39 am »
Quote
but i can see the border of the texture.

What does that mean? Can you show a screenshot?
Laurent Gomila - SFML developer

ravenheart

  • Full Member
  • ***
  • Posts: 148
    • View Profile
OpenGL - Question concerning Image::bind() a bit
« Reply #2 on: January 15, 2010, 11:37:28 am »
here u can see a screenshot, i hope u can understand my problem now


http://mstg.bplaced.net/Bildschirmfoto1.png

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
OpenGL - Question concerning Image::bind() a bit
« Reply #3 on: January 15, 2010, 11:47:15 am »
Call img.SetSmooth(false);

But you shouldn't use a sf::Image directly for 3D, SFML's textures are optimized for 2D rendering (they have no mipmaps, etc.).
Laurent Gomila - SFML developer

ravenheart

  • Full Member
  • ***
  • Posts: 148
    • View Profile
OpenGL - Question concerning Image::bind() a bit
« Reply #4 on: January 15, 2010, 12:06:48 pm »
o yeah that worked,

but what should i use instead of sf::Image?

the only alternative i found was

AUX_RGBImageRec

but it sounds quite difficult.

What is the standard for 3d?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
OpenGL - Question concerning Image::bind() a bit
« Reply #5 on: January 15, 2010, 12:19:27 pm »
I mean, use sf::Image for loading the image file, but then create your own OpenGL texture and fill it with the image's pixels.

This way you can setup your OpenGL texture properly for a 3D usage.

Take a look at the OpenGL sample from the SFML SDK, this is exactly what it does.
Laurent Gomila - SFML developer

ravenheart

  • Full Member
  • ***
  • Posts: 148
    • View Profile
OpenGL - Question concerning Image::bind() a bit
« Reply #6 on: January 15, 2010, 12:33:34 pm »
Thank u, i finally found the example =)