Jump to content
  • Advertisement
Sign in to follow this  
leonardteo

OpenGL Newbie question - linker issues with SDL and OpenGL

This topic is 3011 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

Hi guys, I've just started coding with SDL and OpenGL and I'm having a bizarre issue with linking OpenGL. I am using Visual Studio 2008, Windows 7 x64. When I compile/link, none of the native OpenGL function calls seem to be resolving.... The errors are: error LNK2019: unresolved external symbol __imp__glFlush@0 referenced in function "void __cdecl leodraw(void)" (?leodraw@@YAXXZ) error LNK2019: unresolved external symbol __imp__glEnd@0 referenced in function "void __cdecl leodraw(void)" (?leodraw@@YAXXZ) etc.... basically, every native OpenGL call is unresolved. This is very strange. gl\gl.h and glu.h are included in the SDL_opengl.h header. Anyone know what I'm doing wrong here? Thanks in advance, Leonard
#include <SDL.h>
#include <SDL_opengl.h>
#include <stdio.h>

const int SCREEN_WIDTH = 800;
const int SCREEN_HEIGHT = 600;
const int SCREEN_BPP = 32;

void leodraw(){
	glClearColor(0.0, 0.0, 0.0, 0.0);
	glClear(GL_COLOR_BUFFER_BIT);
	glColor3f(1.0, 1.0, 1.0);
	glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
	glBegin(GL_POLYGON);
		glVertex3f(0.25, 0.25, 0.0);
		glVertex3f(0.75, 0.25, 0.0);
		glVertex3f(0.75, 0.75, 0.0);
		glVertex3f(0.25, 0.75, 0.0);
	glEnd();
	glFlush();
	SDL_GL_SwapBuffers();

}

int main (int argc, char* argv[]){

	printf("Firing up SDL OpenGL...\n");

	//Initialize
	if (SDL_Init(SDL_INIT_EVERYTHING) < 0){
		return -1;
	} else {
		printf("Initialized SDL\n");
	}

	//Set opengl attributes
    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 );


	if (SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_OPENGL) == 0){
		return -1;
	} else {
		printf("Set video mode %ix%ix%i", SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP);
	}

	SDL_WM_SetCaption("OpenGL Test", "OpenGL Test");

	bool quit = false;
	SDL_Event event;

	while (!quit){
		if (SDL_PollEvent(&event)){
			if (event.type == SDL_QUIT){
				quit = true;
				break;
			}
		}
	}

	SDL_Quit();
	return 1;

} ///end main

Share this post


Link to post
Share on other sites
Advertisement
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!