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

Author Topic: Need help to connect OpenGl project with SFML  (Read 3453 times)

0 Members and 1 Guest are viewing this topic.

linkorMariya

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Need help to connect OpenGl project with SFML
« on: April 07, 2016, 09:48:17 pm »
I have OpenGl project, but I can't connect it to sfml in any way, could someone help me to connect them?

#include <SFML/OpenGL.hpp>
#include <glut.h>

#include <cmath>

float f(float x, float y)
{
        return sin(x*y*0.0001)*100;
}

void display()
{
        glClear(GL_COLOR_BUFFER_BIT);
        for (float x = -480; x < 480; x += 10)
        {
                glBegin(GL_LINE_STRIP);
                for (float y = -480; y < 480; y += 10)
                        glVertex3f(x, y, f(x, y));
                glEnd();
        }
        for (float y = -480; y < 480; y += 10)
        {
                glBegin(GL_LINE_STRIP);
                for (float x = -480; x < 480; x += 10)
                        glVertex3f(x, y, f(x, y));
                glEnd();
        }
        glutSwapBuffers();
}

void timer(int = 0)
{
        display();
        glutTimerFunc(10, timer, 0);
}

int main(int argc, char **argv)
{
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
        glutInitWindowSize(480, 480);
        glutInitWindowPosition(20, 86);
        glutCreateWindow("3d plot");
        glClearColor(0, 0, 0, 1.0);

        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glFrustum(-100, 100, -100, 100, 100, 2000);
        glMatrixMode(GL_MODELVIEW);
        glTranslatef(0, 0, -800);
        glRotatef(-30, 1, 0, 0);
        glutDisplayFunc(display);
        timer();
        glutMainLoop();
}

#include <SFML/Graphics.hpp>
 
int main()
{
        sf::RenderWindow window(sf::VideoMode(800, 600), "sdfs");
 
        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }
 
                window.clear();

                window.display();
        }
 
        return 0;
}

I try to do this but only get errors such as screenshot in attachment. The project without sfml is completely working.
Sorry for my bad English
« Last Edit: April 07, 2016, 09:51:14 pm by linkorMariya »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Need help to connect OpenGl project with SFML
« Reply #1 on: April 08, 2016, 03:24:55 am »
Well, you have two main functions for a start.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: Need help to connect OpenGl project with SFML
« Reply #2 on: April 08, 2016, 05:52:50 am »
Looks like you don't have a proper driver for your graphics card installed.

Your basic OpenGL project works because you're using the version supported by MS's OpenGL driver (1.1 iirc).

SFML version isn't working because it needs a more recent version (I can't remember the specific version) or vendor-specific extensions not offered by the MS driver.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Need help to connect OpenGl project with SFML
« Reply #3 on: April 08, 2016, 09:14:09 am »
After you have installed a proper GPU driver, check out the official tutorial on OpenGL.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

linkorMariya

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Need help to connect OpenGl project with SFML
« Reply #4 on: April 08, 2016, 06:17:33 pm »
Looks like you don't have a proper driver for your graphics card installed.

Your basic OpenGL project works because you're using the version supported by MS's OpenGL driver (1.1 iirc).

SFML version isn't working because it needs a more recent version (I can't remember the specific version) or vendor-specific extensions not offered by the MS driver.
I have intalled it today, but this error still remains

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Need help to connect OpenGl project with SFML
« Reply #5 on: April 08, 2016, 06:38:10 pm »
Don't just focus on one answer and ignore the other comments. ;)

You have two main functions, how do you expect this to work?
Did you read the linked tutorial?
Do you understand what glut does?
Do you understand what SFML does?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

linkorMariya

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Need help to connect OpenGl project with SFML
« Reply #6 on: April 08, 2016, 06:58:07 pm »
Don't just focus on one answer and ignore the other comments. ;)

You have two main functions, how do you expect this to work?
Did you read the linked tutorial?
Do you understand what glut does?
Do you understand what SFML does?
Oh, I'am sorry for ignoring them, i've really focused only at last message. I have two projects with main functions, and i'am trying to build it in one with one main funtion in sfml window. Yes, i've read that thread before creating this topic, my English isn't so high, so may be i have missed something, but i dont think so. Yes, i understand what both of them do

P.s. I'm really grateful for all answers and will try not to ignore by focusing on other
« Last Edit: April 08, 2016, 07:00:44 pm by linkorMariya »

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: Need help to connect OpenGl project with SFML
« Reply #7 on: April 08, 2016, 07:09:34 pm »
If you got the same exact error message, then I don't think you installed the correct driver.

What graphics card are you using, and what driver did you install?

If I understand correctly, the above OpenGL/glut sample separately works, and the above SFML sample separately does not work. Am I correct? They are two separate programs?

linkorMariya

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Need help to connect OpenGl project with SFML
« Reply #8 on: April 08, 2016, 07:44:14 pm »
If you got the same exact error message, then I don't think you installed the correct driver.

What graphics card are you using, and what driver did you install?

If I understand correctly, the above OpenGL/glut sample separately works, and the above SFML sample separately does not work. Am I correct? They are two separate programs?
Yes, i have two C++ projects with SFML OpenGL, and with simple glut, which was downloaded from the offical site. First - shows error, second - works without any issues
« Last Edit: April 08, 2016, 07:47:28 pm by linkorMariya »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Need help to connect OpenGl project with SFML
« Reply #9 on: April 08, 2016, 08:26:36 pm »
You might want to update your SFML version to SFML 2.3.2. The message about SGSI_texture_edge_clamp you see was a bug that has been fixed.

Did you by any chance and for whatever reason copy the OpenGL32.dll into your project directory?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

linkorMariya

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Need help to connect OpenGl project with SFML
« Reply #10 on: April 08, 2016, 09:02:19 pm »
You might want to update your SFML version to SFML 2.3.2. The message about SGSI_texture_edge_clamp you see was a bug that has been fixed.

Did you by any chance and for whatever reason copy the OpenGL32.dll into your project directory?
i have already SFML 2.3.2

Oh, i really have it, after deleting this error was gone. Thanks great. But now i have another

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Need help to connect OpenGl project with SFML
« Reply #11 on: April 08, 2016, 10:11:02 pm »
Your new error message is just because it couldn't create with the settings you asked it to.
You asked for 32 bit depth but could only create 24 bit depth.
If you set it to 24-bit, this error should disappear (on your computer anyway).
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything