The following code compiles and opens an SDL2 window so long as SDL_opengl.h is commented out. When included I get five errors:
...\Pellesc\Include\Win\basetsd.h(213): error #2120: Redeclaration of 'DWORD', previously declared at ...\Pellesc\Include\Win\windef.h(99); expected 'unsigned long int' but found 'unsigned long long int'.
...\Pellesc\Include\Win\winnt.h(244): error #2120: Redeclaration of 'LONG', previously declared at ...\Pellesc\Include\Win\basetsd.h(72); expected 'long long int' but found 'long int'.
...\Pellesc\Include\Win\winnt.h(1424): error #2179: '-1' is an invalid array size
...\Pellesc\Include\Win\winnt.h(1425): error #2179: '-1' is an invalid array size
...\Pellesc\Include\Win\winnt.h(1426): error #2179: '-1' is an invalid array size
The actual lines causing issues are:
basetsd.h(213): typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
windef.h(99): typedef unsigned long DWORD;
and:
winnt.h(244): typedef long LONG;
basetsd.h(72): typedef __int64 LONG_PTR, *PLONG_PTR;
#define SDL_MAIN_HANDLED
typedef int bool;
#define true 1
#define false 0
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "SDL2/SDL.h"
#include "SDL2/SDL_opengl.h"
#pragma comment(lib, "SDL2.lib")
SDL_Window* win;
SDL_GLContext context;
bool running = true;
void setupSDL(void);
int main(int argc, char *argv[]){
#ifdef SDL_MAIN_HANDLED
SDL_SetMainReady();
#endif
setupSDL();
while(running){
SDL_Event e;
while(SDL_PollEvent(&e)){
switch(e.type){
case SDL_KEYDOWN:
if(e.key.keysym.sym == SDLK_ESCAPE) running = 0;
break;
default:
break;
}
}
SDL_GL_SwapWindow(win);
}
SDL_GL_DeleteContext(context);
SDL_DestroyWindow(win);
SDL_Quit();
return 0;
}
void setupSDL(void){
SDL_assert(SDL_Init(SDL_INIT_VIDEO) > -1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
int flags = SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_SHOWN;
win = SDL_CreateWindow("3Doodle", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1024, 768, flags);
SDL_assert(win != NULL);
context = SDL_GL_CreateContext(win);
SDL_assert(context != NULL);
}
I am using timovjl's SDL2 dll and lib with SDL2-devel-2.0.1-VC include files because these include the SDL_opengl.h header (I assume that the SDL2 dll does not export opengl functions and that the SDL_opengl.h interfaces with the graphic card's opengl32.dll).
I am compiling with a bat file:
del bin\App.exe
set libs=bin\main.o
cc /c -Tamd64-coff -Ze main.c -Fobin\main.o
cc -Wall %libs% /OUT:bin\App.exe
bin\App.exe
To make opengl work with PellesC I have also tried glew, building the lib with polib from the dll, podumping the dll and making a def file and polibing that into a lib, and compiling glew.c directly into the executable (which works with mingw), but on PellesC it throws cdecl errors. There is no information to be had by googling and I am out of ideas.