소스 검색

Merge branch 'master' into audio

Conflicts:
	engine/Android.mk
mikymod 12 년 전
부모
커밋
46b614a0c7
3개의 변경된 파일151개의 추가작업 그리고 7개의 파일을 삭제
  1. 5 5
      engine/Android.mk
  2. 0 2
      engine/renderers/gles/GLESRenderer.cpp
  3. 146 0
      utils/crown-android.rb

+ 5 - 5
engine/Android.mk

@@ -32,7 +32,7 @@ LOCAL_SRC_FILES :=\
 	core/filesystem/TextReader.cpp\
 	core/filesystem/TextWriter.cpp\
 \
-	core/json/JSONParser.cpp
+	core/json/JSONParser.cpp\
 \
 	core/math/Color4.cpp\
 	core/math/Mat3.cpp\
@@ -88,12 +88,11 @@ LOCAL_SRC_FILES :=\
 	resource/FileBundle.cpp\
 	resource/FontResource.cpp\
 	resource/MaterialResource.cpp\
-	resource/PixelShaderResource.cpp\
+	resource/MeshResource.cpp\
 	resource/ResourceLoader.cpp\
 	resource/ResourceManager.cpp\
-	resource/TextResource.cpp\
+	resource/ResourceRegistry.cpp\
 	resource/TextureResource.cpp\
-	resource/VertexShaderResource.cpp\
 	resource/SoundResource.cpp\
 \
 	lua/LuaStack.cpp\
@@ -133,6 +132,7 @@ LOCAL_C_INCLUDES	:=\
 	$(LOCAL_PATH)/core/json\
 	$(LOCAL_PATH)/core/settings\
 	$(LOCAL_PATH)/core/strings\
+	$(LOCAL_PATH)/resource\
 	$(LOCAL_PATH)/input\
 	$(LOCAL_PATH)/lua\
 	$(LOCAL_PATH)/network\
@@ -143,7 +143,7 @@ LOCAL_C_INCLUDES	:=\
 	$(LOCAL_PATH)/renderers/gles\
 	$(LOCAL_PATH)/renderers/gles/egl\
 	$(LOCAL_PATH)/renderers/sles\
-	$(LOCAL_PATH)/third/luajit/include/luajit-2.0\
+	$(LOCAL_PATH)/luajit/include/luajit-2.0\
 
 LOCAL_CPPFLAGS	:= -g -fexceptions -std=c++03 -ansi -pedantic -Wall -Wextra -Wno-long-long -Wno-variadic-macros
 LOCAL_LDLIBS	:= -llog -landroid -lEGL -lGLESv2 -lz -lOpenSLES

+ 0 - 2
engine/renderers/gles/GLESRenderer.cpp

@@ -42,8 +42,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Mat4.h"
 #include "Device.h"
 #include "ResourceManager.h"
-#include "VertexShaderResource.h"
-#include "PixelShaderResource.h"
 
 namespace crown
 {

+ 146 - 0
utils/crown-android.rb

@@ -0,0 +1,146 @@
+#!/usr/bin/ruby
+
+require 'optparse'
+require 'ostruct'
+require 'fileutils'
+
+$android_create 	= "android create project"
+$android_update 	= "android update project"
+$activity			= "CrownActivity"
+$package			= "crown.android"
+
+$engine_src 		= "../engine/."
+$android_src		= "../engine/os/android/*.java"
+$manifest			= "../engine/os/android/AndroidManifest.xml"
+
+$luajit				= "../engine/third/ARMv7/luajit"
+
+#------------------------------------------------------------------------------
+def validate_command_line(args)
+
+	if args.length != 6
+		return false
+	end
+
+	if args[0] != "--target"
+		return false
+	end
+
+	if args[2] != "--name"
+		return false
+	end
+
+	if args[4] != "--path"
+		return false
+	end
+
+	return true
+end
+
+#------------------------------------------------------------------------------
+def parse_command_line(args)
+
+	banner = "Usage: crown-android.rb --target <android-target> --name <project-name> --path <project-path>\n"
+
+	if not validate_command_line(args)
+		print banner
+		exit
+	end
+
+	options = OpenStruct.new
+
+	OptionParser.new do |opts|
+		opts.banner = banner
+
+		opts.on("-t", "--target TARGET", "Android target") do |t|
+			options.target = t
+		end
+
+		opts.on("-n", "--name NAME", "Android project name") do |n|
+			options.name = n
+		end
+
+		opts.on("-p", "--path PATH", "Android project path") do |p|
+			options.path 	= p
+		end
+
+	    opts.on_tail("-h", "--help", "Show this message") do
+	    	puts opts
+	      	exit
+	    end
+	end.parse!(args)
+
+	return options
+end
+
+#------------------------------------------------------------------------------
+def create_android_project(target, name, path)
+
+	engine_dest 	= path + "/jni"
+	android_dest	= path + "/src/crown/android"
+
+	# Creates path if not exists
+	if not Dir.exists?(path)
+		FileUtils.mkdir_p(path)
+	end
+
+	# Project path is empty
+	if Dir[path + "/*"].empty?
+		# Creates android project
+		system($android_create + " --target " + target + " --name " + name + " --path " + path + 
+				" --activity " + $activity + " --package " + $package)
+	else
+		# Updates android project
+		system($android_update + " --target " + target + " --name " + name + " --path " + path)
+	end
+	
+	# if jni dir does not exists, create it!
+	if not Dir.exists?(engine_dest)
+		FileUtils.mkdir_p(engine_dest)
+		print "Created directory " + engine_dest + "\n"
+	end
+end
+
+#------------------------------------------------------------------------------
+def fill_android_project(path)
+
+	engine_dest 	= path + "/jni"
+	android_dest	= path + "/src/crown/android"
+
+	# Copy Engine files
+	FileUtils.cp_r($engine_src, engine_dest, :remove_destination => true)
+	print "Copied Engine to " + engine_dest + "\n"
+
+	# Copy luajit dir
+	FileUtils.cp_r($luajit, engine_dest, :remove_destination => true)
+
+	# Copy luajit lib
+	FileUtils.cp($luajit + "/lib/libluajit-5.1.so.2.0.2", engine_dest + "/libluajit-5.1.so")
+
+	# Copy Java files
+	FileUtils.cp_r(Dir.glob($android_src), android_dest, :remove_destination => true)
+	print "Copied Java files to " + android_dest + "\n"
+
+	# Copy Android Manifest
+	FileUtils.cp($manifest, path)
+	print "Copied Android Manifest to " + path  + "\n"
+end
+
+#------------------------------------------------------------------------------
+def build_android_project(path)
+	# Move to root directory of Android project
+	Dir.chdir(path)
+
+	# Build libraries
+	system("ndk-build")
+
+	# Build apk
+	system("ant debug")
+end
+
+#------------------------------------------------------------------------------
+opts = parse_command_line(ARGV)
+
+create_android_project(opts.target, opts.name, opts.path)
+fill_android_project(opts.path)
+build_android_project(opts.path)