Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
levinli303 committed Feb 20, 2024
2 parents 954918d + c27b545 commit 1c3b655
Show file tree
Hide file tree
Showing 62 changed files with 2,568 additions and 3,322 deletions.
2 changes: 1 addition & 1 deletion debian/celestia-gtk.install
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
usr/bin/celestia-gtk
usr/share/celestia/celestiaui.xml
usr/share/applications/celestia-gtk.desktop
usr/share/metainfo/space.celestia.celestia_gtk.metainfo.xml
usr/share/metainfo/space.celestiaproject.Celestia-gtk.metainfo.xml
usr/share/man/man1/celestia-gtk.1
2 changes: 1 addition & 1 deletion debian/celestia-qt5.install
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
usr/bin/celestia-qt5
usr/share/applications/celestia-qt5.desktop
usr/share/metainfo/space.celestia.celestia_qt5.metainfo.xml
usr/share/metainfo/space.celestiaproject.Celestia-qt5.metainfo.xml
usr/share/man/man1/celestia-qt5.1
515 changes: 207 additions & 308 deletions po/bg.po

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions src/celcompat/charconv_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include <config.h>

#include <celutil/localeutil.h>

#include "charconv_impl.h"

namespace celestia::compat
Expand All @@ -30,6 +32,7 @@ constexpr std::size_t inf_length = 3;
constexpr std::size_t infinity_length = 8;
constexpr std::size_t nan_length = 3;
constexpr std::size_t hex_prefix_length = 2;
locale_t numberParsingLocale = nullptr;

enum class State
{
Expand Down Expand Up @@ -167,19 +170,19 @@ write_buffer(const char* first, const char* last, chars_format fmt, char* buffer
inline void
parse_value(const char* start, char** end, float& value)
{
value = std::strtof(start, end);
value = strtof_l(start, end, numberParsingLocale);
}

inline void
parse_value(const char* start, char** end, double& value)
{
value = std::strtod(start, end);
value = strtod_l(start, end, numberParsingLocale);
}

inline void
parse_value(const char* start, char** end, long double& value)
{
value = std::strtold(start, end);
value = strtold_l(start, end, numberParsingLocale);
}

template<typename T>
Expand All @@ -191,8 +194,9 @@ from_chars_impl(const char* first, const char* last, T& value, chars_format fmt)
from_chars_result result = write_buffer(first, last, fmt, buffer, hex_prefix);
if (result.ec != std::errc{}) { return result; }

const char* savedLocale = std::setlocale(LC_NUMERIC, nullptr);
std::setlocale(LC_NUMERIC, "C");
if (numberParsingLocale == nullptr)
numberParsingLocale = newlocale(LC_NUMERIC_MASK, "C", nullptr);

errno = 0;
char* end;
T parsed;
Expand All @@ -213,7 +217,6 @@ from_chars_impl(const char* first, const char* last, T& value, chars_format fmt)
result = { first + (end - buffer), std::errc{} };
}

std::setlocale(LC_NUMERIC, savedLocale);
return result;
}

Expand Down
10 changes: 0 additions & 10 deletions src/celengine/framebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class FramebufferObject
FramebufferObject& operator=(FramebufferObject&&) noexcept;
~FramebufferObject();

static inline bool isSupported();
bool isValid() const;
GLuint width() const
{
Expand Down Expand Up @@ -60,12 +59,3 @@ class FramebufferObject
GLuint m_fboId;
GLenum m_status;
};

bool FramebufferObject::isSupported()
{
#ifdef GL_ES
return true;
#else
return celestia::gl::ARB_framebuffer_object;
#endif
}
8 changes: 7 additions & 1 deletion src/celengine/glsupport.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "glsupport.h"
#include <algorithm>
#include <cstring>
#include <fmt/format.h>
#include <celutil/gettext.h>

namespace celestia::gl
{
Expand Down Expand Up @@ -81,7 +83,11 @@ bool init(util::array_view<std::string> ignore) noexcept
OES_geometry_shader = check_extension(ignore, "GL_OES_geometry_shader") || check_extension(ignore, "GL_EXT_geometry_shader");
#else
ARB_vertex_array_object = check_extension(ignore, "GL_ARB_vertex_array_object");
ARB_framebuffer_object = check_extension(ignore, "GL_ARB_framebuffer_object") || check_extension(ignore, "GL_EXT_framebuffer_object");
if (!has_extension("GL_ARB_framebuffer_object"))
{
fmt::print(_("Mandatory extension GL_ARB_framebuffer_object is missing!\n"));
return false;
}
#endif
ARB_shader_texture_lod = check_extension(ignore, "GL_ARB_shader_texture_lod");
EXT_texture_compression_s3tc = check_extension(ignore, "GL_EXT_texture_compression_s3tc");
Expand Down
1 change: 0 additions & 1 deletion src/celengine/glsupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ extern CELAPI bool OES_texture_border_clamp; //NOSONAR
extern CELAPI bool OES_geometry_shader; //NOSONAR
#else
extern CELAPI bool ARB_vertex_array_object; //NOSONAR
extern CELAPI bool ARB_framebuffer_object; //NOSONAR
#endif
extern CELAPI GLint maxPointSize; //NOSONAR
extern CELAPI GLint maxTextureSize; //NOSONAR
Expand Down
8 changes: 8 additions & 0 deletions src/celengine/overlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#pragma once

#include <locale>
#include <string>
#include <vector>
#include <fmt/printf.h>
Expand Down Expand Up @@ -60,6 +61,13 @@ class Overlay

void print(std::string_view);

template <typename... T>
void print(const std::locale& loc, std::string_view format, const T&... args)
{
static_assert(sizeof...(args) > 0);
print(fmt::format(loc, format, args...));
}

template <typename... T>
void print(std::string_view format, const T&... args)
{
Expand Down
2 changes: 0 additions & 2 deletions src/celengine/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4811,8 +4811,6 @@ Renderer::createShadowFBO()
void
Renderer::setShadowMapSize(unsigned size)
{
if (!FramebufferObject::isSupported())
return;
m_shadowMapSize = std::min(size, static_cast<unsigned>(gl::maxTextureSize));
if (m_shadowFBO != nullptr && m_shadowMapSize == m_shadowFBO->width())
return;
Expand Down
44 changes: 6 additions & 38 deletions src/celengine/texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,6 @@ ImageTexture::ImageTexture(const Image& img,
}

bool genMipmaps = mipmap && !precomputedMipMaps;
#ifndef GL_ES
if (genMipmaps && !FramebufferObject::isSupported())
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
#endif

if (mipmap)
{
Expand All @@ -511,7 +507,7 @@ ImageTexture::ImageTexture(const Image& img,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
#endif
}
if (genMipmaps && FramebufferObject::isSupported())
if (genMipmaps)
glGenerateMipmap(GL_TEXTURE_2D);

alpha = img.hasAlpha();
Expand Down Expand Up @@ -689,25 +685,9 @@ TiledTexture::TiledTexture(const Image& img,
}
}

LoadMiplessTexture(*tile, GL_TEXTURE_2D);
if (mipmap)
{
if (FramebufferObject::isSupported())
{
LoadMiplessTexture(*tile, GL_TEXTURE_2D);
glGenerateMipmap(GL_TEXTURE_2D);
}
#ifndef GL_ES
else
{
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
LoadMiplessTexture(*tile, GL_TEXTURE_2D);
}
#endif
}
else
{
LoadMiplessTexture(*tile, GL_TEXTURE_2D);
}
glGenerateMipmap(GL_TEXTURE_2D);
}
}
}
Expand Down Expand Up @@ -810,29 +790,17 @@ CubeMap::CubeMap(celestia::util::array_view<const Image*> faces) :

bool genMipmaps = mipmap && !precomputedMipMaps;

#if !defined(GL_ES)
if (genMipmaps && !FramebufferObject::isSupported())
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_GENERATE_MIPMAP, GL_TRUE);
#endif

for (int i = 0; i < 6; i++)
{
auto targetFace = static_cast<GLenum>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i);
const Image* face = faces[i];

if (mipmap)
{
if (precomputedMipMaps)
LoadMipmapSet(*face, targetFace);
else
LoadMiplessTexture(*face, targetFace);
}
if (mipmap && precomputedMipMaps)
LoadMipmapSet(*face, targetFace);
else
{
LoadMiplessTexture(*face, targetFace);
}
}
if (genMipmaps && FramebufferObject::isSupported())
if (genMipmaps)
glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
}

Expand Down
Loading

0 comments on commit 1c3b655

Please sign in to comment.