Skip to content

Commit

Permalink
Example: SDL2 + OpenGL ES2 (+ optionally Emscripten)
Browse files Browse the repository at this point in the history
Should work with emscripten, as well as mobile hardware.

Inspired by: ocornut#336
  • Loading branch information
laanwj committed Sep 27, 2017
1 parent e56eba4 commit c237b3a
Show file tree
Hide file tree
Showing 5 changed files with 606 additions and 0 deletions.
60 changes: 60 additions & 0 deletions examples/sdl_opengles2_example/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#
# Cross Platform Makefile
# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
#
#
# You will need SDL2 (http://www.libsdl.org)
#
# apt-get install libsdl2-dev # Linux
# brew install sdl2 # Mac OS X
# pacman -S mingw-w64-i686-SDL # MSYS2
#

#CXX = g++

EXE = sdl_opengles2_example
OBJS = main.o imgui_impl_sdl_gles2.o
OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o

UNAME_S := $(shell uname -s)


ifeq ($(UNAME_S), Linux) #LINUX
ECHO_MESSAGE = "Linux"
LIBS = -lGLESv2 -ldl `sdl2-config --libs`

CXXFLAGS = -I../../ `sdl2-config --cflags`
CXXFLAGS += -Wall -Wformat
CFLAGS = $(CXXFLAGS)
endif

ifeq ($(UNAME_S), Darwin) #APPLE
ECHO_MESSAGE = "Mac OS X"
LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs`

CXXFLAGS = -I../../ -I/usr/local/include `sdl2-config --cflags`
CXXFLAGS += -Wall -Wformat
CFLAGS = $(CXXFLAGS)
endif

ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
ECHO_MESSAGE = "Windows"
LIBS = -lgdi32 -limm32 `pkg-config --static --libs sdl2`

CXXFLAGS = -I../../ `pkg-config --cflags sdl2`
CXXFLAGS += -Wall -Wformat
CFLAGS = $(CXXFLAGS)
endif


.cpp.o:
$(CXX) $(CXXFLAGS) -c -o $@ $<

all: $(EXE)
@echo Build complete for $(ECHO_MESSAGE)

$(EXE): $(OBJS)
$(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)

clean:
rm $(EXE) $(OBJS)
13 changes: 13 additions & 0 deletions examples/sdl_opengles2_example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

# How to Build

- On Linux and similar Unixes

```
c++ `sdl2-config --cflags` -I ../.. main.cpp imgui_impl_sdl_gles2.cpp ../../imgui*.cpp `sdl2-config --libs` -lGLESv2 -ldl -o sdl2_opengles2_example
```
- Emscripten

```
em++ -O2 -s USE_SDL=2 -I ../.. main.cpp imgui_impl_sdl.cpp ../../imgui*.cpp -o html/index.html
```
Loading

0 comments on commit c237b3a

Please sign in to comment.