Changeset 26072

Timestamp:
Dec 15, 2021, 7:43:41 AM (3 years ago)
Author:
Vladislav Belov
Message:

Encapsulates information about GL inside device.

Commented By: Stan

Differential Revision: https://code.wildfiregames.com/D4375

Location:
ps/trunk
Files:
4 added
2 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/build/premake/premake5.lua

    r26040 r26072  
    773773        "graphics/scripting",
    774774        "renderer",
     775
     776
    775777        "renderer/scripting",
    776778        "third_party/mikktspace",
  • ps/trunk/source/lib/ogl.cpp

    r25982 r26072  
    3434#include "lib/external_libraries/libsdl.h"
    3535#include "lib/debug.h"
    36 #include "lib/sysdep/gfx.h"
    3736#include "lib/res/h_mgr.h"
    3837
  • ps/trunk/source/lib/ogl.h

    r19503 r26072  
    1 /* Copyright (C) 2017 Wildfire Games.
     1/* Copyright (C) 20 Wildfire Games.
    22 *
    33 * Permission is hereby granted, free of charge, to any person obtaining
     
    3333/**
    3434 * initialization: import extension function pointers and do feature detect.
    35  * call before using any other function, and after each video mode change.
     35 * call before using any other function.
    3636 * fails if OpenGL not ready for use.
    3737 **/
  • ps/trunk/source/lib/sysdep/os/osx/osx.cpp

    r23754 r26072  
    1 /* Copyright (C) 2020 Wildfire Games.
     1/* Copyright (C) 202 Wildfire Games.
    22 *
    33 * Permission is hereby granted, free of charge, to any person obtaining
     
    2525#include "lib/lib.h"
    2626#include "lib/sysdep/sysdep.h"
    27 #include "lib/sysdep/gfx.h"
    2827#include "lib/utf8.h"
    2928#include "osx_bundle.h"
  • ps/trunk/source/lib/sysdep/os/win/wgfx.cpp

    r23754 r26072  
    1 /* Copyright (C) 2020 Wildfire Games.
     1/* Copyright (C) 202 Wildfire Games.
    22 *
    33 * Permission is hereby granted, free of charge, to any person obtaining
     
    2828#include "lib/sysdep/os/win/wgfx.h"
    2929
    30 #include "lib/sysdep/gfx.h"
    3130#include "lib/sysdep/os/win/wdll_ver.h"
    3231#include "lib/sysdep/os/win/wutil.h"
  • ps/trunk/source/ps/GameSetup/GameSetup.cpp

    r26065 r26072  
    932932    g_GUI = new CGUIManager();
    933933
    934     // (must come after SetVideoMode, since it calls ogl_Init)
    935934    CStr8 renderPath = "default";
    936935    CFG_GET_VAL("renderpath", renderPath);
    937     if ((ogl_HaveExtensions(0, "GL_ARB_vertex_program", "GL_ARB_fragment_program", nullptr) // ARB
    938         && ogl_HaveExtensions(0, "GL_ARB_vertex_shader", "GL_ARB_fragment_shader", nullptr)) // GLSL
    939         || !ogl_HaveExtension("GL_ARB_vertex_buffer_object") // VBO
    940         || ogl_HaveExtensions(0, "GL_ARB_multitexture", "GL_EXT_draw_range_elements", nullptr)
    941         || (!ogl_HaveExtension("GL_EXT_framebuffer_object") && !ogl_HaveExtension("GL_ARB_framebuffer_object"))
    942         || RenderPathEnum::FromString(renderPath) == FIXED)
     936    if (RenderPathEnum::FromString(renderPath) == FIXED)
    943937    {
    944938        // It doesn't make sense to continue working here, because we're not
  • ps/trunk/source/ps/GameSetup/HWDetect.cpp

    r26040 r26072  
    2626#include "lib/posix/posix_utsname.h"
    2727#include "lib/sysdep/cpu.h"
    28 #include "lib/sysdep/gfx.h"
    2928#include "lib/sysdep/numa.h"
    3029#include "lib/sysdep/os_cpu.h"
     
    4443#include "ps/UserReport.h"
    4544#include "ps/VideoMode.h"
     45
    4646#include "scriptinterface/FunctionWrapper.h"
    4747#include "scriptinterface/JSON.h"
     
    161161    Script::SetProperty(rq, settings, "build_clang", (int)CLANG_VERSION);
    162162
    163     Script::SetProperty(rq, settings, "gfx_card", gfx::CardName());
    164     Script::SetProperty(rq, settings, "gfx_drv_ver", gfx::DriverInfo());
     163    Script::SetProperty(rq, settings, "gfx_card", gName());
     164    Script::SetProperty(rq, settings, "gfx_drv_ver", g());
    165165#if CONFIG2_AUDIO
    166166    if (g_SoundManager)
  • ps/trunk/source/ps/GameSetup/HWDetect.h

    r8663 r26072  
    1 /* Copyright (C) 2010 Wildfire Games.
     1/* Copyright (C) 20 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
     
    2222 * Runs hardware-detection script to adjust default config settings
    2323 * and/or emit warnings depending on the user's system configuration.
    24  * This must only be called after ogl_Init.
     24 * This must only be called after .
    2525 */
    2626void RunHardwareDetection();
  • ps/trunk/source/ps/Util.cpp

    r25936 r26072  
    2929#include "lib/sysdep/arch/x86_x64/topology.h"
    3030#endif
    31 #include "lib/sysdep/gfx.h"
    3231#include "lib/sysdep/cpu.h"
    3332#include "lib/sysdep/os_cpu.h"
     
    4544#include "ps/Pyrogenesis.h"
    4645#include "ps/VideoMode.h"
     46
    4747#include "renderer/Renderer.h"
    4848
     
    5353#include <iomanip>
    5454#include <sstream>
    55 
    56 static std::string SplitExts(const char *exts)
    57 {
    58     std::string str = exts;
    59     std::string ret = "";
    60     size_t idx = str.find_first_of(" ");
    61     while(idx != std::string::npos)
    62     {
    63         if(idx >= str.length() - 1)
    64         {
    65             ret += str;
    66             break;
    67         }
    68 
    69         ret += str.substr(0, idx);
    70         ret += "\n";
    71         str = str.substr(idx + 1);
    72         idx = str.find_first_of(" ");
    73     }
    74 
    75     return ret;
    76 }
    77 
    7855
    7956void WriteSystemInfo()
     
    127104
    128105    // graphics
    129     const std::wstring cardName = gfx::CardName();
    130     const std::wstring driverInfo = gfx::DriverInfo();
    131     fprintf(f, "Graphics Card  : %ls\n", cardName.c_str());
    132     fprintf(f, "OpenGL Drivers : %s; %ls\n", glGetString(GL_VERSION), driverInfo.c_str());
     106    fprintf(f, "Video Card     : %s\n", g_VideoMode.GetBackendDevice()->GetName().c_str());
     107    fprintf(f, "Video Driver   : %s\n", g_VideoMode.GetBackendDevice()->GetDriverInformation().c_str());
    133108    fprintf(f, "Video Mode     : %dx%d:%d\n", g_VideoMode.GetXRes(), g_VideoMode.GetYRes(), g_VideoMode.GetBPP());
    134109
     
    148123
    149124    // OpenGL extensions (write them last, since it's a lot of text)
    150     const char* exts = ogl_ExtensionString();
    151     if (!exts) exts = "{unknown}";
    152     fprintf(f, "\nOpenGL Extensions: \n%s\n", SplitExts(exts).c_str());
     125    fprintf(f, "\nBackend Extensions:\n");
     126    if (g_VideoMode.GetBackendDevice()->GetExtensions().empty())
     127        fprintf(f, "{unknown}\n");
     128    else
     129        for (const std::string& extension : g_VideoMode.GetBackendDevice()->GetExtensions())
     130            fprintf(f, "%s\n", extension.c_str());
    153131
    154132    // System Management BIOS (even more text than OpenGL extensions)
  • ps/trunk/source/ps/VideoMode.cpp

    r26069 r26072  
    2525#include "lib/external_libraries/libsdl.h"
    2626#include "lib/ogl.h"
    27 #include "lib/sysdep/gfx.h"
    2827#include "lib/tex/tex.h"
    2928#include "ps/CConsole.h"
     
    3534#include "ps/GameSetup/Config.h"
    3635#include "ps/Pyrogenesis.h"
     36
    3737#include "renderer/Renderer.h"
    3838
     
    287287        }
    288288
    289         m_Context = SDL_GL_CreateContext(m_Window);
    290         if (!m_Context)
    291         {
    292             LOGERROR("SetVideoMode failed in SDL_GL_CreateContext: %dx%d:%d %d (\"%s\")",
    293                 w, h, bpp, fullscreen ? 1 : 0, SDL_GetError());
     289#if OS_WIN
     290        // We need to set the window for an error dialog.
     291        wutil_SetAppWindow(m_Window);
     292#endif
     293
     294        if (!CreateBackendDevice(true))
     295        {
     296            LOGERROR("SetVideoMode failed in backend device creation: %dx%d:%d %d",
     297                w, h, bpp, fullscreen ? 1 : 0);
    294298            return false;
    295299        }
     
    330334    else
    331335        SDL_SetWindowGrab(m_Window, SDL_FALSE);
    332 
    333 #if OS_WIN
    334     // We need to set the window for an error dialog.
    335     wutil_SetAppWindow(m_Window);
    336 #endif
    337336
    338337    m_IsFullscreen = fullscreen;
     
    469468    // End work around.
    470469
    471     ogl_Init(); // required after each mode change
    472     // (TODO: does that mean we need to call this when toggling fullscreen later?)
    473 
    474470    m_IsInitialised = true;
    475471
     
    506502    m_IsFullscreen = false;
    507503    m_IsInitialised = false;
    508     if (m_Context)
    509     {
    510         SDL_GL_DeleteContext(m_Context);
    511         m_Context = nullptr;
    512     }
     504    m_BackendDevice.reset();
    513505    if (m_Window)
    514506    {
     
    516508        m_Window = nullptr;
    517509    }
     510
     511
     512
     513
     514
     515
    518516}
    519517
  • ps/trunk/source/ps/VideoMode.h

    r26069 r26072  
    2525typedef struct SDL_Window SDL_Window;
    2626typedef void* SDL_GLContext;
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
    2738
    2839class CVideoMode
     
    5364     */
    5465    void Shutdown();
     66
     67
     68
     69
     70
     71
    5572
    5673    /**
     
    113130    Backend GetBackend() const { return m_Backend; }
    114131
     132
     133
    115134private:
    116135    void ReadConfig();
     
    126145
    127146    SDL_Window* m_Window = nullptr;
    128     SDL_GLContext m_Context = nullptr;
    129147
    130148    // Initial desktop settings.
     
    168186
    169187    Backend m_Backend = Backend::GL;
     188
    170189};
    171190
  • ps/trunk/source/renderer/Renderer.cpp

    r26069 r26072  
    13891389    bool checkGLErrorAfterSwap = false;
    13901390    CFG_GET_VAL("gl.checkerrorafterswap", checkGLErrorAfterSwap);
     1391
    13911392    if (!checkGLErrorAfterSwap)
    13921393        return;
     1394
    13931395    PROFILE3("error check");
    13941396    // We have to check GL errors after SwapBuffer to avoid possible
  • ps/trunk/source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp

    r26024 r26072  
    112112    UNUSED2(msg);
    113113
    114     ogl_Init();
     114    );
    115115
    116116    InitGraphics(g_AtlasGameLoop->args, g_InitFlags, {});
Note: See TracChangeset for help on using the changeset viewer.