开发者

OpenGL in Eclipse on Windows, Set-up help w/ Linking Error?

Using Eclipse 3.6.2, current version of CDT, current Cygwin tools and C++ (GCC) compiler. Linking -lglu32, -lglut32, -lopengl32.

I'm trying to get this environment set-up for OpenGL development and am running into linking errors that I've been unable to resolve. Current versions of the relevant opengl and glut libs and headers hav开发者_Python百科e been copied to C:\cygwin\lib and C:\cygwin\usr\include\w32api

For example while this compiles and links ..

#include <windows.h>

#include <GLES2/gl2.h>

#include <EGL/egl.h>

#include <GL/glut.h>

[...]

void display() {

    glClear( GL_COLOR_BUFFER_BIT ); /* Clear the screen with the clear color */

glBegin(GL_TRIANGLES);
    glVertex3f(-0.5,-0.5,0.0);
    glVertex3f(0.5,0.0,0.0);
    glVertex3f(0.0,0.5,0.0);
glEnd();

glutSwapBuffers(); 

}

the following throws undefined reference errors on glVertextAttribPointer, glEnableVertexAttribArray and glDisableVertexAttribArray.

void display() {

glClear( GL_COLOR_BUFFER_BIT ); /* Clear the screen with the clear color */

    // map the border vertices
glVertexAttribPointer(crosshairVertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &crossVertices[0]);
glEnableVertexAttribArray(crosshairVertexHandle);


glLineWidth(2.0f);
glDrawArrays(GL_LINES, 0, 4);
glDisableVertexAttribArray(crosshairVertexHandle);

glutSwapBuffers(); /* Double buffering */

}

Here's the error..

Build of configuration Debug for project ogl_tests **

make all 
Building file: ../src/ogl_tests.cpp
Invoking: Cygwin C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/ogl_tests.d" -MT"src/ogl_tests.d" -o"src/ogl_tests.o" "../src/ogl_tests.cpp"

Finished building: ../src/ogl_tests.cpp

Building target: ogl_tests.exe
Invoking: Cygwin C++ Linker
g++  -o"ogl_tests.exe"  ./src/ogl_tests.o   -lglu32 -lglut32 -lopengl32
./src/ogl_tests.o: In function `_Z7displayv':
/cygdrive/c/Users/David/workspace/ogl_tests/Debug/../src/ogl_tests.cpp:61: undefined reference to `__imp__glVertexAttribPointer@24'
/cygdrive/c/Users/David/workspace/ogl_tests/Debug/../src/ogl_tests.cpp:62: undefined reference to `__imp__glEnableVertexAttribArray@4'
/cygdrive/c/Users/David/workspace/ogl_tests/Debug/../src/ogl_tests.cpp:67: undefined reference to `__imp__glDisableVertexAttribArray@4'
collect2: ld returned 1 exit status
make: *** [ogl_tests.exe] Error 1

Any ideas?? - are the cygwin paths that I'm using correct?


@Nicol Bolas gave you one pice of the puzzle I give you the other: You're using OpenGL functions that go beyond the functionality of OpenGL-1.1, yet even OpenGL-1.4. On Windows OpenGL functionality beyond that versions must be obtained through the extension mechanism.

The most easy way to do this is using a extension wrapper like GLEW or GLEE. GLEW must be initialized with glewInit() right after context creation. GLEE can be used without initialization (that happens implicitly upon first call of an extension function).


OpenGL is not OpenGL ES. These are two completely different things (even though they seem similar on the surface). If you're running Vista 64, odds are you are not running on a system with a functioning OpenGL ES implementation.

There is an OpenGL extension that allows you to create an OpenGL ES context on desktop windows. But it's not widely implemented yet, and you're not using it in your code. Oh, and GLUT can't use OpenGL ES.

EGL is likewise not widely available, particularly on Windows. There has been some noise made about writing an EGL implementation on Windows, but nothing has come of it.

So two of your headers don't make any sense. You should be including OpenGL stuff, not OpenGL ES.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜