Skip to content

Commit c819f74

Browse files
committed
Fix tricked out example
1 parent 396575e commit c819f74

File tree

1 file changed

+81
-4
lines changed

1 file changed

+81
-4
lines changed

examples/CMakeLists.txt

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,86 @@ endfunction()
9090
add_ps2gl_example(box box/box.cpp)
9191
add_ps2gl_example(logo logo/logo.cpp)
9292
add_ps2gl_example(performance performance/performance.cpp)
93-
# Note: tricked_out has linking issues (missing CBillboardRenderer symbols)
94-
# add_ps2gl_example(tricked_out tricked_out/tricked_out.cpp)
93+
94+
# tricked_out example requires special handling due to billboard_renderer VU1 code
95+
# First, assemble the billboard VSM to a .vo file
96+
set(BILLBOARD_VSM "${CMAKE_CURRENT_SOURCE_DIR}/tricked_out/billboard_renderer_vcl.vsm")
97+
set(BILLBOARD_VO "${CMAKE_CURRENT_BINARY_DIR}/tricked_out/billboard_renderer.vo")
98+
99+
# Create directory for output
100+
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tricked_out")
101+
102+
# Assemble the VSM file to .vo (DVP assembler should be available)
103+
add_custom_command(
104+
OUTPUT ${BILLBOARD_VO}
105+
COMMAND dvp-as -o ${BILLBOARD_VO} ${BILLBOARD_VSM}
106+
DEPENDS ${BILLBOARD_VSM}
107+
COMMENT "Assembling billboard_renderer VU1 code"
108+
)
109+
110+
# Create a custom target for the billboard VU1 object
111+
add_custom_target(billboard_vu1_object DEPENDS ${BILLBOARD_VO})
112+
113+
# Add tricked_out example with billboard_renderer sources
114+
add_executable(tricked_out
115+
tricked_out/tricked_out.cpp
116+
tricked_out/billboard_renderer.cpp
117+
)
118+
119+
target_include_directories(tricked_out PRIVATE
120+
${CMAKE_SOURCE_DIR}/glut/include
121+
${CMAKE_SOURCE_DIR}/include
122+
${CMAKE_SOURCE_DIR}/src # For ps2gl internal headers
123+
${CMAKE_CURRENT_SOURCE_DIR}/shared_code
124+
${CMAKE_CURRENT_SOURCE_DIR}/tricked_out
125+
${PS2SDK}/ports/include
126+
)
127+
128+
target_compile_options(tricked_out PRIVATE
129+
-Wno-strict-aliasing
130+
-Wno-conversion-null
131+
)
132+
133+
target_compile_definitions(tricked_out PRIVATE
134+
NO_VU0_VECTORS
135+
NO_ASM
136+
)
137+
138+
target_link_directories(tricked_out PRIVATE
139+
${PS2SDK}/ports/lib
140+
)
141+
142+
# Link the billboard VU1 object file
143+
target_link_libraries(tricked_out
144+
${BILLBOARD_VO}
145+
shared_code
146+
ps2glut
147+
ps2gl
148+
ps2stuff
149+
pad
150+
dma
151+
)
152+
153+
add_dependencies(tricked_out billboard_vu1_object)
154+
155+
set_target_properties(tricked_out PROPERTIES
156+
OUTPUT_NAME "tricked_out.elf"
157+
SUFFIX ""
158+
)
159+
160+
# Strip the executable
161+
add_custom_command(TARGET tricked_out POST_BUILD
162+
COMMAND ${CMAKE_STRIP} --strip-all $<TARGET_FILE:tricked_out>
163+
COMMENT "Stripping tricked_out.elf"
164+
)
165+
166+
# Copy data files (car.bin texture)
167+
add_custom_command(TARGET tricked_out POST_BUILD
168+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
169+
${CMAKE_CURRENT_SOURCE_DIR}/tricked_out/car.bin
170+
${CMAKE_CURRENT_BINARY_DIR}/car.bin
171+
COMMENT "Copying car.bin texture"
172+
)
95173

96174
# NeHe tutorials
97175
add_ps2gl_example(nehe_lesson02 nehe/lesson02/lesson2.cpp)
@@ -101,7 +179,6 @@ add_ps2gl_example(nehe_lesson05 nehe/lesson05/lesson5.cpp)
101179

102180
message(STATUS "")
103181
message(STATUS "ps2gl examples configured:")
104-
message(STATUS " box, logo, performance")
182+
message(STATUS " box, logo, performance, tricked_out")
105183
message(STATUS " nehe: lesson02, lesson03, lesson04, lesson05")
106-
message(STATUS " Note: tricked_out disabled due to linking issues")
107184
message(STATUS "")

0 commit comments

Comments
 (0)