Added -gles2_renderer option.

Trying to clean up code
This commit is contained in:
Emile Belanger 2021-04-24 17:15:14 +01:00
parent 0452bb4f23
commit 33312cbcd7
14 changed files with 29 additions and 246 deletions

View file

@ -433,7 +433,6 @@ set( PLAT_WIN32_SOURCES
common/platform/win32/base_sysfb.cpp
common/platform/win32/win32basevideo.cpp
common/platform/win32/win32glvideo.cpp
common/platform/win32/win32glesvideo.cpp
common/platform/win32/win32polyvideo.cpp)
if (HAVE_VULKAN)

View file

@ -52,8 +52,9 @@
#include "v_text.h"
#include "version.h"
#include "printf.h"
#include "gl_framebuffer.h"
#include "gles_framebuffer.h"
#ifdef HAVE_VULKAN
#include "vulkan/system/vk_framebuffer.h"
#endif
@ -462,7 +463,10 @@ public:
if (fb == nullptr)
{
fb = new OpenGLESRenderer::OpenGLFrameBuffer(0, vid_fullscreen);
if( Args->CheckParm ("-gles2_renderer") )
fb = new OpenGLESRenderer::OpenGLFrameBuffer(0, vid_fullscreen);
else
fb = new OpenGLRenderer::OpenGLFrameBuffer(0, vid_fullscreen);
}
fb->SetWindow(ms_window);

View file

@ -49,8 +49,9 @@
#include "gl_system.h"
#include "gl_renderer.h"
#include "gl_framebuffer.h"
#include "gles_framebuffer.h"
#ifdef HAVE_VULKAN
#include "vulkan/system/vk_framebuffer.h"
#endif
@ -470,7 +471,10 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer ()
#endif
if (fb == nullptr)
{
fb = new OpenGLESRenderer::OpenGLFrameBuffer(0, vid_fullscreen);
if( Args->CheckParm ("-gles2_renderer") )
fb = new OpenGLESRenderer::OpenGLFrameBuffer(0, vid_fullscreen);
else
fb = new OpenGLRenderer::OpenGLFrameBuffer(0, vid_fullscreen);
}
return fb;

View file

@ -49,7 +49,6 @@
#include "m_argv.h"
#include "engineerrors.h"
#include "win32glvideo.h"
#include "win32glesvideo.h"
extern HWND Window;
@ -72,7 +71,6 @@ PFNWGLSWAPINTERVALEXTPROC myWglSwapIntervalExtProc;
SystemGLFrameBuffer::SystemGLFrameBuffer(void *hMonitor, bool fullscreen) : SystemBaseFrameBuffer(hMonitor, fullscreen)
{
//if (!static_cast<Win32GLESVideo *>(Video)->InitHardware(Window, 0))
if (!static_cast<Win32GLVideo*>(Video)->InitHardware(Window, 0))
{
I_FatalError("Unable to initialize OpenGL");
@ -123,5 +121,8 @@ void SystemGLFrameBuffer::SetVSync (bool vsync)
if (myWglSwapIntervalExtProc != NULL) myWglSwapIntervalExtProc(vsync ? (gl_control_tear? SwapInterval : 1) : 0);
}
void SystemGLFrameBuffer::SwapBuffers()
{
::SwapBuffers(static_cast<Win32GLVideo *>(Video)->m_hDC);
}

View file

@ -44,7 +44,6 @@
#include "version.h"
#include "printf.h"
#include "win32glvideo.h"
#include "win32glesvideo.h"
#ifdef HAVE_SOFTPOLY
#include "win32polyvideo.h"
#endif
@ -157,7 +156,6 @@ void I_InitGraphics ()
#endif
{
Video = new Win32GLVideo();
//Video = new Win32GLESVideo();
}
#ifdef HAVE_SOFTPOLY

View file

@ -1,204 +0,0 @@
/*
** win32video.cpp
** Code to let ZDoom draw to the screen
**
**---------------------------------------------------------------------------
** Copyright 1998-2006 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#include <windows.h>
#include <GL/gl.h>
#include <vector>
#include "wglext.h"
#include <vector>
#include "gl_sysfb.h"
#include "hardware.h"
#include "templates.h"
#include "version.h"
#include "c_console.h"
#include "v_video.h"
#include "i_input.h"
#include "i_system.h"
#include "v_text.h"
#include "m_argv.h"
#include "printf.h"
#include "engineerrors.h"
#include "win32glesvideo.h"
#include "win32glvideo.h"
#include "gles_framebuffer.h"
//#include "Mali_OpenGL_ES_Emulator\include\EGL\egl.h"
//#include "glad/glad_egl.h"
#include "EGL/egl.h"
EXTERN_CVAR(Int, gl_pipeline_depth);
//#define USE_EGL
// Add to class!
EGLDisplay sEGLDisplay;
EGLContext sEGLContext;
EGLSurface sEGLSurface;
//==========================================================================
//
//
//
//==========================================================================
Win32GLESVideo::Win32GLESVideo()
{
}
//==========================================================================
//
//
//
//==========================================================================
DFrameBuffer * Win32GLESVideo::CreateFrameBuffer()
{
SystemGLFrameBuffer *fb;
fb = new OpenGLESRenderer::OpenGLFrameBuffer(m_hMonitor, vid_fullscreen);
fb->mPipelineNbr = gl_pipeline_depth;
fb->mPipelineNbr = 4;
return fb;
}
//==========================================================================
//
//
//
//==========================================================================
void SystemGLFrameBuffer::SwapBuffers()
{
::SwapBuffers(static_cast<Win32GLVideo*>(Video)->m_hDC);
//eglSwapBuffers(sEGLDisplay, sEGLSurface));
}
bool Win32GLESVideo::InitHardware(HWND Window, int multisample)
{
#ifdef USE_EGL
EGLint eglError;
m_Window = Window;
m_hDC = GetDC(Window);
EGLint aEGLAttributes[] = {
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_DEPTH_SIZE, 16,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_NONE
};
EGLint aEGLContextAttributes[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
EGLConfig aEGLConfigs[1];
EGLint cEGLConfigs;
//HDC hDisplay = EGL_DEFAULT_DISPLAY;
sEGLDisplay = eglGetDisplay(m_hDC);
eglError = eglGetError();
if (eglError != EGL_SUCCESS) {
exit(1);
}
eglInitialize(sEGLDisplay, NULL, NULL);
eglError = eglGetError();
if (eglError != EGL_SUCCESS) {
exit(1);
}
eglChooseConfig(sEGLDisplay, aEGLAttributes, aEGLConfigs, 1, &cEGLConfigs);
eglError = eglGetError();
if (eglError != EGL_SUCCESS) {
exit(1);
}
if (cEGLConfigs == 0) {
printf("No EGL configurations were returned.\n");
exit(-1);
}
sEGLSurface = eglCreateWindowSurface(sEGLDisplay, aEGLConfigs[0], Window, NULL);
if (sEGLSurface == EGL_NO_SURFACE) {
printf("Failed to create EGL surface.\n");
exit(-1);
}
sEGLContext = eglCreateContext(sEGLDisplay,
aEGLConfigs[0], EGL_NO_CONTEXT, aEGLContextAttributes);
if (sEGLContext == EGL_NO_CONTEXT) {
printf("Failed to create EGL context.\n");
exit(-1);
}
eglMakeCurrent(sEGLDisplay, sEGLSurface, sEGLSurface, sEGLContext);
return true;
#endif
// We get here if the driver doesn't support the modern context creation API which always means an old driver.
I_Error("R_OPENGL: Unable to create an OpenGL render context. Insufficient driver support for context creation\n");
return false;
}
//==========================================================================
//
//
//
//==========================================================================
void Win32GLESVideo::Shutdown()
{
if (m_hDC) ReleaseDC(m_Window, m_hDC);
}

View file

@ -1,22 +0,0 @@
#pragma once
#include "win32basevideo.h"
//==========================================================================
//
//
//
//==========================================================================
class Win32GLESVideo : public Win32BaseVideo
{
public:
Win32GLESVideo();
DFrameBuffer *CreateFrameBuffer() override;
bool InitHardware(HWND Window, int multisample);
void Shutdown();
protected:
HGLRC m_hRC;
};

View file

@ -106,8 +106,10 @@ DFrameBuffer *Win32GLVideo::CreateFrameBuffer()
{
SystemGLFrameBuffer *fb;
fb = new OpenGLESRenderer::OpenGLFrameBuffer(m_hMonitor, vid_fullscreen);
// fb = new OpenGLRenderer::OpenGLFrameBuffer(m_hMonitor, vid_fullscreen);
if (Args->CheckParm("-gles2_renderer"))
fb = new OpenGLESRenderer::OpenGLFrameBuffer(m_hMonitor, vid_fullscreen);
else
fb = new OpenGLRenderer::OpenGLFrameBuffer(m_hMonitor, vid_fullscreen);
return fb;
}

View file

@ -5,6 +5,8 @@
class FRenderState;
#define HW_MAX_PIPELINE_BUFFERS 8
// The low level code needs to know which attributes exist.
// OpenGL needs to change the state of all of them per buffer binding.
// VAOs are mostly useless for this because they lump buffer and binding state together which the model code does not want.

View file

@ -50,7 +50,7 @@ public:
int mPipelinePos = 0;
IVertexBuffer* mVertexBuffer;
IVertexBuffer *mVertexBufferPipeline[MAX_PIPELINE_BUFFERS];
IVertexBuffer *mVertexBufferPipeline[HW_MAX_PIPELINE_BUFFERS];
IIndexBuffer *mIndexBuffer;

View file

@ -1,7 +1,6 @@
#ifndef __GL_LIGHTBUFFER_H
#define __GL_LIGHTBUFFER_H
#include "doomdef.h"
#include "tarray.h"
#include "hw_dynlightdata.h"
#include "hwrenderer/data/buffers.h"
@ -13,7 +12,7 @@ class FRenderState;
class FLightBuffer
{
IDataBuffer *mBuffer;
IDataBuffer* mBufferPipeline[MAX_PIPELINE_BUFFERS];
IDataBuffer* mBufferPipeline[HW_MAX_PIPELINE_BUFFERS];
int mPipelineNbr;
int mPipelinePos = 0;

View file

@ -1,4 +1,4 @@
#include "doomdef.h"
#include "tarray.h"
#include "hwrenderer/data/buffers.h"
@ -8,7 +8,7 @@ class FRenderState;
class HWViewpointBuffer
{
IDataBuffer *mBuffer;
IDataBuffer* mBufferPipeline[MAX_PIPELINE_BUFFERS];
IDataBuffer* mBufferPipeline[HW_MAX_PIPELINE_BUFFERS];
int mPipelineNbr;
int mPipelinePos = 0;

View file

@ -255,6 +255,4 @@ enum
#define BLINKTHRESHOLD (4*32)
#define MAX_PIPELINE_BUFFERS 8
#endif // __DOOMDEF_H__

View file

@ -38,6 +38,8 @@
#include "texmanip.h"
#include "fcolormap.h"
#include "hwrenderer/data/buffers.h"
// Some more or less basic data types
// we depend on.
#include "m_fixed.h"
@ -698,7 +700,7 @@ struct sector_t
int vboindex[4]; // VBO indices of the 4 planes this sector uses during rendering. This is only needed for updating plane heights.
int iboindex[4]; // IBO indices of the 4 planes this sector uses during rendering
double vboheight[MAX_PIPELINE_BUFFERS][2]; // Last calculated height for the 2 planes of this actual sector
double vboheight[HW_MAX_PIPELINE_BUFFERS][2]; // Last calculated height for the 2 planes of this actual sector
int vbocount[2]; // Total count of vertices belonging to this sector's planes. This is used when a sector height changes and also contains all attached planes.
int ibocount; // number of indices per plane (identical for all planes.) If this is -1 the index buffer is not in use.