Sdl opengl example

Hi SDL users,

I use the source code(dont have change anything) of example 2-8.sdl and opengl which can be found at->
http://sdldoc.csn.ul.ie/guidevideoopengl.php#AEN136

so i tried to compile this example but got some errors like:

  • redefinition of int APIENTRY (GL.h file)
  • redefinition of int WINGDIAPI (GL.h file)

so i hope this is a known error . I hope someone can tell me how to fix this.

regards btang

Try adding #include <windows.h> at the top of the file… It’s a "magic bullet"
in windows :slight_smile:

/Olof

btang at planet.nl: “[SDL] sdl opengl example” (2004-05-27 10:10)

#Hi SDL users,#
#I use the source code(dont have change anything) of example 2-8.sdl and opengl which can be found at->
#http://sdldoc.csn.ul.ie/guidevideoopengl.php#AEN136

#so i tried to compile this example but got some errors like:
#- redefinition of int APIENTRY (GL.h file)
#- redefinition of int WINGDIAPI (GL.h file)

#so i hope this is a known error . I hope someone can tell me how to fix this.

#regards btang

#_______________________________________________
#SDL mailing list
#SDL at libsdl.org
#http://www.libsdl.org/mailman/listinfo/sdl

Try adding #include <windows.h> at the top of the file… It’s a "magic bullet"
in windows :slight_smile:

/Olof

The most portable solution is probably to replace :

#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>

with :

#include “SDL.h”
#include “SDL_opengl.h”

since SDL_opengl.h already includes windows.h under windows.

Stephane

The most portable solution is probably to replace :

#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>

with :

#include “SDL.h”
#include “SDL_opengl.h”

New library header directories are generally put into
your default header directory so they can be sure to
be sitting right on your include path, and thus can be
referred to as SDL/something and GL/something. While
convention may have it that you tell your compiler to
also looking in include_path/SDL and include_path/GL
and then simply include “SDL.h” “SDL_opengl.h” etc
etc, that doesn’t change the fact if BOTH don’t work,
the ABOVE version SHOULD work.__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.

unless you want to use
glut.h
glaux.h
etc.

which SDL_opengl.h does not include…> ----- Original Message -----

From: Stephane Marchesin [mailto:stephane.marchesin@wanadoo.fr]
Sent: 27 May 2004 10:31
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: Re: [SDL] sdl opengl example

Try adding #include <windows.h> at the top of the file… It’s a "magic
bullet"
in windows :slight_smile:

/Olof

The most portable solution is probably to replace :

#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>

with :

#include “SDL.h”
#include “SDL_opengl.h”

since SDL_opengl.h already includes windows.h under windows.

Stephane


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

The most portable solution is probably to replace :

#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>

with :

#include “SDL.h”
#include “SDL_opengl.h”

New library header directories are generally put into
your default header directory so they can be sure to
be sitting right on your include path, and thus can be
referred to as SDL/something and GL/something.

That’s not the case on every platform SDL supports. For example, on mac that would be :
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
Thus, if you want easy portability, you should include “SDL.h” and “SDL_opengl.h”. The path to these files will be handled by sdl-config. Doing anything else is asking for trouble.

Stephane

If you are using sdl-config --cflags, then
#include "SDL.h"
or
#include <SDL.h>
will work just fine.

Besides, on some systems (Windows), there is no default include directory
(at least, not in the same sense as on Unix), so you must explicitly tell
VS.NET/VC++.NET/whatever what directory the SDL include files are in, and
then include them with #include <SDl.h>. Using your method, you’d have to
tell it where the parent directory to the directory containing the SDL
include files is.

Of course, doing
#include <GL/gl.h>
is fine on every system that I’ve ever used. Even on Windows, the OpenGL
headers that come with MS VC++ .NET are in C:\Whatever\GL. If you’re going to
use SDL + OpenGL, though, you’ll need <SDL_opengl.h> anyway, which already
goes to the trouble of including gl.h and glu.h.

-Sean RidenourOn Thursday 27 May 2004 03:31 am, Donny Viszneki wrote:

The most portable solution is probably to replace :

#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>

with :

#include “SDL.h”
#include “SDL_opengl.h”

New library header directories are generally put into
your default header directory so they can be sure to
be sitting right on your include path, and thus can be
referred to as SDL/something and GL/something. While
convention may have it that you tell your compiler to
also looking in include_path/SDL and include_path/GL
and then simply include “SDL.h” “SDL_opengl.h” etc
etc, that doesn’t change the fact if BOTH don’t work,
the ABOVE version SHOULD work.