Skip to content

Commit

Permalink
Merge branch 'feat/emcc'
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeokkim committed Dec 21, 2024
2 parents 7c52df5 + 3e814a7 commit e7585ee
Show file tree
Hide file tree
Showing 11 changed files with 464 additions and 240 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

# 설정 파일
*.manifest
**/bin/
**/.vs/
**/.vscode/

Expand Down
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Expand All @@ -23,7 +23,7 @@
# =============================================================================

.PHONY: all clean rebuild
.SUFFIXES: .c .exe .out
.SUFFIXES: .c .exe .html .out

# =============================================================================

Expand Down Expand Up @@ -82,7 +82,7 @@ build: ${TARGETS}
${TARGETS}: ${OBJECTS}
@mkdir -p ${BINARY_PATH}
@printf "${LOG_PREFIX} Linking: ${TARGETS}\n"
@${CC} ${OBJECTS} -o ${TARGETS} ${LDFLAGS} ${LDLIBS}
@${CC} ${OBJECTS} -o ${TARGETS} ${LDFLAGS} ${LDLIBS} ${WEBFLAGS}

post-build:
@printf "${LOG_PREFIX} Build complete.\n"
Expand All @@ -95,6 +95,8 @@ rebuild: clean all

clean:
@printf "${LOG_PREFIX} Cleaning up.\n"
@rm -f ${BINARY_PATH}/*.exe ${BINARY_PATH}/*.out ${SOURCE_PATH}/*.o
@rm -f ${BINARY_PATH}/*.data ${BINARY_PATH}/*.exe ${BINARY_PATH}/*.html \
${BINARY_PATH}/*.js ${BINARY_PATH}/*.out ${BINARY_PATH}/*.wasm \
${SOURCE_PATH}/*.o

# =============================================================================
61 changes: 61 additions & 0 deletions Makefile.emcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#
# Copyright (c) 2024 Jaedeok Kim <jdeokkim@protonmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#

# =============================================================================

.PHONY: all clean rebuild

# =============================================================================

# TODO: Edit these values to match your raylib installation path!
RAYLIB_INCLUDE_PATH = ../raylib/src
RAYLIB_LIBRARY_PATH = ../raylib/src

BINARY_PATH = bin
INCLUDE_PATH = include
LIBRARY_PATH = lib
RESOURCE_PATH = res
SOURCE_PATH = src

TARGET_SUFFIX = html

# =============================================================================

CC = emcc
CFLAGS = -D_DEFAULT_SOURCE -DPLATFORM_WEB -g -I${INCLUDE_PATH} \
-I${RAYLIB_INCLUDE_PATH} -I${INCLUDE_PATH}/raygui -I${RESOURCE_PATH} \
-O2 -std=gnu99
LDFLAGS = -L${RAYLIB_LIBRARY_PATH}
LDLIBS = -lraylib -ldl -lGL -lm -lpthread -lrt -lX11
WEBFLAGS = -s FORCE_FILESYSTEM -s FULL_ES3 -s INITIAL_MEMORY=67108864 \
-s USE_GLFW=3 --preload-file ${RESOURCE_PATH} \
--shell-file ${RESOURCE_PATH}/html/shell.html

CFLAGS += -Wno-limited-postlink-optimizations

# =============================================================================

all clean rebuild:
@${MAKE} TARGET_SUFFIX=${TARGET_SUFFIX} CC=${CC} CFLAGS="${CFLAGS}" \
LDFLAGS="${LDFLAGS}" LDLIBS="${LDLIBS}" WEBFLAGS="${WEBFLAGS}" $@

# =============================================================================
4 changes: 2 additions & 2 deletions Makefile.mingw
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Expand Down
270 changes: 149 additions & 121 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,121 +1,149 @@
# MVP Transform Visualizer



> "The engines don’t move the ship at all.
>
> **The ship stays where it is and the engines move the universe around it.**"
>
> — Futurama
A [raylib](https://github.com/raysan5/raylib) demo to visualize the Model, View, and Projection (MVP) matrices.

This project is a C rewrite of [@diskhkme](https://github.com/diskhkme)'s [MVP Transform Visualizer](https://github.com/diskhkme/mvp_transform_visualize) with additional features, for the "Computer Graphics" (1214-3005) course at Chungnam National University.

https://github.com/user-attachments/assets/4b7cda17-2f32-4651-9297-7070fb274da0

## Controls

- `ALT` + `0`: Draw All Spaces
- `ALT` + `1`: Draw Local Space
- `ALT` + `2`: Draw World Space
- `ALT` + `3`: Draw View Space
- `ALT` + `4`: Draw Clip Space
- `ESC`: Lock/Unlock Observer Camera
- `V`: Show/Hide Player Model Vertices

## Prerequisites

- GCC version 11.4.0+
- Git version 2.34.0+
- GNU Make version 4.3+
- raylib 5.0+

## Building

<details>
<summary>Compiling for Windows</summary>

### [w64devkit](https://github.com/skeeto/w64devkit)

Download the latest release of w64devkit from [here](https://github.com/skeeto/w64devkit/releases), extract the `.zip` file to your working directory, and run `w64devkit.exe`.

```console
$ cd .. && wget https://github.com/raysan5/raylib/archive/refs/tags/5.0.zip
$ unzip 5.0.zip && mv raylib-5.0 raylib
$ cd raylib/src && make
```

```console
$ git clone https://github.com/jdeokkim/mvp-demo
$ cd mvp-demo && make -f Makefile.mingw
```

</details>

<details>
<summary>Compiling for GNU/Linux</summary>

### Debian / Ubuntu

```console
$ sudo apt update && sudo apt install libasound2-dev libgl1-mesa-dev \
libglu1-mesa-dev libx11-dev libxrandr-dev libxi-dev libxcursor-dev \
libxinerama-dev libxkbcommon-dev
$ git clone https://github.com/raysan5/raylib ~/raylib && cd ~/raylib/src
$ make PLATFORM=PLATFORM_DESKTOP GLFW_LINUX_ENABLE_WAYLAND=OFF && make install
```

```console
$ git clone https://github.com/jdeokkim/mvp-demo
$ cd mvp-demo && make
```

</details>

<details>
<summary>Cross-compiling from GNU/Linux to Windows (WSL2)</summary>

### Debian / Ubuntu

```console
$ sudo apt install mingw-w64
$ git clone https://github.com/raysan5/raylib && cd raylib/src
$ make CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar OS=Windows_NT
```

```console
$ git clone https://github.com/jdeokkim/mvp-demo
$ cd mvp-demo && make -f Makefile.mingw
```

</details>

## License

MIT License

```
Copyright (c) 2024 Jaedeok Kim <jdeokkim@protonmail.com>
Copyright (c) 2024 Minhu Lee <fghkk12d@gmail.com>
Copyright (c) 2024 Hyungki Kim <diskhkme@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
# MVP Transform Visualizer

> "The engines don’t move the ship at all.
>
> **The ship stays where it is and the engines move the universe around it.**"
>
> — Futurama
A [raylib](https://github.com/raysan5/raylib) demo to visualize the Model, View, and Projection (MVP) matrices.

This project is a C rewrite of [@diskhkme](https://github.com/diskhkme)'s [MVP Transform Visualizer](https://github.com/diskhkme/mvp_transform_visualize) with additional features, for the "Computer Graphics" (1214-3005) course at Chungnam National University.

https://github.com/user-attachments/assets/4b7cda17-2f32-4651-9297-7070fb274da0

## Controls

- `ALT` + `0`: Draw All Spaces
- `ALT` + `1`: Draw Local Space
- `ALT` + `2`: Draw World Space
- `ALT` + `3`: Draw View Space
- `ALT` + `4`: Draw Clip Space
- `ESC`: Lock/Unlock Observer Camera
- `V`: Show/Hide Player Model Vertices

## Prerequisites

- GCC version 11.4.0+
- Git version 2.34.0+
- GNU Make version 4.3+
- raylib 5.5+

## Building

<details>
<summary>Compiling for Windows</summary>

### [w64devkit](https://github.com/skeeto/w64devkit)

Download the latest release of w64devkit from [here](https://github.com/skeeto/w64devkit/releases), extract the `.zip` file to your working directory, and run `w64devkit.exe`.

```console
$ cd .. && wget https://github.com/raysan5/raylib/archive/refs/tags/5.0.zip
$ unzip 5.0.zip && mv raylib-5.0 raylib
$ cd raylib/src && make
```

```console
$ git clone https://github.com/jdeokkim/mvp-demo
$ cd mvp-demo && make -f Makefile.mingw
```

</details>

<details>
<summary>Compiling for GNU/Linux</summary>

### Debian / Ubuntu

```console
$ sudo apt update && sudo apt install libasound2-dev libgl1-mesa-dev \
libglu1-mesa-dev libx11-dev libxrandr-dev libxi-dev libxcursor-dev \
libxinerama-dev libxkbcommon-dev
$ git clone https://github.com/raysan5/raylib ~/raylib && cd ~/raylib/src
$ make PLATFORM=PLATFORM_DESKTOP GLFW_LINUX_ENABLE_WAYLAND=OFF && make install
```

```console
$ git clone https://github.com/jdeokkim/mvp-demo
$ cd mvp-demo && make
```

</details>

<details>
<summary>Compiling for the Web (LLVM-to-WebAssembly)</summary>

### Debian / Ubuntu

Compiling for the Web requires installation of the [Emscripten SDK](https://emscripten.org/docs/getting_started/downloads.html).

```console
$ git clone git clone https://github.com/emscripten-core/emsdk && cd emsdk
$ ./emsdk install latest
$ ./emsdk activate latest
$ source ./emsdk_env.sh
```

Then, you must recompile raylib for the Web:

```console
$ git clone https://github.com/raysan5/raylib && cd raylib/src
$ make -j`nproc` PLATFORM=PLATFORM_WEB GRAPHICS=GRAPHICS_API_OPENGL_ES3 -B
```

Finally, in order to build this project, do:

```
$ git clone https://github.com/jdeokkim/mvp-demo
$ cd mvp-demo && make -f Makefile.emcc
```

</details>

<details>
<summary>Cross-compiling from GNU/Linux to Windows (WSL2)</summary>

### Debian / Ubuntu

```console
$ sudo apt install mingw-w64
$ git clone https://github.com/raysan5/raylib && cd raylib/src
$ make CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar OS=Windows_NT
```

```console
$ git clone https://github.com/jdeokkim/mvp-demo
$ cd mvp-demo && make -f Makefile.mingw
```

</details>

## License

MIT License

```
Copyright (c) 2024 Jaedeok Kim <jdeokkim@protonmail.com>
Copyright (c) 2024 Minhu Lee <fghkk12d@gmail.com>
Copyright (c) 2024 Hyungki Kim <diskhkme@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
Loading

0 comments on commit e7585ee

Please sign in to comment.