Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Windmill-City committed Aug 17, 2023
1 parent 8b0a4b9 commit 8ad924a
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 10 deletions.
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ endif(WIN32)
# ####################################
# Embed Assets Build Tools
# ####################################
add_executable(ResourceBuilder EXCLUDE_FROM_ALL ResourceBuilder.cpp)
add_executable(ResourceBuilder EXCLUDE_FROM_ALL builder/ResourceBuilder.cpp)
target_include_directories(ResourceBuilder PRIVATE include)

# Build embed assets
if(MSVC)
add_executable(MSVC_bin2obj MSVC_bin2obj.cpp)
add_executable(MSVC_bin2obj builder/MSVC_bin2obj.cpp)
target_include_directories(MSVC_bin2obj PRIVATE include)

add_custom_target(BuildEmbed
Expand Down Expand Up @@ -79,5 +79,10 @@ enable_testing()

# GTest
set(GTEST ctest/gtest/googletest)
add_library(GTEST STATIC EXCLUDE_FROM_ALL ${GTEST}/src/gtest-all.cc)
target_include_directories(GTEST PUBLIC ${GTEST}/include ${GTEST})
add_library(gtest STATIC EXCLUDE_FROM_ALL ${GTEST}/src/gtest-all.cc)
target_include_directories(gtest PUBLIC ${GTEST}/include ${GTEST})

# Unicode test
add_executable(T_Unicode ctest/T_Unicode.cpp)
target_include_directories(T_Unicode PRIVATE include)
target_link_libraries(T_Unicode PRIVATE gtest)
7 changes: 5 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ My learn OpenGL
| Encoding | Codepoint format in bytes | UTF-8; UTF-16; ANSI; |
---

### Common Regulations

Following table shows the encoding of the strings depends on their physical location:

| Physical Location | Encoding |
| ----------------- | -------- |
| Network | UTF-8 |
| Disk | UTF-8 |
| Memory(Windows) | UTF-16 |
| Memory(Linux) | UTF-32 |
Expand All @@ -36,9 +39,9 @@ Following table shows the encoding of the strings depends on their storage class

Note: Encoding here is **NOT** regulated by any standard! This regulation only suits in **MY** program!

Note: These string classes won't deal with encodings, which means `split()`,`length()`, `size()`, are base on **bytes** not codepoints.
Note: These classes knows nothing about encodings, and so they **CAN'T** deal with **Variable Length** encodings.

---
### Locale

Before using some locale dependent C APIs, we need to set correct locale to ensure correct codepage and encoding are used. The following code do this thing:

Expand Down
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions ctest/T_Unicode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <gtest/gtest.h>
#include <iostream>

TEST(Unicode, _setlocale)
{
// UTF-8(File Encoding)
std::cout << "你好世界! Hello World!" << std::endl;
// UTF-8
std::cout << (const char*)u8"你好世界! Hello World!" << std::endl;
// UTF-16(Windows)/UTF-32(Linux)
std::wcout << L"你好世界! Hello World!" << std::endl;

setlocale(LC_ALL, ".UTF-8");

// UTF-8(File Encoding)
std::cout << "你好世界! Hello World!" << std::endl;
// UTF-8
std::cout << (const char*)u8"你好世界! Hello World!" << std::endl;
// UTF-16(Windows)/UTF-32(Linux)
std::wcout << L"你好世界! Hello World!" << std::endl;
}

int main(int argc, char** argv)
{
printf("Running main() from %s\n", __FILE__);
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
2 changes: 1 addition & 1 deletion include/Shader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct Shader
Shader() = default;
~Shader();

Shader(Shader&& _Right);
Shader(Shader&& _right);
Shader(const Shader&) = delete;

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Shader::~Shader()
glDeleteProgram(ProgramID);
}

Shader::Shader(Shader&& _Right)
: ProgramID(_Right.ProgramID)
Shader::Shader(Shader&& _right)
: ProgramID(_right.ProgramID)
{
_Right.ProgramID = 0;
_right.ProgramID = 0;
}

void Shader::use() const
Expand Down
2 changes: 2 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "Main.hpp"

#include <Windows.h>

void framebuffer_size_callback(GLFWwindow* window, int width, int height);
void processInput(GLFWwindow* window);

Expand Down

0 comments on commit 8ad924a

Please sign in to comment.