Jump to content
  • Advertisement
Sign in to follow this  
Player_0

OpenGL Need help running SDL and OpenGL on Visual Express

This topic is 4487 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! I just started to try and use Visual Studio Express and Im having problems with it. I got my SDL program running nicely and I was able to initialize OpenGL with it but as soon as I tried to use any GL functions I ran into some problems. It said the functions were undefined so I figured it wasn't seeing the opengl32.dll. I included the system32 directory where the dll is in Tools->Options->->Projects->Directories under the Library section but that didn't do anything. Is there some way of adding the DLL to yer project? Anyway I also tried including "gl\gl.h" and that brought up 142 errors out of no where so I need help. Any suggestions are appreciated.

Share this post


Link to post
Share on other sites
Advertisement
When you use OpenGL though SDL, you will just have to link in the library files with your project and the .DLLs will be used. The libraries you will probabally need are "opengl32.lib" as well as "glu32.lib". If you are using DevCpp it will be "libopengl32.a" and "libglu32.a". Also, you will just need to include "SDL_Opengl.h" and everything else will be taken care of header file wise, you do not need to include gl.h yourself. Good luck!

Share this post


Link to post
Share on other sites
I used #pragma to include Opengl32.lib. I didn't get any error which means it finds it and uses it just like the SDL libs, but I still get the error saying the gl functions are undefined.

Share this post


Link to post
Share on other sites
Yes, after you create your project:

Project-><Project Name> Properties (Last time in menu)
Expand the "Configuration Properties"
Expand the "Linker" (Under c/c++)
Click on the "Input"
On the right pane, enter in "SDLmain.lib SDL.lib OpenGL32.lib GLU32.lib" without quotes into the first box, which is "Additional Dependecies"

Do the same thing for the release configuration of your project as well. Change the configuration using the top left corner's combo box.

If you still get linker errors, please use the [source] Your Errors Here [/source] tags to show us.

Share this post


Link to post
Share on other sites
This is the source to the program, just basic initialization. The gl function is called at the bottom.



#include "SDL.h"

bool Init_SDL();
bool Init_OGL();

int main(int argc, char **argv)
{
if(Init_SDL() == 0) fprintf( stderr, "Init Error... Exiting.\n");
SDL_Delay(500);
SDL_Quit();
return 0;
}

bool Init_SDL()
{
const SDL_VideoInfo* info = NULL;
int width = 0;
int height = 0;
int bpp = 0;
int flags = 0;

if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
/* Failed, exit. */
fprintf( stderr, "Video initialization failed: %s\n",
SDL_GetError( ) );
return 0;
}

info = SDL_GetVideoInfo( );

if( !info ) {
fprintf( stderr, "Video query failed: %s\n",
SDL_GetError( ) );
return 0;
}

width = 640;
height = 480;
bpp = info->vfmt->BitsPerPixel;

SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

flags = SDL_OPENGL;

if( SDL_SetVideoMode( width, height, bpp, flags ) == 0 ) {
fprintf( stderr, "Video mode set failed: %s\n",
SDL_GetError( ) );
return 0;
}

return 1;
}

bool Init_OGL()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

return 1;
}



I added those libraries like you said and Im still getting:


------ Build started: Project: ProjectRPG, Configuration: Debug Win32 ------
Compiling...
main.cpp
c:\documents and settings\om\desktop\project 1\projectrpg\projectrpg\main.cpp(63) : error C3861: 'glClearColor': identifier not found
Build log was saved at "file://c:\Documents and Settings\Om\Desktop\Project 1\ProjectRPG\ProjectRPG\Debug\BuildLog.htm"
ProjectRPG - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!