Opengl newer version

Hi,
my computer is a few years old, I have developed quite a bit of software using it seems version 1.0 of opengl. I think that is what comes with windows, I cannot remember how I installed the sdk, if I did.

I want to start using vbo’s, but my graphics card will not support 4.5. I would like to start with 3.1, where can I down load that? I am assuming when I install that it will fix this error
error LNK2001: unresolved external symbol __imp___glewGenBuffers

[QUOTE=macsam;1292799]my computer is a few years old, I have developed quite a bit of software using it seems version 1.0 of opengl.
I think that is what comes with windows, I cannot remember how I installed the sdk, if I did.

I want to start using vbo’s, but my graphics card will not support 4.5.
I would like to start with 3.1, where can I down load that?[/QUOTE]

Just install the latest graphics drivers for your GPU. They implement the OpenGL API. See:

[ul]
[li]Getting_Started#Windows (OpenGL Wiki) [/li][/ul]

I am assuming when I install that it will fix this error
error LNK2001: unresolved external symbol __imp___glewGenBuffers

No, this comes from the GLEW extension loader library. This layers on top of OpenGL to give you a simple mechanism to load and expose all of the core and extension APIs supported by your graphics drivers. Related: see this thread and this one.

Thanks for your help.

It seems my laptop will not allow me to install 4.6. The graphics card is a GeForce GT 640M.

I have found a version 3.2 sample and would like to use that. ( Tutorial2: VAOs, VBOs, Vertex and Fragment Shaders (C / SDL) - OpenGL Wiki ).

I am stuck on the first hurdle - I cannot find GL3/gl3.h and possible the opengl library that goes with it.

Any pointers gratefully appreciated.

MacSam

should I be thinking of DirectX, is it easier?

[QUOTE=macsam;1292824]I have found a version 3.2 sample and would like to use that. ( Tutorial2: VAOs, VBOs, Vertex and Fragment Shaders (C / SDL) - OpenGL Wiki ).

I am stuck on the first hurdle - I cannot find GL3/gl3.h and possible the opengl library that goes with it.[/QUOTE]

This thread describes gl3.h. It’s not a standard header, but rather a paired down version of “gl.h” that tries to remove the declarations for much of the old pre-OpenGL 3.0 functionality.

As the thread mentions, you can just ignore this header and use GLEW to declare and load your OpenGL functions and other declarations. For more on that, see OpenGL Loading Library in the OpenGL wiki.

Here’s a short, stand-alone GLEW + GLUT test program to help you get started:


//------------------------------------------------------------------------------
//  Stand-alone GLUT Test Program Shell
//------------------------------------------------------------------------------

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GL/glut.h>

//-----------------------------------------------------------------------

void checkGLError( const char hdr[] )
{
    bool  found = false;
    GLint err;

    while ( (err = glGetError()) != GL_NO_ERROR )
    {
        fprintf(stderr, "GL ERROR %s (at %s)
", gluErrorString(err), hdr);
        found = true;
    }

    if ( found )
    {
        exit(1);
    }
}

//-----------------------------------------------------------------------

void init()
{
    //------------------------------------------------------------
    // Put your GL resource creation here
    //   (buffer objects, textures, etc.)
    //------------------------------------------------------------

    checkGLError( "init()" );
}

//-----------------------------------------------------------------------

void reshape( int width, int height )
{
    glViewport(0, 0, width, height);
}

//-----------------------------------------------------------------------

void display()
{
    // Clear screen
    glClearColor( 0.1f, 0.1f, 0.43f, 1.0f );
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    // Load up PROJECTION and MODELVIEW
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-2,2,-2,2,-2,2);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    //------------------------------------------------------------
    // Put your GL draw calls here.
    //------------------------------------------------------------

    // Swap
    glutSwapBuffers();

    // Cause display() to be called again.
    glutPostRedisplay();
    checkGLError( "display()" );
}

//-----------------------------------------------------------------------

void keyboard( unsigned char key, int x, int y )
{
    switch (key)
    {
        case 27:         // ESC quits
            exit(0);
            break;
    }
}

int main( int argc, char** argv )
{
    // Init GLUT
    glutInit( &argc, argv );
    glutInitDisplayMode(  GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE  );
    glutCreateWindow( argv[0] );

    glutKeyboardFunc( keyboard );
    glutDisplayFunc( display );
    glutReshapeFunc( reshape );

    glutReshapeWindow( 400,400 );

    // Init GLEW
    GLenum err = glewInit();
    if ( err != GLEW_OK )
    {
        // Problem: glewInit failed, something is seriously wrong.
        fprintf( stderr, "Error: %s
", glewGetErrorString(err) );
        exit(1);
    }

    printf( "GL_RENDERER = %s
", glGetString( GL_RENDERER) );

    init();

    glutMainLoop();
    return 0;
}

thank you, I appreciate your post.

Hi,

I still have this problem: error LNK2001: unresolved external symbol __imp___glewGenBuffers
I use MFC static in a static library. I have the glew32sd.lib for the debug mode. I have added it to additional dependencies but still have the problem. I did try adding the glew.c to the project but it came up a lot of errors relating to DLL’s.

Any help gratefully appreciated

[QUOTE=macsam;1292838]I still have this problem:

error LNK2001: unresolved external symbol __imp___glewGenBuffers

I use MFC static in a static library. I have the glew32sd.lib for the debug mode. [/QUOTE]

See:

[ul]
[li]The OpenGL Extension Wrangler Library: Installing, and Building your Project with GLEW (read everything here) [/li][li]undefined reference to ‘_imp___glewGenBuffers’ [/li][li]Linker error with glew when library is statically linked [/li][/ul]

If this doesn’t resolve your problem, please describe exactly:

[ol]
[li]what compiler you’re compiling and linking with [/li][li]what symbols you are defining when you compile, and [/li][li]exactly what libraries you are linking with (and the order that you are linking them). [/li][/ol]

Other questions:

[ol]
[li]You are linking with glew32sd.lib, so you are trying to link with GLEW statically, correct? [/li][li]Did you define GLEW_STATIC when you compiled? [/li][li]Did you verify that you are not linking with any other GLEW libraries? [/li][li]Did you verify that you are linking with the GLEW library of the correct architecture (32-bit or 64-bit)? [/li][li]Did you verify that you are trying to compile/link with MSVC and not MinGW? [/li][li]Did you verify that you are linking with the GLEW library before opengl32.lib? [/li][/ol]

Thank you again for your help

I eventualy got this to work, thanks to the help here and jamie King.( OpenGL Compiling GLSL Shaders - YouTube)

I hope it helps someone.


//I needed to add this:
#include <GL/gl.h> 
#include <GL/glu.h>
#include <GL/glext.h>
#include <GL/glcorearb.h>



PFNGLGENBUFFERSPROC glGenBuffers;
PFNGLBINDBUFFERPROC glBindBuffer;
PFNGLBUFFERDATAPROC glBufferData;
PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
PFNGLBINDVERTEXARRAYAPPLEPROC glBindVertexArray;
PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
PFNGLCREATESHADERPROC glCreateShader;
PFNGLSHADERSOURCEPROC glShaderSource;
PFNGLCOMPILESHADERPROC glCompileShader;
PFNGLCREATEPROGRAMPROC glCreateProgram;
PFNGLATTACHSHADERPROC glAttachShader;
PFNGLLINKPROGRAMPROC glLinkProgram;
PFNGLUSEPROGRAMPROC glUseProgram;
PFNGLGETSHADERIVPROC glGetShaderiv;
PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;



void *GetAnyGLFuncAddress(const char *name)
{
	void *p = (void *)wglGetProcAddress(name);
	if (p == 0 ||
		(p == (void*)0x1) || (p == (void*)0x2) || (p == (void*)0x3) ||
		(p == (void*)-1))
	{
		HMODULE module = LoadLibraryA("opengl32.dll");
		p = (void *)GetProcAddress(module, name);
	}

	return p;
}

void SetUpProcs(void)
{
	glGenBuffers = (PFNGLGENBUFFERSPROC)GetAnyGLFuncAddress("glGenBuffers");
	glBindBuffer = (PFNGLBINDBUFFERPROC)GetAnyGLFuncAddress("glBindBuffer");
	glBufferData = (PFNGLBUFFERDATAPROC)GetAnyGLFuncAddress("glBufferData");
	glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)GetAnyGLFuncAddress("glGenVertexArrays");
	glBindVertexArray = (PFNGLBINDVERTEXARRAYAPPLEPROC)GetAnyGLFuncAddress("glBindVertexArray");
	glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)GetAnyGLFuncAddress("glEnableVertexAttribArray");
	glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)GetAnyGLFuncAddress("glVertexAttribPointer");
	glCreateShader = (PFNGLCREATESHADERPROC)GetAnyGLFuncAddress("glCreateShader");
	glShaderSource = (PFNGLSHADERSOURCEPROC)GetAnyGLFuncAddress("glShaderSource");
	glCompileShader = (PFNGLCOMPILESHADERPROC)GetAnyGLFuncAddress("glCompileShader");
	glCreateProgram = (PFNGLCREATEPROGRAMPROC)GetAnyGLFuncAddress("glCreateProgram");
	glAttachShader = (PFNGLATTACHSHADERPROC)GetAnyGLFuncAddress("glAttachShader");
	glLinkProgram = (PFNGLLINKPROGRAMPROC)GetAnyGLFuncAddress("glLinkProgram");
	glUseProgram = (PFNGLUSEPROGRAMPROC)GetAnyGLFuncAddress("glUseProgram");
	glGetShaderiv = (PFNGLGETSHADERIVPROC)GetAnyGLFuncAddress("glGetShaderiv");
	glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)GetAnyGLFuncAddress("glGetShaderInfoLog");


}

//this I got from msdn

HDC   ghDC;
HGLRC ghRC;

void oncreateOpenGLVBO(HWND hwnd)
{
	// PAINTSTRUCT    ps; 
	RECT rect;
	BOOL bError;
	DWORD dwErrorCode;
	GLenum GLenumError;
	bError = 0;

	ghDC = GetDC(hwndThrd);//hwnd

	bError = GetClientRect(hwndThrd, &rect);
	if (bError == 0)
		dwErrorCode = GetLastError();
	if (CSetupPixelFormatComplted == 'y')
	{
		ghRC = wglCreateContext(ghDC);
		bError = wglMakeCurrent(ghDC, ghRC);

		//createObjects( hwnd ); 
		initializeGLVBO(hwnd, rect.right, rect.bottom);
		return;
	}


	CSetupPixelFormatComplted = 'y';

	if (!bSetupPixelFormat(ghDC))
		PostQuitMessage(0);

	ghRC = wglCreateContext(ghDC);
	if (ghRC == NULL)
		ghRC = NULL;
	bError = wglMakeCurrent(ghDC, ghRC);


	

	GLenumError = glGetError();
	if (GLenumError != GL_NO_ERROR)
		OGLErrorCode(GLenumError);

	

	drawsceneVBO(hwnd);
	//initializeGLVBO(hwnd, rect.right, rect.bottom);

	// createObjects( hwnd ); aready created in InitializeGL above

}


This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.