-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored cmake files
- Loading branch information
Showing
14 changed files
with
388 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#include <simd/simd.h> | ||
#include <metal_stdlib> | ||
#include "aarect.h" | ||
#include "triangle.h" | ||
|
||
using namespace metal; | ||
|
||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
cmake_minimum_required(VERSION 3.13) | ||
project(triangle) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
add_executable(clip clip.mm clip.metal) | ||
|
||
target_link_libraries(clip ${APPKIT_LIBRARY}) | ||
target_link_libraries(clip "-framework Cocoa") | ||
target_link_libraries(clip "-framework Metal") | ||
target_link_libraries(clip "-framework MetalKit") | ||
target_link_libraries(clip "-framework QuartzCore") | ||
|
||
add_custom_command( | ||
OUTPUT ${PROJECT_BINARY_DIR}/clipsh.metallib_ | ||
WORKING_DIR ${PROJECT_BINARY_DIR} | ||
COMMAND ${METAL} -o clipsh.air ${CMAKE_SOURCE_DIR}/ex8_clip/clip.metal | ||
COMMAND ${METALLIB} -o clipsh.metallib_ clipsh.air | ||
COMMAND ${CMAKE_COMMAND} -E copy clipsh.metallib_ clipsh.metallib | ||
MAIN_DEPENDENCY clip.metal | ||
VERBATIM | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef COMMON_H | ||
#define COMMON_H | ||
|
||
#include <simd/simd.h> | ||
|
||
enum VertexAttributes { | ||
VertexAttributePosition = 0, | ||
VertexAttributeColor = 1, | ||
}; | ||
|
||
enum BufferIndex { | ||
MeshVertexBuffer = 0, | ||
FrameUniformBuffer = 1, | ||
}; | ||
|
||
struct FrameUniforms { | ||
simd::float4x4 projectionViewModel; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <simd/simd.h> | ||
#include "clip.h" | ||
|
||
using namespace metal; | ||
|
||
struct VertexInput { | ||
float3 position [[attribute(VertexAttributePosition)]]; | ||
half4 color [[attribute(VertexAttributeColor)]]; | ||
}; | ||
|
||
struct ShaderInOut { | ||
float4 position [[position]]; | ||
half4 color; | ||
}; | ||
|
||
vertex ShaderInOut vert(VertexInput in [[stage_in]], | ||
constant FrameUniforms& uniforms [[buffer(FrameUniformBuffer)]]) { | ||
ShaderInOut out; | ||
float4 pos4 = float4(in.position, 1.0); | ||
out.position = uniforms.projectionViewModel * pos4; | ||
out.color = in.color / 255.0; | ||
return out; | ||
} | ||
|
||
fragment half4 frag(ShaderInOut in [[stage_in]]) { | ||
return in.color; | ||
} |
Oops, something went wrong.