Skip to content

Commit

Permalink
Added partial support for GL|ES3
Browse files Browse the repository at this point in the history
  • Loading branch information
matus-chochlik committed Mar 15, 2017
1 parent f060c18 commit 0412a59
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 20 deletions.
27 changes: 27 additions & 0 deletions CMakeLists.txt
Expand Up @@ -46,6 +46,9 @@ endif()
# the GL header and GL init lib
set(OGLPLUS_USE_GLCOREARB_H 0)
set(OGLPLUS_USE_GL3_H 0)
set(OGLPLUS_USE_GLES3_GL32_H 0)
set(OGLPLUS_USE_GLES3_GL31_H 0)
set(OGLPLUS_USE_GLES3_GL3_H 0)
set(OGLPLUS_USE_GLEW 0)
set(OGLPLUS_USE_GL3W 0)

Expand Down Expand Up @@ -144,6 +147,30 @@ if((${OGLPLUS_USE_GLCOREARB_H}) OR (${OGLPLUS_USE_GL3_H}))
set(OGLPLUS_GL_FOUND 1)

message(STATUS "Using native OpenGL API library")
elseif(${OGLPLUS_USE_GLES3_GL32_H})

set(OGLPLUS_GL_INCLUDE_DIRS ${OPENGLES32_INCLUDE_DIRS})
include_directories(BEFORE SYSTEM ${OPENGLES32_INCLUDE_DIRS})
set(OGLPLUS_GL_LIBRARIES ${OPENGLES32_LIBRARIES})
set(OGLPLUS_GL_FOUND 1)

message(STATUS "Using GLES 3.2 API library")
elseif(${OGLPLUS_USE_GLES3_GL31_H})

set(OGLPLUS_GL_INCLUDE_DIRS ${OPENGLES31_INCLUDE_DIRS})
include_directories(BEFORE SYSTEM ${OPENGLES31_INCLUDE_DIRS})
set(OGLPLUS_GL_LIBRARIES ${OPENGLES31_LIBRARIES})
set(OGLPLUS_GL_FOUND 1)

message(STATUS "Using GLES 3.1 API library")
elseif(${OGLPLUS_USE_GLES3_GL3_H})

set(OGLPLUS_GL_INCLUDE_DIRS ${OPENGLES3_INCLUDE_DIRS})
include_directories(BEFORE SYSTEM ${OPENGLES3_INCLUDE_DIRS})
set(OGLPLUS_GL_LIBRARIES ${OPENGLES3_LIBRARIES})
set(OGLPLUS_GL_FOUND 1)

message(STATUS "Using GLES 3.0 API library")
elseif(${OGLPLUS_USE_GLEW})

set(OGLPLUS_GL_INCLUDE_DIRS ${GLEW_INCLUDE_DIRS})
Expand Down
20 changes: 18 additions & 2 deletions config/CommonDefs.cmake
Expand Up @@ -4,7 +4,23 @@
#
set(OGLPLUS_GL_INIT_LIBS GLX GLUT GLFW3 GLFW SDL WXGL QT4GL QT5GL EGL)
if(${WIN32})
set(OGLPLUS_GL_API_LIBS GLEW GL3W GLCOREARB_H GL3_H)
set(OGLPLUS_GL_API_LIBS
GLEW
GL3W
GLCOREARB_H
GL3_H
GLES3_GL32_H
GLES3_GL31_H
GLES3_GL3_H
)
else()
set(OGLPLUS_GL_API_LIBS GLCOREARB_H GL3_H GLEW GL3W)
set(OGLPLUS_GL_API_LIBS
GLCOREARB_H
GL3_H
GLES3_GL32_H
GLES3_GL31_H
GLES3_GL3_H
GLEW
GL3W
)
endif()
76 changes: 72 additions & 4 deletions config/FindGLES3.cmake
@@ -1,5 +1,73 @@
# Copyright 2010-2013 Matus Chochlik. Distributed under the Boost
# Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# Copyright Matus Chochlik.
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt
#
oglplus_common_find_module(GLES3 glesv3 GLES3/gl3.h GLESv3) #TODO
macro(gles3_detection VER_MINOR)
unset(OPENGLES3${VER_MINOR}_INCLUDE_DIRS)
set(OPENGLES3${VER_MINOR}_FOUND 0)
#
# try to find GLES3/gl3${VER_MINOR}.h
find_path(
OPENGLES3_GL3${VER_MINOR}_H_DIR GLES3/gl3${VER_MINOR}.h
PATHS ${HEADER_SEARCH_PATHS}
NO_DEFAULT_PATH
)
# if that didn't work try the system directories
if(
(NOT OPENGLES3_GL3${VER_MINOR}_H_DIR) OR
(NOT EXISTS ${OPENGLES3_GL3${VER_MINOR}_H_DIR})
)
find_path(
OPENGLES3_GL3${VER_MINOR}_H_DIR
NAMES GLES3/gl3${VER_MINOR}.h
)
endif()
# if found append it to the include directories
if(
(OPENGLES3_GL3${VER_MINOR}_H_DIR) AND
(EXISTS ${OPENGLES3_GL3${VER_MINOR}_H_DIR})
)
set(
OPENGLES3${VER_MINOR}_INCLUDE_DIRS
${OPENGLES3${VER_MINOR}_INCLUDE_DIRS}
${OPENGLES3_GL3${VER_MINOR}_H_DIR}
)
set(OPENGLES3${VER_MINOR}_FOUND 1)
endif()
#
# try to find the GLES3 library
find_library(
OPENGLES3${VER_MINOR}_LIBRARIES
NAMES GLESv3${VER_MINOR} GLESv3 GLES3${VER_MINOR} GLES3 GL
PATHS ${LIBRARY_SEARCH_PATHS}
NO_DEFAULT_PATH
)
if(NOT OPENGLES3${VER_MINOR}_LIBRARIES)
find_library(
OPENGLES3${VER_MINOR}_LIBRARIES
NAMES GLESv3${VER_MINOR} GLESv3 GLES3${VER_MINOR} GLES3 GL
)
else()
get_filename_component(
OPENGLES3${VER_MINOR}_LIBRARY_DIRS
{OPENGLES3${VER_MINOR}_LIBRARIES} PATH
)
endif()

#if we have not found the library
if(NOT OPENGLES3${VER_MINOR}_LIBRARIES)
set(OPENGLES3${VER_MINOR}_LIBRARIES "")
endif()

if(OPENGLES3${VER_MINOR}_FOUND AND ${OPENGLES3${VER_MINOR}_FOUND})
message(STATUS "Found GLES3${VER_MINOR}: ${OPENGLES3${VER_MINOR}_INCLUDE_DIRS};${OPENGLES3${VER_MINOR}_LIBRARIES}")
set(GLES3_GL3${VER_MINOR}_H_FOUND 1)
else()
set(GLES3_GL3${VER_MINOR}_H_FOUND 0)
endif()
endmacro()

gles3_detection("")
gles3_detection("1")
gles3_detection("2")
12 changes: 12 additions & 0 deletions config/oglplus/config/site.hpp.in
Expand Up @@ -33,6 +33,18 @@
#define OGLPLUS_USE_GL3_H @OGLPLUS_USE_GL3_H@
#endif

#ifndef OGLPLUS_USE_GLES3_GL32_H
#define OGLPLUS_USE_GLES3_GL32_H @OGLPLUS_USE_GLES3_GL32_H@
#endif

#ifndef OGLPLUS_USE_GLES3_GL31_H
#define OGLPLUS_USE_GLES3_GL31_H @OGLPLUS_USE_GLES3_GL31_H@
#endif

#ifndef OGLPLUS_USE_GLES3_GL3_H
#define OGLPLUS_USE_GLES3_GL3_H @OGLPLUS_USE_GLES3_GL3_H@
#endif

#ifndef OGLPLUS_USE_GLEW
#define OGLPLUS_USE_GLEW @OGLPLUS_USE_GLEW@
#endif
Expand Down
21 changes: 13 additions & 8 deletions configure.py
Expand Up @@ -4,7 +4,7 @@
# Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
import os, sys, getopt, shutil, subprocess
import os, sys, string, getopt, shutil, subprocess

# initial values for the configuration options

Expand Down Expand Up @@ -308,19 +308,24 @@ def OpenGLVersionValue(arg):
"""
)

path2idus = string.maketrans("/.","__")
path2idmi = string.maketrans("/.","--")
gl_api_libs = {
"glcorearb.h" : "GL/glcorearb.h header",
"gl3.h" : "GL3/gl3.h header",
"GLEW" : "GLEW library",
"GL3W" : "GL3W library"
"glcorearb.h" : "GL/glcorearb.h header",
"gl3.h" : "GL3/gl3.h header",
"GLES3/gl32.h" : "GLES3/gl32.h header",
"GLES3/gl31.h" : "GLES3/gl31.h header",
"GLES3/gl3.h" : "GLES3/gl3.h header",
"GLEW" : "GLEW library",
"GL3W" : "GL3W library"
}

argparser_gl_api_lib_group = argparser.add_mutually_exclusive_group()
argparser_gl_api_lib_group.add_argument(
"--use-gl-api-lib",
dest="gl_api_lib",
type=str,
choices=[lib.upper().replace('.', '_') for lib in gl_api_libs.keys() ],
choices=[lib.upper().translate(path2idus) for lib in gl_api_libs.keys() ],
action="store",
default=None,
help="""
Expand All @@ -334,8 +339,8 @@ def OpenGLVersionValue(arg):
"""
)
for gl_api_lib, gl_api_lib_name in gl_api_libs.items():
lib_lc = gl_api_lib.lower().replace('.', '-')
lib_uc = gl_api_lib.upper().replace('.', '_')
lib_lc = gl_api_lib.lower().translate(path2idmi)
lib_uc = gl_api_lib.upper().translate(path2idus)
argparser_gl_api_lib_group.add_argument(
"--use-%(lib_lc)s" % { "lib_lc" : lib_lc },
dest="gl_api_lib",
Expand Down
50 changes: 44 additions & 6 deletions include/oglplus/gl.hpp
Expand Up @@ -25,6 +25,18 @@
#define OGLPLUS_USE_GL3_H 0
#endif

#ifndef OGLPLUS_USE_GLES3_GL32_H
#define OGLPLUS_USE_GLES3_GL32_H 0
#endif

#ifndef OGLPLUS_USE_GLES3_GL31_H
#define OGLPLUS_USE_GLES3_GL31_H 0
#endif

#ifndef OGLPLUS_USE_GLES3_GL3_H
#define OGLPLUS_USE_GLES3_GL3_H 0
#endif

#ifndef OGLPLUS_USE_GLEW
#define OGLPLUS_USE_GLEW 0
#endif
Expand Down Expand Up @@ -65,12 +77,38 @@ struct GLAPIInitializer
# define __glext_h__

namespace oglplus {
struct GLAPIInitializer
{
GLAPIInitializer(
int /*gl_ver_major*/ = 3,
int /*gl_ver_minor*/ = 3
){ }
struct GLAPIInitializer {
GLAPIInitializer(int = 3, int = 3){ }
};
} // namespace oglplus

# elif OGLPLUS_USE_GLES3_GL32_H
# define GL3_PROTOTYPES
# include <GLES3/gl32.h>

namespace oglplus {
struct GLAPIInitializer {
GLAPIInitializer(int = 3, int = 3){ }
};
} // namespace oglplus

# elif OGLPLUS_USE_GLES3_GL31_H
# define GL3_PROTOTYPES
# include <GLES3/gl31.h>

namespace oglplus {
struct GLAPIInitializer {
GLAPIInitializer(int = 3, int = 3){ }
};
} // namespace oglplus

# elif OGLPLUS_USE_GLES3_GL3_H
# define GL3_PROTOTYPES
# include <GLES3/gl3.h>

namespace oglplus {
struct GLAPIInitializer {
GLAPIInitializer(int = 3, int = 3){ }
};
} // namespace oglplus

Expand Down

0 comments on commit 0412a59

Please sign in to comment.