What SDL2 version you are you using because I am using SDL-2.0.5.
And how can I static link the libraries and where to get it.
And adding the headers still didn't help.
Heres the code,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 | #include <stdio.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengles2.h>
#include <SDL2/SDL_hints.h>
#include <GLES2/gl2.h>
#define Assert(x) do {if (!(x)) __debugbreak(); } while (0)
int main(int argc, char* argv[])
{
Assert(SDL_Init(SDL_INIT_VIDEO) == 0);
SDL_SetHint(SDL_HINT_OPENGL_ES_DRIVER, "1");
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_Window* w = SDL_CreateWindow("ANGLE", 100, 100, 640, 480, SDL_WINDOW_OPENGL|SDL_WINDOW_SHOWN|SDL_WINDOW_RESIZABLE);
Assert(w);
SDL_GLContext ctx = SDL_GL_CreateContext(w);
Assert(ctx);
Assert(SDL_GL_MakeCurrent(w, ctx) == 0);
SDL_GL_SetSwapInterval(1);
PFNGLGETSTRINGPROC glGetString = SDL_GL_GetProcAddress("glGetString");
PFNGLCLEARCOLORPROC glClearColor = SDL_GL_GetProcAddress("glClearColor");
PFNGLCLEARPROC glClear = SDL_GL_GetProcAddress("glClear");
printf("GL_VERSION = %s\n", glGetString(GL_VERSION));
printf("GL_VENDOR = %s\n", glGetString(GL_VENDOR));
printf("GL_RENDERER = %s\n", glGetString(GL_RENDERER));
int running = 1;
while (running)
{
SDL_Event ev;
while (SDL_PollEvent(&ev))
{
if (ev.type == SDL_QUIT)
{
running = 0;
break;
}
}
glClearColor(1, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow(w);
}
SDL_GL_DeleteContext(ctx);
SDL_Quit();
return 0;
}
|
the errors
e:\shazan\programming\sdl_angle_project\code\sdllayer.cpp(264): error C2065: 'SDL_HINT_OPENGL_ES_DRIVER': undeclared identifier
e:\shazan\programming\sdl_angle_project\code\sdllayer.cpp(281): error C2065: 'PFNGLGETSTRINGPROC': undeclared identifier
e:\shazan\programming\sdl_angle_project\code\sdllayer.cpp(281): error C2146: syntax error: missing ';' before identifier 'glGetString'
e:\shazan\programming\sdl_angle_project\code\sdllayer.cpp(281): error C2659: '=': function as left operand
e:\shazan\programming\sdl_angle_project\code\sdllayer.cpp(282): error C2065: 'PFNGLCLEARCOLORPROC': undeclared identifier
e:\shazan\programming\sdl_angle_project\code\sdllayer.cpp(282): error C2146: syntax error: missing ';' before identifier 'glClearColor'
e:\shazan\programming\sdl_angle_project\code\sdllayer.cpp(282): error C2659: '=': function as left operand
e:\shazan\programming\sdl_angle_project\code\sdllayer.cpp(283): error C2065: 'PFNGLCLEARPROC': undeclared identifier
e:\shazan\programming\sdl_angle_project\code\sdllayer.cpp(283): error C2146: syntax error: missing ';' before identifier 'glClear'
e:\shazan\programming\sdl_angle_project\code\sdllayer.cpp(283): error C2659: '=': function as left operand
and the build file
@echo off
set CompilerFlags= /Z7 /FC /nologo /Od -fp:fast -Gm- -GR- -EHa- /Oi -WX -W4 -wd4189 -wd4505 -wd4100 -wd4127 -wd4201
set LinkerFlags=-subsystem:console
mkdir build > NUL 2> NUL
pushd build
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
del *.pdb > NUL 2> NUL
ctime -begin sdl_opengl.ctm
cl %CompilerFlags% /MTd ..\code\gamecode.cpp -Fmgamecode.map -LD /link -incremental:no -opt:ref -PDB:handmade_%RANDOM%.pdb -EXPORT:Gameupdateandrender -out:GameCode.dll
cl %CompilerFlags% /MD ..\code\sdllayer.cpp /I..\deps\include /link -incremental:no ..\deps\lib\x64\SDL2.lib ..\deps\lib\x64\SDL2main.lib opengl32.lib %LinkerFlags%
ctime -end sdl_opengl.ctm
popd
Plus the docs says this,
SDL has support for OpenGL ES 2.x under Windows via two alternative
implementations.
The most straightforward method consists in running your app in a system with
a graphic card paired with a relatively recent (as of November of 2013) driver
which supports the WGL_EXT_create_context_es2_profile extension. Vendors known
to ship said extension on Windows currently include nVidia and Intel.
The other method involves using the ANGLE library (https://code.google.com/p/angleproject/)
If an OpenGL ES 2.x context is requested and no WGL_EXT_create_context_es2_profile
extension is found, SDL will try to load the libEGL.dll library provided by
ANGLE.
To obtain the ANGLE binaries, you can either compile from source from
https://chromium.googlesource.com/angle/angle or copy the relevant binaries from
a recent Chrome/Chromium install for Windows. The files you need are:
* libEGL.dll
* libGLESv2.dll
* d3dcompiler_46.dll (supports Windows Vista or later, better shader compiler)
or...
* d3dcompiler_43.dll (supports Windows XP or later)
If you compile ANGLE from source, you can configure it so it does not need the
d3dcompiler_* DLL at all (for details on this, see their documentation).
However, by default SDL will try to preload the d3dcompiler_46.dll to
comply with ANGLE's requirements. If you wish SDL to preload d3dcompiler_43.dll (to
support Windows XP) or to skip this step at all, you can use the
SDL_HINT_VIDEO_WIN_D3DCOMPILER hint (see SDL_hints.h for more details).
Known Bugs:
* SDL_GL_SetSwapInterval is currently a no op when using ANGLE. It appears
that there's a bug in the library which prevents the window contents from
refreshing if this is set to anything other than the default value.