Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: glew and glfw error

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2013
    Posts
    27

    glew and glfw error

    This code

    #include <cstdio>
    #include <cstdlib>
    #include <iostream>
    #define GLEW_STATIC
    #include <GL/glew.h>
    #include <GL/glfw3.h>


    int main(void)
    {
    GLFWwindow* window;

    // Initialize the library
    if (!glfwInit())
    return -1;

    // Create a windowed mode window and its OpenGL context
    window = glfwCreateWindow(320, 240, "Treball Recerca", NULL, NULL);
    if (!window)
    {
    glfwTerminate();
    return -1;
    }

    // Make the window's context current
    glfwMakeContextCurrent(window);

    //Start of GLEW thing
    glewExperimental = GL_TRUE;
    glewInit();


    GLuint vertexBuffer;
    glGenBuffers( 00001, &vertexBuffer );

    printf( "%u\n", vertexBuffer );
    //End of GLEW thing

    // Loop until the user closes the window
    while (!glfwWindowShouldClose(window))
    {
    // Render here


    // Swap front and back buffers
    glfwSwapBuffers(window);

    // Poll for and process events
    glfwPollEvents();
    }

    glfwTerminate();
    return 0;
    }

    Runs well.

    But this:

    #include <cstdio>
    #include <cstdlib>
    #include <iostream>
    #define GLEW_STATIC
    #include <GL/glew.h>
    #include <GL/glfw3.h>




    int main()
    {
    glfwInit();
    glewExperimental = GL_TRUE;
    glewInit();

    GLuint vertexBuffer;
    glGenBuffers( 1, &vertexBuffer );

    printf( "%u\n", vertexBuffer );


    while( glfwGetWindowParam( GLFW_OPENED ) )
    {
    glfwSwapBuffers();
    if ( glfwGetKey( GLFW_KEY_ESC ) == GLFW_PRESS )
    break;
    }

    glfwOpenWindowHint( GLFW_OPENGL_VERSION_MAJOR, 3 );
    glfwOpenWindowHint( GLFW_OPENGL_VERSION_MINOR, 2 );
    glfwOpenWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );

    glfwOpenWindowHint( GLFW_WINDOW_NO_RESIZE, GL_TRUE );
    glfwOpenWindow( 800, 600, 0, 0, 0, 0, 0, 0, GLFW_WINDOW );
    glfwSetWindowTitle( "OpenGL" );


    glfwTerminate();


    return 0;
    }

    Is giving me this:

    C:\Documents and Settings\marc\Escritorio\C++\test glfw\main.cpp||In function 'int main()':|
    C:\Documents and Settings\marc\Escritorio\C++\test glfw\main.cpp|21|error: 'GLFW_OPENED' was not declared in this scope|
    C:\Documents and Settings\marc\Escritorio\C++\test glfw\main.cpp|21|error: 'glfwGetWindowParam' was not declared in this scope|
    C:\Documents and Settings\marc\Escritorio\C++\test glfw\main.cpp|23|error: too few arguments to function 'void glfwSwapBuffers(GLFWwindow*)'|
    c:\archivos de programa\codeblocks\mingw\bin\..\lib\gcc\mingw32\4 .7.1\..\..\..\..\include\GL\glfw3.h|2171|note: declared here|
    C:\Documents and Settings\marc\Escritorio\C++\test glfw\main.cpp|24|error: 'GLFW_KEY_ESC' was not declared in this scope|
    C:\Documents and Settings\marc\Escritorio\C++\test glfw\main.cpp|28|error: 'GLFW_OPENGL_VERSION_MAJOR' was not declared in this scope|
    C:\Documents and Settings\marc\Escritorio\C++\test glfw\main.cpp|28|error: 'glfwOpenWindowHint' was not declared in this scope|
    C:\Documents and Settings\marc\Escritorio\C++\test glfw\main.cpp|29|error: 'GLFW_OPENGL_VERSION_MINOR' was not declared in this scope|
    C:\Documents and Settings\marc\Escritorio\C++\test glfw\main.cpp|32|error: 'GLFW_WINDOW_NO_RESIZE' was not declared in this scope|
    C:\Documents and Settings\marc\Escritorio\C++\test glfw\main.cpp|33|error: 'GLFW_WINDOW' was not declared in this scope|
    C:\Documents and Settings\marc\Escritorio\C++\test glfw\main.cpp|33|error: 'glfwOpenWindow' was not declared in this scope|
    C:\Documents and Settings\marc\Escritorio\C++\test glfw\main.cpp|34|error: cannot convert 'const char*' to 'GLFWwindow*' for argument '1' to 'void glfwSetWindowTitle(GLFWwindow*, const char*)'|
    ||=== Build finished: 11 errors, 0 warnings (0 minutes, 0 seconds) ===|

    Wich code is better, and if the better is the second, how i could fix it? I linked this libraries:

    glew32.lib, glew32s.lib, libglfw.a, libopengl32.a and glew32s is in the top of the list.

    So much thank you to everyone,


    Marc
    Last edited by Marc Colomé; 07-08-2013 at 12:36 PM.

  2. #2
    Junior Member Newbie
    Join Date
    Jul 2013
    Posts
    27
    #include <GL/glfw3.h>
    #include <stdlib.h>
    #include <stdio.h>

    static void error_callback(int error, const char* description)
    {
    fputs(description, stderr);
    }
    static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
    {
    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
    glfwSetWindowShouldClose(window, GL_TRUE);
    }
    int main(void)
    {
    GLFWwindow* window;
    glfwSetErrorCallback(error_callback);
    if (!glfwInit())
    exit(EXIT_FAILURE);
    window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL);
    if (!window)
    {
    glfwTerminate();
    exit(EXIT_FAILURE);
    }
    glfwMakeContextCurrent(window);
    glfwSetKeyCallback(window, key_callback);
    while (!glfwWindowShouldClose(window))
    {
    float ratio;
    int width, height;
    glfwGetFramebufferSize(window, &width, &height);
    ratio = width / (float) height;
    glViewport(0, 0, width, height);
    glClear(GL_COLOR_BUFFER_BIT);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-ratio, ratio, -1.f, 1.f, 1.f, -1.f);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glRotatef((float) glfwGetTime() * 50.f, 0.f, 0.f, 1.f);
    glBegin(GL_TRIANGLES);
    glColor3f(1.f, 0.f, 0.f);
    glVertex3f(-0.6f, -0.4f, 0.f);
    glColor3f(0.f, 1.f, 0.f);
    glVertex3f(0.6f, -0.4f, 0.f);
    glColor3f(0.f, 0.f, 1.f);
    glVertex3f(0.f, 0.6f, 0.f);
    glEnd();
    glfwSwapBuffers(window);
    glfwPollEvents();
    }
    glfwDestroyWindow(window);
    glfwTerminate();
    exit(EXIT_SUCCESS);
    }

    This code works, wich is better? This or the other?

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2013
    Posts
    27
    solved. I have a different glfw version

    sorry for the issues

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •