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

Author Topic: does SFML 1.6 support OpenGL 4.0 context?  (Read 2631 times)

0 Members and 1 Guest are viewing this topic.

Fantasy

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Email
does SFML 1.6 support OpenGL 4.0 context?
« on: January 23, 2012, 08:41:33 pm »
Hello guys
I was just wondering does SFML support window mode for OpenGL 4.0 context?
I heard that SFML uses OpenGL 1.1 context. I'm just starting to learn OpenGL and I was wondering can use both OpenGL 4.0 and SFML 1.6 without any problem?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
does SFML 1.6 support OpenGL 4.0 context?
« Reply #1 on: January 23, 2012, 09:51:13 pm »
Nop, you'll need SFML 2.0 to be able to use contexts >= 3.0.
Laurent Gomila - SFML developer

Fantasy

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Email
does SFML 1.6 support OpenGL 4.0 context?
« Reply #2 on: January 24, 2012, 11:20:43 am »
ok i have a OpenGL question.
Now as far as i know functions like glBegin, glEnd, glVertex3f, and glColor3f are not part of OpenGL 4.0. Now if i try to use them with window Context 4.0 they work. Shouldn't function like this give me some kind of error or something because they are not a part of OpenGL 4.0, so why are they working?

Isn't window Context 4.0 means that I'm using OpenGL 4.0 function ?
And how do i differentiate between OpenGL old function and OpenGL new functions ?

Code: [Select]

#include <SFML\Graphics.hpp>
#include <SFML\Window.hpp>
#include <SFML\OpenGL.hpp>
#include <iostream>

int main()
{
sf::Window Window(sf::VideoMode(800, 600, 32), "Game", sf::Style::Close, sf::ContextSettings(24, 8, 16, 4, 0));

glClearDepth(1.f);
glClearColor(0.f, 0.f, 0.f, 0.f);

// Enable Z-buffer read and write
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);

// Setup a perspective projection
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.f, 1.f, 1.f, 500.f);

std::cout<<Window.GetSettings().MajorVersion;
std::cout<<Window.GetSettings().MinorVersion;

while(Window.IsOpen())
{
sf::Event Event;
while (Window.PollEvent(Event))
{
if (Event.Type == sf::Event::Closed)
Window.Close();

if (Event.Type == sf::Event::Resized)
glViewport(0, 0, Event.Size.Width, Event.Size.Height);
}

Window.SetActive();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.f, 0.f, -200.f);

glBegin(GL_QUADS);

glVertex3f(-50.f, -50.f, -50.f);
glVertex3f(-50.f,  50.f, -50.f);
glVertex3f( 50.f,  50.f, -50.f);
glVertex3f( 50.f, -50.f, -50.f);

glVertex3f(-50.f, -50.f, 50.f);
glVertex3f(-50.f,  50.f, 50.f);
glVertex3f( 50.f,  50.f, 50.f);
glVertex3f( 50.f, -50.f, 50.f);

glVertex3f(-50.f, -50.f, -50.f);
glVertex3f(-50.f,  50.f, -50.f);
glVertex3f(-50.f,  50.f,  50.f);
glVertex3f(-50.f, -50.f,  50.f);

glVertex3f(50.f, -50.f, -50.f);
glVertex3f(50.f,  50.f, -50.f);
glVertex3f(50.f,  50.f,  50.f);
glVertex3f(50.f, -50.f,  50.f);

glVertex3f(-50.f, -50.f,  50.f);
glVertex3f(-50.f, -50.f, -50.f);
glVertex3f( 50.f, -50.f, -50.f);
glVertex3f( 50.f, -50.f,  50.f);

glVertex3f(-50.f, 50.f,  50.f);
glVertex3f(-50.f, 50.f, -50.f);
glVertex3f( 50.f, 50.f, -50.f);
glVertex3f( 50.f, 50.f,  50.f);

glEnd();
Window.Display();
}
return 0;
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
does SFML 1.6 support OpenGL 4.0 context?
« Reply #3 on: January 24, 2012, 11:32:59 am »
SFML always creates a compatibility context, because it internally needs these deprecated functions.
Laurent Gomila - SFML developer

Fantasy

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Email
does SFML 1.6 support OpenGL 4.0 context?
« Reply #4 on: January 24, 2012, 12:16:16 pm »
ok thank you very much.
I'm sorry for asking so many newbie question. I just have few more.

ok so why do i need these files and what is the use of them ?

gl.h
glu.h

I opened both gl.h and glu.h and they ware dated for 1995 and 1996 and they are version 4. why are we using old files? and is there newer versions? and what are they used for ?

and what is the use of GLEW library? and do i need it to create OpenGL application?

finally what exactly do i need to do to use the latest version of OpenGL which is 4.2?

all I know is I have to create a Context and set both MajorVersion to 4 and MinorVersion to 2 and use the latest OpenGL functions.

thank you very much you ware very helpful :)

 

anything