Hello, I did a brief check and I'm sure I missed a similar topic somewhere but I think my issues may be a touch more specific.
A friend convinced me that I should be using OpenGL over DirectX and I can understand his reasoning which brought me to the NeHe site. I am trying to follow the tutorials but I get the following error:
Main.obj : error LNK2019: unresolved external symbol _gluPerspective@32 referenced in function "void __cdecl ReSizeGLScene(int,int)" (?ReSizeGLScene@@YAXHH@Z)
I have the following code segments in my project that I think are relevant:
#include <windows.h> // Header File For Windows
#include <gl/gl.h> // Header File For The OpenGL32 Library
#include <gl/glu.h>
#include <SDL_opengl.h>
----------------------------
GLvoid ReSizeGLScene(GLsizei width, GLsizei height){
if(height == 0)
height =1;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
// Calculate The Aspect Ratio Of The Window
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
}
It should be noted that I don't seem to have an opengl library file on my computer. I assume that's a problem but I'm not entirely certain where I should be downloading a new one from.
I am using glew and SDL as per my friend's advice.
Any help on any of the above would be greatly appreciated as this has been a cause of massive stress for me. Additionally, any better tutorials than NeHe would be great since they seem to be several years old and I'm sure they're deprecated by now...
What compiler and build environment are you using? The only one I'm aware of that won't include these libs is Visual C++ 2005 Express (both 2008 and 2010 do). Otherwise you do have them.
you don't need to go looking through your filesystem for these. They're installed automatically and Visual C++ (and other environments) will be automatically set up with the correct paths to be able to find them. There's nothing you need to do aside from just link to them. The only way they could be missing is if you've done something yourself to remove them.
What happens if you put this at the top of your program? #pragma comment (lib, "opengl32.lib")
#pragma comment (lib, "glu32.lib")
Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.
One additon for others who might read this: If you're using an IDE that doesn't install the OpenGL libraries you can download and install the Windows SDK from microsoft.com to get the missing libraries (and the latest version of other system libraries)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
However. I can't get it to 'work'. It compiles and runs but the window fails and I'm reasonably certain that it outputs all of the failure cases below (the window vanishes way too fast for me to tell and print screen is not working when I try to capture it.)
#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GL/glfw.h>
#include <glm/glm.hpp>
using namespace glm;
int main( void )
{
// Initialise GLFW
if( !glfwInit() )
{
fprintf( stderr, "Failed to initialize GLFW\n" );
return -1;
}
glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4);
glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE,GL_TRUE);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Open a window and create its OpenGL context
if( !glfwOpenWindow( 1024, 768, 0,0,0,0, 32,0, GLFW_WINDOW ) )
{
fprintf( stderr, "Failed to open GLFW window\n" );
glfwTerminate();
return -1;
}
// Initialize GLEW
if (glewInit() != GLEW_OK) {
fprintf(stderr, "Failed to initialize GLEW\n");
return -1;
}
glfwSetWindowTitle( "Playground" );
// Ensure we can capture the escape key being pressed below
glfwEnable( GLFW_STICKY_KEYS );
// Dark blue background
glClearColor(0.0f, 0.0f, 0.3f, 0.0f);
do{
// Draw nothing, see you in tutorial 2 !
// Swap buffers
glfwSwapBuffers();
} // Check if the ESC key was pressed or the window was closed
while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS &&
glfwGetWindowParam( GLFW_OPENED ) );
// Close OpenGL window and terminate GLFW
glfwTerminate();
return 0;
}
I'm obviously doing something wrong but I just can't imagine what!
In that case, use your debugger to step through the code.
Or, output line by line to a text file so that you'll know where the code is stopping and what the error code is.
Sig: http://glhlib.sourceforge.net an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
*sigh* This has just been one huge, demoralizing headache.
Ok, so in order to start testing this code, I needed to separate it from the huge project it was a part of because it had an issue of it being all bundled together and you were apparently just supposed to run the exe outside of VC 2010...
So I copied and pasted the above code into a new project and then realized I didn't have either glfw or glm (not part of the original problem as they came packaged with those tutorials.) So I downloaded the appropriate uh, I'm not sure what to call them... extensions? and included them in my project.
Now I am getting all of this!
1>SDLmain.lib(SDL_win32_main.obj) : error LNK2005: _main already defined in Main.obj
1>MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>Main.obj : error LNK2019: unresolved external symbol _glfwGetWindowParam referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwGetKey referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwSwapBuffers referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwEnable referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwSetWindowTitle referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol __imp__glewInit referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwTerminate referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwOpenWindow referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwOpenWindowHint referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwInit referenced in function _main
1>SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol _SDL_main referenced in function _main
So I assume that there's something wrong with my SDL?