Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7a1c574
wip(vtfpp): initial vtf parser work
craftablescience May 28, 2024
e81e085
wip(vtfpp): add conversion functions to get meaningful resource data
craftablescience May 28, 2024
5567c6f
wip(vtfpp): add face count getter
craftablescience May 28, 2024
070136c
wip(vtfpp): correctly parse data from every vtf version except 7.6
craftablescience May 28, 2024
9a44fed
wip(vtfpp): correctly parse non-dxt image formats
craftablescience May 28, 2024
7f9f10d
wip(vtfpp): begin work on image conversion functions
craftablescience May 28, 2024
610fa73
wip(vtfpp): finish conversion functions to rgba8888
craftablescience May 28, 2024
eedb484
wip(vtfpp): add conversion functions from rgba8888
craftablescience May 28, 2024
469d377
wip(vtfpp): make sure all formats can convert into each other
craftablescience May 28, 2024
b11be80
wip(vtfpp): decode compressed image data
craftablescience May 29, 2024
2b910c7
wip(vtfpp): fix linux compressonator build
craftablescience May 29, 2024
955ee61
fix(ci): update checkout step
craftablescience May 29, 2024
9f38711
wip(vtfpp): add tests for almost every format converted to rgba8888
craftablescience May 29, 2024
fbb38c4
wip(vtfpp): fix bluescreen alpha decoding, fix argb decoding
craftablescience May 29, 2024
965d1eb
wip(vtfpp): fix bluescreen alpha encoding
craftablescience May 29, 2024
a78fdeb
chore: improve file format table in readme
craftablescience May 29, 2024
a86db5f
wip(vtfpp): fix rgba8888 -> rgb565/bgr565 conversions, fix accessing …
craftablescience May 29, 2024
df52c3c
chore(all): bump bufferstream
craftablescience May 30, 2024
40fb2ef
wip(vtfpp): fix all conversions to rgba8888
craftablescience May 30, 2024
ba8cc59
wip(vtfpp): clean up interface
craftablescience May 30, 2024
6c0fce9
wip(vtfpp): add mip argument to width/height getters
craftablescience May 30, 2024
f4028b6
chore: bump bufferstream
craftablescience Jun 1, 2024
b87ad96
feat: reduce unnecessary copies of vectors
craftablescience Jun 2, 2024
09077d1
chore: move createFile to test helpers
craftablescience Jun 2, 2024
6803f35
fix: get rid of std::move spam
craftablescience Jun 2, 2024
fd812aa
fix: possibly fix invalid span crash
craftablescience Jun 2, 2024
2625ef8
fix: all implemented conversions
craftablescience Jun 2, 2024
0dd0350
wip(vtfpp): add more compressonator format mappings
craftablescience Jun 5, 2024
d60b6e2
wip(vtfpp): remove more dumb std::move
craftablescience Jun 5, 2024
b741ae8
wip(vtfpp): add vtf 7.6 support
craftablescience Jun 6, 2024
e9947e5
wip(vtfpp): remove debug lines
craftablescience Jun 6, 2024
adb34fe
wip(vtfpp): fill in float conversion functions
craftablescience Jun 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
shell: cmd
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "src/thirdparty/bufferstream"]
path = src/thirdparty/bufferstream
url = https://github.com/craftablescience/BufferStream
[submodule "src/thirdparty/miniz"]
path = src/thirdparty/miniz
url = https://github.com/richgel999/miniz
73 changes: 65 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,49 @@
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
project(sourcepp)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


# Options (General)
option(SOURCEPP_USE_DMXPP "Build dmxpp library" ON)
option(SOURCEPP_USE_FGDPP "Build fgdpp library" ON)
option(SOURCEPP_USE_STUDIOMODELPP "Build studiomodelpp library" ON)
option(SOURCEPP_USE_VMFPP "Build vmfpp library" ON)
option(SOURCEPP_BUILD_TESTS "Build tests for enabled libraries" OFF)
option(SOURCEPP_USE_DMXPP "Build dmxpp library" ON)
option(SOURCEPP_USE_FGDPP "Build fgdpp library" ON)
option(SOURCEPP_USE_STUDIOMODELPP "Build studiomodelpp library" ON)
option(SOURCEPP_USE_VMFPP "Build vmfpp library" ON)
option(SOURCEPP_USE_VTFPP "Build vtfpp library" ON)
option(SOURCEPP_BUILD_TESTS "Build tests for enabled libraries" OFF)
option(SOURCEPP_USE_STATIC_MSVC_RUNTIME "Link to static MSVC runtime library" OFF)


# Options (Library)
option(FGDPP_ENABLE_SPEN_FGD_SUPPORT "Enable support for FGD alterations (https://github.com/TeamSpen210/HammerAddons/wiki/Unified-FGD) made by TeamSpen's HammerAddons. Fully backwards compatible with Valve's FGD standard." OFF)


# BufferStream
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/bufferstream")
# Set defaults
if(PROJECT_IS_TOP_LEVEL)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

if(SOURCEPP_USE_STATIC_MSVC_RUNTIME)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()


# bufferstream
if(NOT TARGET bufferstream)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/bufferstream")
endif()


# miniz
if(SOURCEPP_USE_VTFPP AND NOT TARGET miniz)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/miniz")
endif()


# stb_image
if(SOURCEPP_USE_VTFPP)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/stb_image")
endif()


# Shared code
Expand Down Expand Up @@ -108,6 +134,37 @@ if(SOURCEPP_USE_VMFPP)
endif()


# vtfpp
if(SOURCEPP_USE_VTFPP)
add_pretty_parser(vtfpp SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/include/vtfpp/ImageConversion.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/vtfpp/ImageFormats.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/vtfpp/vtfpp.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/vtfpp/ImageConversion.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/vtfpp/vtfpp.cpp")
target_link_libraries(vtfpp PRIVATE miniz stb_image)

# Compressonator
if(MSVC)
if(SOURCEPP_USE_STATIC_MSVC_RUNTIME)
target_link_libraries(vtfpp PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/compressonator/lib/win64/Compressonator_MT$<$<CONFIG:Debug>:d>.lib")
else()
target_link_libraries(vtfpp PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/compressonator/lib/win64/Compressonator_MD$<$<CONFIG:Debug>:d>.lib")
endif()
elseif(UNIX)
target_link_libraries(vtfpp PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/compressonator/lib/linux64/libCMP_Compressonator.a"
"${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/compressonator/lib/linux64/libCMP_Core.a"
"${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/compressonator/lib/linux64/libCMP_Core_AVX.a"
"${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/compressonator/lib/linux64/libCMP_Core_AVX512.a"
"${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/compressonator/lib/linux64/libCMP_Core_SSE.a")
else()
message(FATAL_ERROR "Unable to link to Compressonator library!")
endif()
target_include_directories(vtfpp PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/compressonator/include")
endif()


# Tests, part 2
if(SOURCEPP_BUILD_TESTS)
add_executable(${SOURCEPP_TEST_NAME} ${${SOURCEPP_TEST_NAME}_SOURCES})
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Looking for more parsers in this vein? Try my other project which relies on this

| Library Name | Supports | Read | Write | Author(s) |
|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----:|:-----:|------------------------------------------------------------------------------------------------|
| dmxpp | [DMX](https://developer.valvesoftware.com/wiki/DMX) Binary v1-5 | ✅ | ❌ | [@craftablescience](https://github.com/craftablescience) |
| fgdpp | &bull; [Valve FGD syntax](https://developer.valvesoftware.com/wiki/FGD)<br>&bull; [TeamSpen's Unified FGD syntax](https://github.com/TeamSpen210/HammerAddons/wiki/Unified-FGD) | ✅ | ❌ | [@Trico-Everfire](https://github.com/Trico-Everfire) |
| dmxpp | &bull; [DMX](https://developer.valvesoftware.com/wiki/DMX) Binary v1-5 | ✅ | ❌ | [@craftablescience](https://github.com/craftablescience) |
| fgdpp | &bull; [FGD](https://developer.valvesoftware.com/wiki/FGD)<br>&bull; [TeamSpen's Unified FGD](https://github.com/TeamSpen210/HammerAddons/wiki/Unified-FGD) | ✅ | ❌ | [@Trico-Everfire](https://github.com/Trico-Everfire) |
| studiomodelpp | &bull; [MDL](https://developer.valvesoftware.com/wiki/MDL_(Source)) v44-49<br>&bull; [VTX](https://developer.valvesoftware.com/wiki/VTX) v7<br>&bull; [VVD](https://developer.valvesoftware.com/wiki/VVD) v4 | ✅ | ❌ | [@craftablescience](https://github.com/craftablescience) |
| vmfpp | Any [VMF](https://developer.valvesoftware.com/wiki/VMF_(Valve_Map_Format)) | ✅ | ❌ | [@Galaco](https://github.com/Galaco), [@craftablescience](https://github.com/craftablescience) |
| vmfpp | &bull; [VMF](https://developer.valvesoftware.com/wiki/VMF_(Valve_Map_Format)) | ✅ | ❌ | [@Galaco](https://github.com/Galaco), [@craftablescience](https://github.com/craftablescience) |
| vtfpp | &bull; [VTF](https://developer.valvesoftware.com/wiki/VTF_(Valve_Texture_Format)) v7.0-7.6 | ✅ | ❌ | [@craftablescience](https://github.com/craftablescience) |
16 changes: 16 additions & 0 deletions include/vtfpp/ImageConversion.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <cstddef>
#include <span>
#include <vector>

#include "ImageFormats.h"

namespace vtfpp::ImageConversion {

[[nodiscard]] std::vector<std::byte> convertImageDataToFormat(std::span<const std::byte> imageData, ImageFormat oldFormat, ImageFormat newFormat, uint16_t width, uint16_t height);

/// Converts image data to a PNG or HDR file. HDR output will be used for floating-point formats.
[[nodiscard]] std::vector<std::byte> convertImageDataToFile(std::span<const std::byte> imageData, ImageFormat format, uint16_t width, uint16_t height);

} // namespace vtfpp::ImageConversion
Loading