summaryrefslogtreecommitdiff
path: root/src/binary_reader.hpp
diff options
context:
space:
mode:
authorFrederico Linhares <fred@linhares.blue>2023-06-23 20:45:23 -0300
committerFrederico Linhares <fred@linhares.blue>2023-06-28 10:43:13 -0300
commit8cb751ff015271e1844feece5db2113eaec64af3 (patch)
treecd6c698f46408d3b19d4eaea2547efaf3c651a1a /src/binary_reader.hpp
parent66eed8b7548c3e772d3bcb0d351608f0df81ecaf (diff)
feat Create an interface to read binary files
* test/meshes/cube.cgmesh: Store data using Big-Endian order.
Diffstat (limited to 'src/binary_reader.hpp')
-rw-r--r--src/binary_reader.hpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/binary_reader.hpp b/src/binary_reader.hpp
new file mode 100644
index 0000000..b2e4de5
--- /dev/null
+++ b/src/binary_reader.hpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2022-2023 Frederico de Oliveira Linhares
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <cstdint>
+#include <string>
+
+#include "vk/core.hpp"
+
+class BinaryReader
+{
+ int _pointer;
+ int _size;
+ uint8_t *data;
+
+public:
+
+ BinaryReader(const std::string file_path);
+ BinaryReader(const char *file_path);
+ ~BinaryReader();
+
+ inline int
+ pointer(){return this->_pointer;};
+
+ inline int
+ size(){return this->_size;};
+
+ uint8_t
+ read_ui8();
+
+ uint32_t
+ read_ui32();
+
+ glm::vec2
+ read_vec2();
+
+ glm::vec3
+ read_vec3();
+
+ void
+ read_chars(char *str, int size);
+};