Skip to content

Commit

Permalink
Upgrade from ES2 to ES3 and from WebGL1 to WebGL2
Browse files Browse the repository at this point in the history
Upgrade from ES2 to ES3 and from WebGL1 to WebGL2. This change is
needed in the long term for better rendering features such as:

- Transform feedback for GPU based particle simulations.
- Instanced rendering.
- MSAA FBO.

Issue #55
  • Loading branch information
ensisoft committed Sep 30, 2023
1 parent e1aee55 commit ec4d932
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion editor/gui/gfxwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ void GfxWindow::doInit()
}
virtual Version GetVersion() const override
{
return Version::OpenGL_ES2;
return Version::OpenGL_ES3;
}
private:
QOpenGLContext* mContext = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion editor/gui/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void Main(int argc, char* argv[])
// whether the destination color buffer has alpha channel or
// not should be irrelevant.
QSurfaceFormat format;
format.setVersion(2, 0);
format.setVersion(3, 0);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setRenderableType(QSurfaceFormat::OpenGLES);
format.setDepthBufferSize(24);
Expand Down
2 changes: 1 addition & 1 deletion editor/gui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ int Main(int argc, char* argv[])
// whether the destination color buffer has alpha channel or
// not should be irrelevant.
QSurfaceFormat format;
format.setVersion(2, 0);
format.setVersion(3, 0);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setRenderableType(QSurfaceFormat::OpenGLES);
format.setDepthBufferSize(24);
Expand Down
2 changes: 1 addition & 1 deletion editor/gui/playwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class PlayWindow::WindowContext : public dev::Context
}
virtual Version GetVersion() const override
{
return Version::OpenGL_ES2;
return Version::OpenGL_ES3;
}
void SetSurface(QWindow* surface)
{ mSurface = surface; }
Expand Down
2 changes: 2 additions & 0 deletions emscripten/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ target_link_options(GameEngine PRIVATE -sALLOW_MEMORY_GROWTH)
target_link_options(GameEngine PRIVATE -lidbfs.js)
target_link_options(GameEngine PRIVATE -sEXPORTED_FUNCTIONS=_main,_gui_set_flag)
target_link_options(GameEngine PRIVATE -sEXPORTED_RUNTIME_METHODS=ccall)
target_link_options(GameEngine PRIVATE -sUSE_WEBGL2)
target_link_options(GameEngine PRIVATE -sFULL_ES3)

# uncomment this in order to enable threading
#target_link_options(GameEngine PRIVATE -pthread)
Expand Down
4 changes: 2 additions & 2 deletions emscripten/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class WebGLContext : public dev::Context
attrs.depth = true;
attrs.stencil = true;
attrs.antialias = antialias;
attrs.majorVersion = 1; // WebGL 1.0 is based on OpenGL ES 2.0
attrs.majorVersion = 2; // WebGL 2.0 is based on OpenGL ES 3.0
attrs.minorVersion = 0;
attrs.preserveDrawingBuffer = false;
attrs.failIfMajorPerformanceCaveat = true;
Expand Down Expand Up @@ -161,7 +161,7 @@ class WebGLContext : public dev::Context
}
virtual Version GetVersion() const override
{
return Version::WebGL_1;
return Version::WebGL_2;
}
private:
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE mContext = 0;
Expand Down
5 changes: 2 additions & 3 deletions engine/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ class WindowContext : public dev::Context
WindowContext(const wdk::Config::Attributes& attrs, bool debug)
{
mConfig = std::make_unique<wdk::Config>(attrs);
mContext = std::make_unique<wdk::Context>(*mConfig, 2, 0, debug,
wdk::Context::Type::OpenGL_ES);
mContext = std::make_unique<wdk::Context>(*mConfig, 3, 0, debug, wdk::Context::Type::OpenGL_ES);
mVisualID = mConfig->GetVisualID();
mDebug = debug;
}
Expand All @@ -218,7 +217,7 @@ class WindowContext : public dev::Context
}
virtual Version GetVersion() const override
{
return Version::OpenGL_ES2;
return Version::OpenGL_ES3;
}
virtual bool IsDebug() const override
{
Expand Down
4 changes: 2 additions & 2 deletions tools/test/3d/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ int main(int argc, char* argv[])
attrs.sampling = wdk::Config::Multisampling::MSAA4;
attrs.srgb_buffer = true;
mConfig = std::make_unique<wdk::Config>(attrs);
mContext = std::make_unique<wdk::Context>(*mConfig, 2, 0, false /*debug*/, wdk::Context::Type::OpenGL_ES);
mContext = std::make_unique<wdk::Context>(*mConfig, 3, 0, false /*debug*/, wdk::Context::Type::OpenGL_ES);
mVisualID = mConfig->GetVisualID();
}
virtual void Display() override
Expand All @@ -634,7 +634,7 @@ int main(int argc, char* argv[])
}
virtual Version GetVersion() const override
{
return Version::OpenGL_ES2;
return Version::OpenGL_ES3;
}
virtual bool IsDebug() const override
{
Expand Down

0 comments on commit ec4d932

Please sign in to comment.