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

Author Topic: Using glew with sfml 2.0 problem  (Read 1663 times)

0 Members and 1 Guest are viewing this topic.

Vekta

  • Newbie
  • *
  • Posts: 2
    • View Profile
Using glew with sfml 2.0 problem
« on: June 07, 2011, 01:42:27 am »
Hello, i've been having some trouble setting up an OpenGl 3.2 context with sfml 2.0 and glew.

When i call glewInit() it retuns the error "Missing GL version". I've tried the same code using freeGLUT for the context and it worked perfectly. I can only deduce that im using SFML wrong somehow.

Here is the code

Code: [Select]
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <GL/glew.h>
#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#define WINDOW_TITLE_PREFIX "Chapter 2"


void Initialize(int, char*[]);
void InitWindow(void);


int main(int argc, char* argv[])
{
InitWindow();
Initialize(argc, argv);
exit(EXIT_SUCCESS);
}

void InitWindow()
{
sf::Window App(sf::VideoMode(800, 600, 32), "OpenGL");

}

void Initialize(int argc, char* argv[])
{

GLenum GlewInitResult;

glewExperimental = GL_TRUE;
GlewInitResult = glewInit();

if (GLEW_OK != GlewInitResult) {
fprintf(
stderr,
"ERROR: %s\n ",
glewGetErrorString(GlewInitResult)
);
exit(EXIT_FAILURE);
}

fprintf(
stdout,
"INFO: OpenGL Version: %s\n",
glGetString(GL_VERSION)
);
}


I'm probably being stupid and I apologize but any help is greatly appreciated!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Using glew with sfml 2.0 problem
« Reply #1 on: June 07, 2011, 07:56:56 am »
Quote
Code: [Select]
void InitWindow()
{
   sf::Window App(sf::VideoMode(800, 600, 32), "OpenGL");

}

Here you create a window, with an OpenGL context, and... it is destroyed immediately, before the function returns. Therefore when you call glewInit() you have no OpenGL context.
Laurent Gomila - SFML developer

Vekta

  • Newbie
  • *
  • Posts: 2
    • View Profile
Using glew with sfml 2.0 problem
« Reply #2 on: June 07, 2011, 10:22:03 am »
Ah of course, thank you

 

anything