mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
Merge branch 'main' into fix-basic-parser-exponential-notation
This commit is contained in:
commit
98dfeb8da6
3 changed files with 11 additions and 4 deletions
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
namespace util {
|
||||
template<typename T>
|
||||
inline T read_int_le(const uint8_t* src, ptrdiff_t offset=0) {
|
||||
inline T read_int_le(const uint8_t* src) {
|
||||
T tmp;
|
||||
std::memcpy(&tmp, src + offset * sizeof(T), sizeof(T));
|
||||
std::memcpy(&tmp, src, sizeof(T));
|
||||
return dataio::le2h(tmp);
|
||||
}
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ namespace util {
|
|||
if (ptr == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return read_int_le<Tsize>(ptr, -1);
|
||||
return read_int_le<Tsize>(ptr - sizeof(Tsize));
|
||||
}
|
||||
|
||||
/// @return number of entries
|
||||
|
|
@ -177,7 +177,7 @@ namespace util {
|
|||
) : buffer(buffer), index(index), offset(offset) {}
|
||||
|
||||
Tsize size() const {
|
||||
return read_int_le<Tsize>(buffer.data() + offset, -1);
|
||||
return read_int_le<Tsize>(buffer.data() + offset - sizeof(Tsize));
|
||||
}
|
||||
|
||||
bool operator!=(const const_iterator& o) const {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ static void init_gl_extensions_list() {
|
|||
}
|
||||
}
|
||||
|
||||
[[maybe_unused]]
|
||||
static bool is_gl_extension_supported(const char *extension) {
|
||||
if (!extension || !*extension) {
|
||||
return false;
|
||||
|
|
@ -40,6 +41,7 @@ static bool is_gl_extension_supported(const char *extension) {
|
|||
return supported_gl_extensions.find(extension) != supported_gl_extensions.end();
|
||||
}
|
||||
|
||||
#ifndef __APPLE__
|
||||
static const char* gl_error_name(int error) {
|
||||
switch (error) {
|
||||
case GL_DEBUG_TYPE_ERROR: return "ERROR";
|
||||
|
|
@ -80,6 +82,7 @@ static void GLAPIENTRY gl_message_callback(
|
|||
logger.warning() << "GL:" << gl_error_name(type) << ":"
|
||||
<< gl_severity_name(severity) << ": " << message;
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool initialize_gl(int width, int height) {
|
||||
glewExperimental = GL_TRUE;
|
||||
|
|
|
|||
|
|
@ -8,9 +8,13 @@ TEST(SmallHeap, Allocation) {
|
|||
auto index = 0;
|
||||
auto size = 4;
|
||||
|
||||
std::cout << "step 1" << std::endl;
|
||||
SmallHeap<uint16_t, uint8_t> map;
|
||||
std::cout << "step 2" << std::endl;
|
||||
auto ptr = map.allocate(index, size);
|
||||
std::cout << "ptr: " << (void*)ptr << " le2h(1): " << dataio::le2h(1) << " h2le(1): " << dataio::h2le(1) << std::endl;
|
||||
EXPECT_EQ(map.sizeOf(ptr), size);
|
||||
std::cout << "step 4" << std::endl;
|
||||
EXPECT_EQ(ptr, map.find(index));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue