Added shaders and -GL2 option webgl
authorMichael Hartman <omh1280@gmail.com>
Sun, 30 Dec 2012 09:23:30 -0500
branchwebgl
changeset 8334 abb48dd39e26
parent 8332 9333216f2054
child 8336 4877d7333818
Added shaders and -GL2 option
CMakeLists.txt
share/hedgewars/Data/CMakeLists.txt
share/hedgewars/Data/Shaders/CMakeLists.txt
share/hedgewars/Data/Shaders/default.fs
share/hedgewars/Data/Shaders/default.vs
share/hedgewars/Data/Shaders/water.fs
share/hedgewars/Data/Shaders/water.vs
--- a/CMakeLists.txt	Tue Dec 25 05:15:49 2012 +0100
+++ b/CMakeLists.txt	Sun Dec 30 09:23:30 2012 -0500
@@ -27,6 +27,7 @@
 option(ANDROID "Enable Android build [default: off]" OFF)
 option(NOAUTOUPDATE "Disable OS X Sparkle update checking" OFF)
 option(MINIMAL_FLAGS "Respect system flags as much as possible [default: off]" OFF)
+option(GL2 "Enable OpenGL 2 rendering [default: off]" OFF)
 set(FPFLAGS "" CACHE STRING "Additional Freepascal flags" FORCE)
 set(GHFLAGS "" CACHE STRING "Additional Haskell flags" FORCE)
 
@@ -73,12 +74,13 @@
 
 # Check LLVM/Clang version
 find_package(Clang)
-
-if (CLANG_VERSION VERSION_LESS required_clang_version)
-    message(FATAL_ERROR "Necessary LLVM/Clang version not found (version >= ${REQUIRED_CLANG_VERSION} required)")
-else()
-    message(STATUS "Found CLANG: ${CLANG_EXECUTABLE} (version ${CLANG_VERSION})")
-endif()
+if (NOPASCAL)
+	if (CLANG_VERSION VERSION_LESS required_clang_version)
+		message(FATAL_ERROR "LLVM/Clang compiler required version is ${REQUIRED_CLANG_VERSION} but version ${CLANG_VERSION} was found!")
+	else()
+		message(STATUS "Found CLANG: ${CLANG_EXECUTABLE} (version ${CLANG_VERSION})")
+	endif()
+endif(NOPASCAL)
 
 
 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
--- a/share/hedgewars/Data/CMakeLists.txt	Tue Dec 25 05:15:49 2012 +0100
+++ b/share/hedgewars/Data/CMakeLists.txt	Sun Dec 30 09:23:30 2012 -0500
@@ -1,3 +1,3 @@
-foreach(dir "Fonts" "Forts" "Graphics" "Locale" "Maps" "Music" "Sounds" "Themes" "Missions" "Names" "misc" "Scripts")
+foreach(dir "Fonts" "Forts" "Graphics" "Locale" "Maps" "Music" "Shaders" "Sounds" "Themes" "Missions" "Names" "misc" "Scripts")
   add_subdirectory(${dir})
 endforeach(dir)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Shaders/CMakeLists.txt	Sun Dec 30 09:23:30 2012 -0500
@@ -0,0 +1,7 @@
+file(GLOB vertshaders *.vs)
+file(GLOB fragshaders *.fs)
+
+install(FILES
+	${vertshaders}
+	${fragshaders}
+	DESTINATION ${SHAREPATH}Data/Shaders)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Shaders/default.fs	Sun Dec 30 09:23:30 2012 -0500
@@ -0,0 +1,15 @@
+uniform sampler2D tex0;
+uniform vec4 tint;
+uniform bool enableTexture;
+
+varying vec2 tex;
+
+
+void main()
+{
+    if(enableTexture){
+        gl_FragColor = texture2D(tex0, tex) * tint;
+    }else{
+        gl_FragColor = tint;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Shaders/default.vs	Sun Dec 30 09:23:30 2012 -0500
@@ -0,0 +1,16 @@
+
+
+attribute vec2 vertex;
+attribute vec2 texcoord;
+attribute vec4 colors;
+
+varying vec2 tex;
+
+uniform mat4 mvp;
+
+void main()
+{
+    vec4 p = mvp * vec4(vertex, 0.0, 1.0);
+    gl_Position = p;
+    tex = texcoord;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Shaders/water.fs	Sun Dec 30 09:23:30 2012 -0500
@@ -0,0 +1,8 @@
+
+varying vec4 vcolor;
+
+
+void main()
+{
+    gl_FragColor = vcolor;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Shaders/water.vs	Sun Dec 30 09:23:30 2012 -0500
@@ -0,0 +1,15 @@
+
+
+attribute vec2 vertex;
+attribute vec4 color;
+
+varying vec4 vcolor;
+
+uniform mat4 mvp;
+
+void main()
+{
+    vec4 p = mvp * vec4(vertex, 0.0, 1.0);
+    gl_Position = p;
+    vcolor = color;
+}