#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <GL/gl.h>
#include <GL/glu.h>
#ifndef GRAP_HEADER_H
#define GRAP_HEADER_H
SDL_Surface *screen;
GLuint menu_image;
#endif
void graphics_engine_init();
void graphics_engine_exit();
GLuint LoadTexture(char *filename,int textw,int texth);
void DrawTexture(int x, int y, int textw,int texth, GLuint textureid);
No, not quite. (You're looking at "Fixing problem #3". (I think.))
Quickfix:
// graphics.h
extern SDL_Surface *screen;
extern GLuint menu_image;
// graphics.cpp
SDL_Surface *screen;
GLuint menu_image;
When a source file encounters an "extern", it is told that this variable exists, but resides elsewhere. Without the extern, each source file refers to its own version of those variables. When your program is linked, all of the externed variables are hooked up to the (one and only) location.
(Quite a shoddy explanation, but I hope it helps.)