Last active
February 2, 2024 22:45
-
-
Save cyrstem/51338fe6c1b37bb474081c42e47dfd43 to your computer and use it in GitHub Desktop.
script for quick setting up a Cinder Project on linux and and with VS code
This file contains hidden or 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
#!/bin/bash | |
echo "Cinder ProjectMaker" | |
read -p "Project name: " projName | |
#checks | |
# Validate if the project name is provided | |
if [ -z "$projName" ]; then | |
echo "Error: Project name cannot be empty." | |
exit 1 | |
fi | |
# Validate if the project directory already exists | |
if [ -d "$projName" ]; then | |
echo "Error: Project directory '$projName' already exists." | |
exit 1 | |
fi | |
#creation checks | |
echo "Do you want to create settings function? (y/n)" | |
read -n 1 create_settings | |
echo | |
# Validate if create_settings input is either 'y' or 'n' | |
if [ "$create_settings" != "y" ] && [ "$create_settings" != "n" ]; then | |
echo "Error: Invalid input for create_settings. Use 'y' or 'n'." | |
exit 1 | |
fi | |
#create folders | |
mkdir -p $projName/{assets,include,proj,src,build} | |
#create resourses file | |
touch $projName/include/Resources.h | |
cat > $projName/include/Resources.h << ENDOFFILE | |
#pragma once | |
#include "cinder/CinderResources.h" | |
//#define RES_MY_RES CINDER_RESOURCE( ../resources/, image_name.png, 128, IMAGE ) | |
ENDOFFILE | |
#create main thing | |
touch $projName/src/$projName.cpp | |
cat > $projName/src/$projName.cpp <<EOF | |
#include "cinder/app/App.h" | |
#include "cinder/app/RendererGl.h" | |
#include "cinder/gl/gl.h" | |
using namespace ci; | |
using namespace ci::app; | |
using namespace std; | |
class $projName : public App { | |
public: | |
EOF | |
if [ "$create_settings" == "y" ];then | |
cat >> "$projName"/src/"$projName".cpp <<EOF | |
void prepareSettings( $projName::Settings* settings ) | |
{ | |
} | |
EOF | |
fi | |
cat >> "$projName"/src/"$projName".cpp <<EOF | |
void setup() override; | |
void update() override; | |
void draw() override; | |
}; | |
void $projName::setup( ) | |
{ | |
} | |
void $projName::update( ) | |
{ | |
} | |
void $projName::draw( ) | |
{ | |
gl::clear( Color( 0, 0, 0 ) ); | |
} | |
EOF | |
if [ "$create_settings" == "y" ]; then | |
cat >> "$projName"/src/"$projName".cpp <<EOF | |
// This line tells Cinder to actually create and run the application. | |
CINDER_APP( $projName, RendererGl, prepareSettings ) | |
EOF | |
else | |
cat >> "$projName"/src/"$projName".cpp <<EOF | |
// Alternative settings without prepareSettings function | |
CINDER_APP( $projName, RendererGl, []( App::Settings *settings ) { | |
settings->setWindowSize(1280,720); | |
settings->setTitle( "$projName" ); | |
}) | |
EOF | |
fi | |
mkdir $projName/proj/cmake | |
touch $projName/proj/cmake/CMakeLists.txt | |
cat > $projName/proj/cmake/CMakeLists.txt <<EOF | |
cmake_minimum_required( VERSION 3.10 FATAL_ERROR ) | |
set( CMAKE_VERBOSE_MAKEFILE ON ) | |
project( $projName ) | |
get_filename_component( CINDER_PATH "\${CMAKE_CURRENT_SOURCE_DIR}/../../../.." ABSOLUTE ) | |
get_filename_component( APP_PATH "\${CMAKE_CURRENT_SOURCE_DIR}/../../" ABSOLUTE ) | |
include( "\${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake" ) | |
ci_make_app( | |
SOURCES \${APP_PATH}/src/$projName.cpp | |
CINDER_PATH \${CINDER_PATH} | |
#INCLUDES \${APP_PATH}/include | |
) | |
EOF | |
cd "$projName" || exit | |
code . |
This file contains hidden or 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
#!/bin/bash | |
echo "Cinder ProjectMaker" | |
echo "Project name" | |
read -p '' projName | |
mkdir -p $projName/{assets,include,proj,src} | |
touch $projName/src/$projName.cpp | |
touch $projName/include/Resources.h | |
cat > $projName/include/Resources.h << ENDOFFILE | |
#pragma once | |
#include "cinder/CinderResources.h" | |
//#define RES_MY_RES CINDER_RESOURCE( ../resources/, image_name.png, 128, IMAGE ) | |
ENDOFFILE | |
cat > $projName/src/$projName.cpp <<EOF | |
#include "cinder/app/App.h" | |
#include "cinder/app/RendererGl.h" | |
#include "cinder/gl/gl.h" | |
using namespace ci; | |
using namespace ci::app; | |
using namespace std; | |
class $projName : public App { | |
public: | |
void update() override; | |
void draw() override; | |
}; | |
void prepareSettings( $projName::Settings* settings ) | |
{ | |
} | |
void $projName::update( ) | |
{ | |
} | |
void $projName::draw( ) | |
{ | |
gl::clear( Color( 0, 0, 0 ) ); | |
} | |
// This line tells Cinder to actually create and run the application. | |
CINDER_APP( $projName, RendererGl, prepareSettings ) | |
EOF | |
mkdir $projName/proj/cmake | |
touch $projName/proj/cmake/CMakeLists.txt | |
cat > $projName/proj/cmake/CMakeLists.txt <<EOF | |
cmake_minimum_required( VERSION 2.8 FATAL_ERROR ) | |
set( CMAKE_VERBOSE_MAKEFILE ON ) | |
project( $projName ) | |
get_filename_component( CINDER_PATH "\${CMAKE_CURRENT_SOURCE_DIR}/../../../.." ABSOLUTE ) | |
get_filename_component( APP_PATH "\${CMAKE_CURRENT_SOURCE_DIR}/../../" ABSOLUTE ) | |
include( "\${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake" ) | |
ci_make_app( | |
SOURCES \${APP_PATH}/src/$projName.cpp | |
CINDER_PATH \${CINDER_PATH} | |
#INCLUDES \${APP_PATH}/include | |
) | |
EOF | |
cd $projName | |
code . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment