The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.
SDL
Simple Directmedia Layer Forums
Compiling SDL 2 to use gl* instead of wgl* under cygwin
Winestone
Joined: 23 Oct 2014
Posts: 1
Posted: Sun Oct 26, 2014 5:24 am
I would like to compile SDL 2 using cygwin to use gl* rather than wgl* things so that it can create a gl* context. (hopefully I'm making sense here)
This is because I'm using GLEW as well and the cygwin port version of GLEW uses gl* while the mingw SDL 2 build (on the website) and the version I have compiled with make has appeared to create a wgl* context.
const int width = 1000;
const int height = 500;
bool Running = true;
#undef main //Required to compile, otherwise In function 'main': [Linker error] undefined reference to 'WinMain@16'
int main (int argc, char *argv[]) {
FILE* cdebug = fopen("cdebug.txt", "w");
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
fprintf(cdebug, "SDL could not initialize! SDL Error: %s\n", SDL_GetError()); fflush(cdebug);
}
#define setAttr(attr, value) \
if (SDL_GL_SetAttribute(attr, value) < 0) { \
fprintf(cdebug, "SDL failed to set %s to %s, SDL Error: %s\n", #attr, #value, SDL_GetError()); fflush(cdebug);\
}
setAttr(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
setAttr(SDL_GL_CONTEXT_MINOR_VERSION, 3);
setAttr(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GLContext GLContext = SDL_GL_CreateContext(window);
if (GLContext == NULL) {
fprintf(cdebug, "OpenGL context could not be created! SDL Error: %s\n", SDL_GetError()); fflush(cdebug);
}
if (SDL_GL_MakeCurrent(window, GLContext) < 0) {
fprintf(cdebug, "OpenGL context could not be made current! SDL Error: %s\n", SDL_GetError()); fflush(cdebug);
}