Skip to content

Commit

Permalink
VL v2.2 PR (#203)
Browse files Browse the repository at this point in the history
Adds GLSLComputeShader
Added OpenGLFunctions object wrapping all GL functions
Every OpenGLContext now has access to OpenGLFunctions object initialized with all the available functions according to the current GL context capabilities
Upgraded GL headers to latest 4.6
Revamped GL headers and GL function handling: GL function list generated directly from latest GL headers via scripts
Removed legacy GLES code
Removed legacy VL_... wrapper functions for GL functions coming from different extensions
  • Loading branch information
MicBosi authored Jan 4, 2022
1 parent 7cdba0c commit 187a839
Show file tree
Hide file tree
Showing 76 changed files with 24,217 additions and 35,858 deletions.
17 changes: 3 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# Current Version
set(VL_VERSION_MAJOR "2")
set(VL_VERSION_MINOR "1")
set(VL_VERSION_MINOR "2")
set(VL_VERSION_PATCH "0")
set(VL_VERSION "${VL_VERSION_MAJOR}.${VL_VERSION_MINOR}")
set(VL_VERSION_FULL "${VL_VERSION_MAJOR}.${VL_VERSION_MINOR}.${VL_VERSION_PATCH}")
Expand Down Expand Up @@ -51,18 +51,12 @@ endif()
message(STATUS "System detected: \"${CMAKE_SYSTEM_NAME}\"")

# OpenGL, OpenGL ES 1 or OpenGL ES 2 mode
set(VL_OPENGL_MODE "OPENGL" CACHE STRING "Set it to OPENGL, OPENGL_ES1 or OPENGL_ES2 to build VL for OpenGL, OpenGL ES 1.x or OpenGL ES 2.x")
set(VL_OPENGL_MODE "OPENGL" CACHE STRING "Only value supported for now is OPENGL")
if( VL_OPENGL_MODE STREQUAL "OPENGL")
set(VL_OPENGL 1)
message(STATUS "Configuring for OpenGL 1.x/2.x/3.x/4.x")
elseif( VL_OPENGL_MODE STREQUAL "OPENGL_ES1")
set(VL_OPENGL_ES1 1)
message(STATUS "Configuring for OpenGL ES 1.x")
elseif( VL_OPENGL_MODE STREQUAL "OPENGL_ES2")
set(VL_OPENGL_ES2 1)
message(STATUS "Configuring for OpenGL ES 2.x")
else()
message(FATAL_ERROR "Invalid VL_OPENGL_MODE! Valid modes are: OPENGL, OPENGL_ES1, OPENGL_ES2.")
message(FATAL_ERROR "Invalid VL_OPENGL_MODE! Valid modes are: OPENGL")
endif()

################################################################################
Expand Down Expand Up @@ -132,11 +126,6 @@ if( VL_OPENGL_MODE STREQUAL "OPENGL")
set(VL_OPENGL_LIBRARIES ${OPENGL_LIBRARIES})
endif()

if( VL_OPENGL_ES1 OR VL_OPENGL_ES2 )
include( SetupGLES )
set(VL_OPENGL_LIBRARIES ${VL_GLES_LIBRARY} ${VL_EGL_LIBRARY})
endif()

################################################################################
# Packaging
################################################################################
Expand Down
20 changes: 20 additions & 0 deletions scripts/generate_GLExtensionList.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Usage: ./generate_GLExtensionList.sh > ../src/vlGraphics/GL/GLExtensionList.hpp

GLDIR=../src/external/Khronos/GL

echo '// File automatically generated on '$(date '+%Y-%m-%d %H:%M:%S')

echo
echo '// GL Extensions'
echo
sed -n "s/#ifndef\s*\(GL_.*_[_a-zA-Z0-9]*\)/\1/p" $GLDIR/khronos_glext.h | sort | grep -v GL_VERSION | xargs -L 1 -I {} echo 'VL_EXTENSION('{}')'
echo
echo '// GLX Extensions'
echo
sed -n "s/#ifndef\s*\(GLX_.*_[_a-zA-Z0-9]*\)/\1/p" $GLDIR/khronos_glxext.h | sort | xargs -L 1 -I {} echo 'VL_EXTENSION('{}')'
echo
echo '// WGL Extensions'
echo
sed -n "s/#ifndef\s*\(WGL_.*_[_a-zA-Z0-9]*\)/\1/p" $GLDIR/khronos_wglext.h | sort | xargs -L 1 -I {} echo 'VL_EXTENSION('{}')'
29 changes: 29 additions & 0 deletions scripts/generate_GLFunctionList.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Usage: ./generate_GLFunctionList.sh > ../src/vlGraphics/GL/GLFunctionList.hpp

GLDIR=../src/external/Khronos/GL

echo '// File automatically generated on '$(date '+%Y-%m-%d %H:%M:%S')

echo
echo '// GL Extensions'
echo
sed -n -E "s/.*\s*APIENTRY\s*(gl[^(]*).*/VL_GL_FUNCTION( PFN\\U\\1PROC, \\E\\1 )/p" $GLDIR/khronos_glext.h | sort
echo
echo '// WGL Extensions'
echo
echo '#if defined(VL_PLATFORM_WINDOWS)'
sed -n -E "s/.*\s*WINAPI\s*(wgl[^(]*).*/VL_GL_FUNCTION( PFN\\U\\1PROC, \\E\\1 )/p" $GLDIR/khronos_wglext.h | sort
echo '#endif'
echo
echo '// GLX Extensions'
echo
echo '#if defined(VL_PLATFORM_LINUX)'
sed -n -E "s/.*\s*(glX[^(]*).*/VL_GL_FUNCTION( PFN\\U\\1PROC, \\E\\1 )/p" $GLDIR/khronos_glxext.h | sort
echo '#endif'
echo
echo '#if defined(VL_PLATFORM_MACOSX)'
echo ' Nothing to do here?'
echo '#endif'

13 changes: 13 additions & 0 deletions scripts/generate_GLFunctionList_1_1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Usage: ./generate_GLFunctionList_1_1.sh > ../src/vlGraphics/GL/GLFunctionList_1_1.hpp
# Note: to generate gl_1_1.h take Mesa's or Win's gl.h and remove all functions above 1.1

GLDIR=../src/external/Khronos/GL

echo '// File automatically generated on '$(date '+%Y-%m-%d %H:%M:%S')

echo
echo '// GL 1.1 Functions'
echo
sed -n -E "s/.*\s*APIENTRY\s*(gl[^(]*).*/VL_GL_FUNCTION( \\1 )/p" gl_1_1.h | sort
21 changes: 11 additions & 10 deletions src/examples/Applets/App_Fractals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <vlGraphics/GeometryPrimitives.hpp>
#include <vlGraphics/Text.hpp>
#include <vlGraphics/GLSL.hpp>
#include <vlCore/OpenGLDefs.hpp>
#include <vlGraphics/FontManager.hpp>

using namespace vl;
Expand Down Expand Up @@ -109,10 +110,10 @@ class App_Fractals: public BaseDemo
virtual void updateScene()
{
openglContext()->useGLSLProgram( mGLSLProgram.get() );
glUniform1f(mGLSLProgram->getUniformLocation("ColorOffset"), mColorOffset = (float)fract(Time::currentTime() * 0.5) );
glUniform1f(mGLSLProgram->getUniformLocation("Zoom"), mZoom);
glUniform1f(mGLSLProgram->getUniformLocation("Xcenter"), mXcenter);
glUniform1f(mGLSLProgram->getUniformLocation("Ycenter"), mYcenter);
vl::glUniform1f((GLint)mGLSLProgram->getUniformLocation("ColorOffset"), (GLfloat)(mColorOffset = (float)fract(Time::currentTime() * 0.5)) );
vl::glUniform1f(mGLSLProgram->getUniformLocation("Zoom"), mZoom);
vl::glUniform1f(mGLSLProgram->getUniformLocation("Xcenter"), mXcenter);
vl::glUniform1f(mGLSLProgram->getUniformLocation("Ycenter"), mYcenter);
}

void updateText()
Expand Down Expand Up @@ -241,12 +242,12 @@ class App_Fractals: public BaseDemo
mGLSLProgram->attachShader( new GLSLFragmentShader("/glsl/mandelbrot.fs") );
mGLSLProgram->linkProgram();
openglContext()->useGLSLProgram( mGLSLProgram.get() );
glUniform1f(mGLSLProgram->getUniformLocation("ColorOffset"), mColorOffset = (float)fract(Time::currentTime() * 0.5) );
glUniform3f(mGLSLProgram->getUniformLocation("InnerColor"), 0,0,0 );
glUniform1f(mGLSLProgram->getUniformLocation("Zoom"), mZoom);
glUniform1f(mGLSLProgram->getUniformLocation("Xcenter"), mXcenter);
glUniform1f(mGLSLProgram->getUniformLocation("Ycenter"), mYcenter);
glUniform1f(mGLSLProgram->getUniformLocation("MaxIterations"), mMaxIterations);
vl::glUniform1f(mGLSLProgram->getUniformLocation("ColorOffset"), mColorOffset = (float)fract(Time::currentTime() * 0.5) );
vl::glUniform3f(mGLSLProgram->getUniformLocation("InnerColor"), 0,0,0 );
vl::glUniform1f(mGLSLProgram->getUniformLocation("Zoom"), mZoom);
vl::glUniform1f(mGLSLProgram->getUniformLocation("Xcenter"), mXcenter);
vl::glUniform1f(mGLSLProgram->getUniformLocation("Ycenter"), mYcenter);
vl::glUniform1f(mGLSLProgram->getUniformLocation("MaxIterations"), mMaxIterations);
VL_CHECK_OGL();
}

Expand Down
4 changes: 2 additions & 2 deletions src/examples/Applets/App_GeometryInstancing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ class App_GeometryInstancing: public BaseDemo
significant performance improvement.
*/

if (!vl::Has_GL_EXT_draw_instanced)
if (!vl::Has_GL_ARB_draw_instanced)
{
vl::Log::error("GL_EXT_draw_instanced not supported.\n");
vl::Log::error("GL_ARB_draw_instanced not supported.\n");
vl::Time::sleep(2000);
exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion src/examples/Applets/App_MarchingCubes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class App_MarchingCubes: public BaseDemo
// text setup

mText = new vl::Text();
mText->setDisplayListEnabled(!vl::Has_GLES);
mText->setDisplayListEnabled(true);
mText->setFont( vl::defFontManager()->acquireFont("/font/bitstream-vera/VeraMono.ttf", 10) );
mText->setMargin(5);
mText->setViewportAlignment(vl::AlignTop | vl::AlignHCenter);
Expand Down
8 changes: 0 additions & 8 deletions src/examples/Applets/App_PortalCulling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,26 +140,20 @@ class App_PortalCulling: public BaseDemo
floor_fx->shader()->gocLight(0);
floor_fx->shader()->gocLightModel()->setTwoSide(true);
floor_fx->shader()->gocMaterial()->setDiffuse(vl::crimson);
if (!vl::Has_GLES_Version_1_1)
floor_fx->shader()->setRenderState(mPolygonMode.get());

vl::ref<vl::Effect> ceiling_fx = new vl::Effect;
ceiling_fx->shader()->enable(vl::EN_DEPTH_TEST);
ceiling_fx->shader()->enable(vl::EN_LIGHTING);
ceiling_fx->shader()->gocLight(0);
ceiling_fx->shader()->gocLightModel()->setTwoSide(true);
ceiling_fx->shader()->gocMaterial()->setDiffuse(vl::gray);
if (!vl::Has_GLES_Version_1_1)
ceiling_fx->shader()->setRenderState(mPolygonMode.get());

vl::ref<vl::Effect> wall_fx = new vl::Effect;
wall_fx->shader()->enable(vl::EN_DEPTH_TEST);
wall_fx->shader()->enable(vl::EN_LIGHTING);
wall_fx->shader()->gocLight(0)->setLinearAttenuation(0.025f);
wall_fx->shader()->gocLightModel()->setTwoSide(true);
wall_fx->shader()->gocMaterial()->setDiffuse(vl::gold);
if (!vl::Has_GLES_Version_1_1)
wall_fx->shader()->setRenderState(mPolygonMode.get());

// boring code to generate the gometry of various kinds of walls, with out door, with door, with the passage and portal.

Expand Down Expand Up @@ -335,8 +329,6 @@ class App_PortalCulling: public BaseDemo
ball_fx->shader()->enable(vl::EN_DEPTH_TEST);
ball_fx->shader()->enable(vl::EN_LIGHTING);
ball_fx->shader()->gocLight(0);
if (!vl::Has_GLES_Version_1_1)
ball_fx->shader()->setRenderState(mPolygonMode.get());

// for each cell of the dungeon
for(int y=0; y<map_size; ++y)
Expand Down
6 changes: 0 additions & 6 deletions src/examples/Applets/App_Texturing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,6 @@ class App_Texturing: public BaseDemo

void sphericalMapping()
{
if (Has_GLES)
{
Log::error("Spherical mapping texture coordinate generation not supported.\n");
return;
}

// Effect used by the actor
mFXSpheric = new Effect;
mFXSpheric->shader()->enable(EN_DEPTH_TEST);
Expand Down
24 changes: 0 additions & 24 deletions src/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,28 +182,4 @@ if( VL_GUI_QT4_EXAMPLES OR
VL_INSTALL_TARGET(vlWX_tests)
endif()

if (VL_GUI_GLES_EXAMPLES AND VL_OPENGL_ES1)
# Example
add_executable(vlGLES1_example GLES1_example.cpp)
target_link_libraries(vlGLES1_example VLEGL ${VL_LIBS_EXAMPLE})
VL_INSTALL_TARGET(vlGLES1_example)

# Tests
add_executable(vlGLES1_tests GLES1_tests.cpp)
target_link_libraries(vlGLES1_tests VLApplets VLEGL ${VL_LIBS_TESTS})
VL_INSTALL_TARGET(vlGLES1_tests)
endif()

if (VL_GUI_GLES_EXAMPLES AND VL_OPENGL_ES2)
# Example
add_executable(vlGLES2_example GLES2_example.cpp)
target_link_libraries(vlGLES2_example VLEGL ${VL_LIBS_EXAMPLE})
VL_INSTALL_TARGET(vlGLES2_example)

# Tests
add_executable(vlGLES2_tests GLES2_tests.cpp)
target_link_libraries(vlGLES2_tests VLApplets VLEGL ${VL_LIBS_TESTS})
VL_INSTALL_TARGET(vlGLES2_tests)
endif()

endif()
94 changes: 0 additions & 94 deletions src/examples/GLES1_example.cpp

This file was deleted.

Loading

0 comments on commit 187a839

Please sign in to comment.