summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <smspillaz@gmail.com>2010-08-08 13:28:45 +0800
committerSam Spilsbury <smspillaz@gmail.com>2010-08-08 13:28:45 +0800
commit53c356b77d7a959b7afe79c0bb4f4da2563a5344 (patch)
treebff18dce64153f44533aa6f9887503d7a7d678b8
parent79bd82437b138d6aa83f9ae14497c50c4348fbc2 (diff)
downloadsnowglobe-53c356b77d7a959b7afe79c0bb4f4da2563a5344.tar.gz
snowglobe-53c356b77d7a959b7afe79c0bb4f4da2563a5344.tar.bz2
Initial C++ port
-rw-r--r--CMakeLists.txt5
-rw-r--r--Makefile516
-rw-r--r--movement.c124
-rw-r--r--plugin.info2
-rw-r--r--snowglobe-internal.h170
-rw-r--r--snowglobe.c553
-rw-r--r--snowglobe.xml.in151
-rw-r--r--src/movement.cpp116
-rw-r--r--src/snowflake.cpp (renamed from snowflake.c)2
-rw-r--r--src/snowglobe.cpp392
-rw-r--r--src/snowglobe.h259
-rw-r--r--src/snowman.cpp (renamed from snowman.c)2
-rw-r--r--src/water.cpp (renamed from water.c)109
13 files changed, 900 insertions, 1501 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..aa3567d
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,5 @@
+find_package (Compiz REQUIRED)
+
+include (CompizPlugin)
+
+compiz_plugin (snowglobe PLUGINDEPS cube opengl composite)
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 3121c08..0000000
--- a/Makefile
+++ /dev/null
@@ -1,516 +0,0 @@
-##
-#
-# Compiz plugin Makefile
-#
-# Copyright : (C) 2007 by Dennis Kasprzyk
-# E-mail : onestone@deltatauchi.de
-#
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-##
-
-# plugin.info file contents
-#
-# PLUGIN = foo
-# PKG_DEP = pango
-# LDFLAGS_ADD = -lGLU
-# CFLAGS_ADD = -I/usr/include/foo
-# CHK_HEADERS = compiz-cube.h
-#
-
-#load config file
-
-ECHO = `which echo`
-
-# default color settings
-color := $(shell if [ $$TERM = "dumb" ]; then $(ECHO) "no"; else $(ECHO) "yes"; fi)
-
-ifeq ($(shell if [ -f plugin.info ]; then $(ECHO) -n "found"; fi ),found)
-include plugin.info
-else
-$(error $(shell if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\033[1;31m[ERROR]\033[0m \"plugin.info\" file not found"; \
- else \
- $(ECHO) "[ERROR] \"plugin.info\" file not found"; \
- fi;))
-endif
-
-ifneq ($(shell if pkg-config --exists compiz; then $(ECHO) -n "found"; fi ),found)
-$(error $(shell if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e -n "\033[1;31m[ERROR]\033[0m Compiz not installed"; \
- else \
- $(ECHO) -n "[ERROR] Compiz not installed"; \
- fi))
-endif
-
-
-ifneq ($(shell if [ -n "$(PKG_DEP)" ]; then if pkg-config --exists $(PKG_DEP); then $(ECHO) -n "found"; fi; \
- else $(ECHO) -n "found"; fi ),found)
-$(error $(shell if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e -n "\033[1;31m[ERROR]\033[0m "; \
- else \
- $(ECHO) -n "[ERROR] "; \
- fi; \
- pkg-config --print-errors --short-errors --errors-to-stdout $(PKG_DEP); ))
-endif
-
-
-ifeq ($(BUILD_GLOBAL),true)
- PREFIX = $(shell pkg-config --variable=prefix compiz)
- CLIBDIR = $(shell pkg-config --variable=libdir compiz)
- CINCDIR = $(shell pkg-config --variable=includedir compiz)
- PKGDIR = $(CLIBDIR)/pkgconfig
- DESTDIR = $(shell pkg-config --variable=libdir compiz)/compiz
- XMLDIR = $(shell pkg-config --variable=prefix compiz)/share/compiz
- IMAGEDIR = $(shell pkg-config --variable=prefix compiz)/share/compiz
- DATADIR = $(shell pkg-config --variable=prefix compiz)/share/compiz
-else
- DESTDIR = $(HOME)/.compiz/plugins
- XMLDIR = $(HOME)/.compiz/metadata
- IMAGEDIR = $(HOME)/.compiz/images
- DATADIR = $(HOME)/.compiz/data
-endif
-
-BUILDDIR = build
-
-CC = gcc
-CPP = g++
-LIBTOOL = libtool
-INSTALL = install
-
-BCOP = `pkg-config --variable=bin bcop`
-
-CFLAGS = -g -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -fno-strict-aliasing `pkg-config --cflags $(PKG_DEP) compiz ` $(CFLAGS_ADD)
-LDFLAGS = `pkg-config --libs $(PKG_DEP) compiz ` $(LDFLAGS_ADD)
-
-DEFINES = -DIMAGEDIR=\"$(IMAGEDIR)\" -DDATADIR=\"$(DATADIR)\"
-
-POFILEDIR = $(shell if [ -n "$(PODIR)" ]; then $(ECHO) $(PODIR); else $(ECHO) ./po;fi )
-
-COMPIZ_HEADERS = compiz.h compiz-core.h
-COMPIZ_INC = $(shell pkg-config --variable=includedir compiz)/compiz/
-
-is-bcop-target := $(shell if [ -e $(PLUGIN).xml.in ]; then cat $(PLUGIN).xml.in | grep "useBcop=\"true\""; \
- else if [ -e $(PLUGIN).xml ]; then cat $(PLUGIN).xml | grep "useBcop=\"true\""; fi; fi)
-
-trans-target := $(shell if [ -e $(PLUGIN).xml.in -o -e $(PLUGIN).xml ]; then $(ECHO) $(BUILDDIR)/$(PLUGIN).xml;fi )
-
-bcop-target := $(shell if [ -n "$(is-bcop-target)" ]; then $(ECHO) $(BUILDDIR)/$(PLUGIN).xml; fi )
-bcop-target-src := $(shell if [ -n "$(is-bcop-target)" ]; then $(ECHO) $(BUILDDIR)/$(PLUGIN)_options.c; fi )
-bcop-target-hdr := $(shell if [ -n "$(is-bcop-target)" ]; then $(ECHO) $(BUILDDIR)/$(PLUGIN)_options.h; fi )
-
-gen-schemas := $(shell if [ \( -e $(PLUGIN).xml.in -o -e $(PLUGIN).xml \) -a -n "`pkg-config --variable=xsltdir compiz-gconf`" ]; then $(ECHO) true; fi )
-schema-target := $(shell if [ -n "$(gen-schemas)" ]; then $(ECHO) $(BUILDDIR)/$(PLUGIN).xml; fi )
-schema-output := $(shell if [ -n "$(gen-schemas)" ]; then $(ECHO) $(BUILDDIR)/compiz-$(PLUGIN).schema; fi )
-
-ifeq ($(BUILD_GLOBAL),true)
- pkg-target := $(shell if [ -e compiz-$(PLUGIN).pc.in -a -n "$(PREFIX)" -a -d "$(PREFIX)" ]; then $(ECHO) "$(BUILDDIR)/compiz-$(PLUGIN).pc"; fi )
- hdr-install-target := $(shell if [ -e compiz-$(PLUGIN).pc.in -a -n "$(PREFIX)" -a -d "$(PREFIX)" -a -e compiz-$(PLUGIN).h ]; then $(ECHO) "compiz-$(PLUGIN).h"; fi )
-endif
-
-# find all the object files
-
-c-objs := $(patsubst %.c,%.lo,$(shell find -name '*.c' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///'))
-c-objs += $(patsubst %.cpp,%.lo,$(shell find -name '*.cpp' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///'))
-c-objs += $(patsubst %.cxx,%.lo,$(shell find -name '*.cxx' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///'))
-c-objs := $(filter-out $(bcop-target-src:.c=.lo),$(c-objs))
-
-h-files := $(shell find -name '*.h' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///')
-h-files += $(bcop-target-hdr)
-h-files += $(foreach file,$(COMPIZ_HEADERS) $(CHK_HEADERS),$(shell $(ECHO) -n "$(COMPIZ_INC)$(file)"))
-
-all-c-objs := $(addprefix $(BUILDDIR)/,$(c-objs))
-all-c-objs += $(bcop-target-src:.c=.lo)
-
-# additional files
-
-data-files := $(shell find data/ -name '*' -type f 2> /dev/null | sed -e 's/data\///')
-image-files := $(shell find images/ -name '*' -type f 2> /dev/null | sed -e 's/images\///')
-
-# system include path parameter, -isystem doesn't work on old gcc's
-inc-path-param = $(shell if [ -z "`gcc --version | head -n 1 | grep ' 3'`" ]; then $(ECHO) "-isystem"; else $(ECHO) "-I"; fi)
-
-# Tests
-ifeq ($(shell if [ -n "$(is-bcop-target)" -a -z "$(BCOP)" ]; then $(ECHO) -n "error"; fi ),error)
-$(error $(shell if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e -n "\033[1;31m[ERROR]\033[0m BCOP not installed but is needed to build plugin"; \
- else \
- $(ECHO) -n "[ERROR] BCOP not installed but is needed to build plugin"; \
- fi))
-endif
-
-ifeq ($(shell if [ "x$(BUILD_GLOBAL)" != "xtrue" -a -e compiz-$(PLUGIN).pc.in ]; then $(ECHO) -n "warn"; fi ),warn)
-$(warning $(shell if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e -n "\033[1;31m[WARNING]\033[0m This plugin might be needed by other plugins. Install it with \"BUILD_GLOBAL=true sudo make install\" "; \
- else \
- $(ECHO) -n "[WARNING] This plugin might be needed by other plugins. Install it with \"BUILD_GLOBAL=true sudo make install\""; \
- fi))
-endif
-
-#
-# Do it.
-#
-
-.PHONY: $(BUILDDIR) build-dir trans-target bcop-build pkg-creation schema-creation c-build-objs c-link-plugin
-
-all: $(BUILDDIR) build-dir trans-target bcop-build pkg-creation schema-creation c-build-objs c-link-plugin
-
-trans-build: $(trans-target)
-
-bcop-build: $(bcop-target-hdr) $(bcop-target-src)
-
-schema-creation: $(schema-output)
-
-c-build-objs: $(all-c-objs)
-
-c-link-plugin: $(BUILDDIR)/lib$(PLUGIN).la
-
-pkg-creation: $(pkg-target)
-
-#
-# Create build directory
-#
-
-$(BUILDDIR) :
- @mkdir -p $(BUILDDIR)
-
-$(DESTDIR) :
- @mkdir -p $(DESTDIR)
-
-#
-# fallback if xml.in doesn't exists
-#
-$(BUILDDIR)/%.xml: %.xml
- @cp $< $@
-
-#
-# Translating
-#
-$(BUILDDIR)/%.xml: %.xml.in
- @if [ -d $(POFILEDIR) ]; then \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e -n "\033[0;1;5mtranslate \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
- else \
- $(ECHO) "translate $< -> $@"; \
- fi; \
- intltool-merge -x -u $(POFILEDIR) $< $@ > /dev/null; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0mtranslate : \033[34m$< -> $@\033[0m"; \
- fi; \
- else \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e -n "\033[0;1;5mconvert \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
- else \
- $(ECHO) "convert $< -> $@"; \
- fi; \
- cat $< | sed -e 's;<_;<;g' -e 's;</_;</;g' > $@; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0mconvert : \033[34m$< -> $@\033[0m"; \
- fi; \
- fi
-
-#
-# BCOP'ing
-
-$(BUILDDIR)/%_options.h: $(BUILDDIR)/%.xml
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e -n "\033[0;1;5mbcop'ing \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
- else \
- $(ECHO) "bcop'ing $< -> $@"; \
- fi
- @$(BCOP) --header=$@ $<
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0mbcop'ing : \033[34m$< -> $@\033[0m"; \
- fi
-
-$(BUILDDIR)/%_options.c: $(BUILDDIR)/%.xml
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e -n "\033[0;1;5mbcop'ing \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
- else \
- $(ECHO) "bcop'ing $< -> $@"; \
- fi
- @$(BCOP) --source=$@ $<
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0mbcop'ing : \033[34m$< -> $@\033[0m"; \
- fi
-
-#
-# Schema generation
-
-$(BUILDDIR)/compiz-%.schema: $(BUILDDIR)/%.xml
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e -n "\033[0;1;5mschema'ing\033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
- else \
- $(ECHO) "schema'ing $< -> $@"; \
- fi
- @xsltproc `pkg-config --variable=xsltdir compiz-gconf`/schemas.xslt $< > $@
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0mschema : \033[34m$< -> $@\033[0m"; \
- fi
-
-#
-# pkg config file generation
-
-$(BUILDDIR)/compiz-%.pc: compiz-%.pc.in
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e -n "\033[0;1;5mpkgconfig \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
- else \
- $(ECHO) "pkgconfig $< -> $@"; \
- fi
- @COMPIZREQUIRES=`cat $(PKGDIR)/compiz.pc | grep Requires | sed -e 's;Requires: ;;g'`; \
- COMPIZCFLAGS=`cat $(PKGDIR)/compiz.pc | grep Cflags | sed -e 's;Cflags: ;;g'`; \
- sed -e 's;@prefix@;$(PREFIX);g' -e 's;\@libdir@;$(CLIBDIR);g' \
- -e 's;@includedir@;$(CINCDIR);g' -e 's;\@VERSION@;0.0.1;g' \
- -e "s;@COMPIZ_REQUIRES@;$$COMPIZREQUIRES;g" \
- -e "s;@COMPIZ_CFLAGS@;$$COMPIZCFLAGS;g" $< > $@;
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0mpkgconfig : \033[34m$< -> $@\033[0m"; \
- fi
-
-#
-# Compiling
-#
-
-$(BUILDDIR)/%.lo: %.c $(h-files)
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5mcompiling \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
- else \
- $(ECHO) "compiling $< -> $@"; \
- fi
- @$(LIBTOOL) --quiet --mode=compile $(CC) $(CFLAGS) $(DEFINES) -I$(BUILDDIR) -c -o $@ $<
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \
- fi
-
-$(BUILDDIR)/%.lo: $(BUILDDIR)/%.c $(h-files)
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5mcompiling \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
- else \
- $(ECHO) "compiling $< -> $@"; \
- fi
- @$(LIBTOOL) --quiet --mode=compile $(CC) $(CFLAGS) $(DEFINES) -I$(BUILDDIR) -c -o $@ $<
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \
- fi
-
-$(BUILDDIR)/%.lo: %.cpp $(h-files)
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5mcompiling \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
- else \
- $(ECHO) "compiling $< -> $@"; \
- fi
- @$(LIBTOOL) --quiet --mode=compile $(CPP) $(CFLAGS) $(DEFINES) -I$(BUILDDIR) -c -o $@ $<
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \
- fi
-
-$(BUILDDIR)/%.lo: %.cxx $(h-files)
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5mcompiling \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \
- else \
- $(ECHO) "compiling $< -> $@"; \
- fi
- @$(LIBTOOL) --quiet --mode=compile $(CPP) $(CFLAGS) $(DEFINES) -I$(BUILDDIR) -c -o $@ $<
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \
- fi
-
-#
-# Linking
-#
-
-cxx-rpath-prefix := -Wl,-rpath,
-
-$(BUILDDIR)/lib$(PLUGIN).la: $(all-c-objs)
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e -n "\033[0;1;5mlinking \033[0m: \033[0;31m$@\033[0m"; \
- else \
- $(ECHO) "linking : $@"; \
- fi
- @$(LIBTOOL) --quiet --mode=link $(CC) $(LDFLAGS) -rpath $(DESTDIR) -o $@ $(all-c-objs)
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0mlinking : \033[34m$@\033[0m"; \
- fi
-
-
-clean:
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e -n "\033[0;1;5mremoving \033[0m: \033[0;31m./$(BUILDDIR)\033[0m"; \
- else \
- $(ECHO) "removing : ./$(BUILDDIR)"; \
- fi
- @rm -rf $(BUILDDIR)
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0mremoving : \033[34m./$(BUILDDIR)\033[0m"; \
- fi
-
-
-install: $(DESTDIR) all
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(DESTDIR)/lib$(PLUGIN).so\033[0m"; \
- else \
- $(ECHO) "install : $(DESTDIR)/lib$(PLUGIN).so"; \
- fi
- @mkdir -p $(DESTDIR)
- @$(INSTALL) $(BUILDDIR)/.libs/lib$(PLUGIN).so $(DESTDIR)/lib$(PLUGIN).so
- @if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0minstall : \033[34m$(DESTDIR)/lib$(PLUGIN).so\033[0m"; \
- fi
- @if [ -e $(BUILDDIR)/$(PLUGIN).xml ]; then \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \
- else \
- $(ECHO) "install : $(XMLDIR)/$(PLUGIN).xml"; \
- fi; \
- mkdir -p $(XMLDIR); \
- cp $(BUILDDIR)/$(PLUGIN).xml $(XMLDIR)/$(PLUGIN).xml; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0minstall : \033[34m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \
- fi; \
- fi
- @if [ -n "$(hdr-install-target)" ]; then \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(CINCDIR)/compiz/$(hdr-install-target)\033[0m"; \
- else \
- $(ECHO) "install : $(CINCDIR)/compiz/$(hdr-install-target)"; \
- fi; \
- cp $(hdr-install-target) $(CINCDIR)/compiz/$(hdr-install-target); \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0minstall : \033[34m$(CINCDIR)/compiz/$(hdr-install-target)\033[0m"; \
- fi; \
- fi
- @if [ -n "$(pkg-target)" ]; then \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(PKGDIR)/compiz-$(PLUGIN).pc\033[0m"; \
- else \
- $(ECHO) "install : $(PKGDIR)/compiz-$(PLUGIN).pc"; \
- fi; \
- cp $(pkg-target) $(PKGDIR)/compiz-$(PLUGIN).pc; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0minstall : \033[34m$(PKGDIR)/compiz-$(PLUGIN).pc\033[0m"; \
- fi; \
- fi
- @if [ -n "$(schema-output)" -a -e "$(schema-output)" ]; then \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(schema-output)\033[0m"; \
- else \
- $(ECHO) "install : $(schema-output)"; \
- fi; \
- gconftool-2 --install-schema-file=$(schema-output) > /dev/null; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0minstall : \033[34m$(schema-output)\033[0m"; \
- fi; \
- fi
- @if [ -n "$(data-files)" ]; then \
- mkdir -p $(DATADIR); \
- for FILE in $(data-files); do \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(DATADIR)/$$FILE\033[0m"; \
- else \
- $(ECHO) "install : $(DATADIR)/$$FILE"; \
- fi; \
- FILEDIR="$(DATADIR)/`dirname "$$FILE"`"; \
- mkdir -p "$$FILEDIR"; \
- cp data/$$FILE $(DATADIR)/$$FILE; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0minstall : \033[34m$(DATADIR)/$$FILE\033[0m"; \
- fi; \
- done \
- fi
- @if [ -n "$(image-files)" ]; then \
- mkdir -p $(IMAGEDIR); \
- for FILE in $(image-files); do \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(IMAGEDIR)/$$FILE\033[0m"; \
- else \
- $(ECHO) "install : $(IMAGEDIR)/$$FILE"; \
- fi; \
- FILEDIR="$(IMAGEDIR)/`dirname "$$FILE"`"; \
- mkdir -p "$$FILEDIR"; \
- cp images/$$FILE $(IMAGEDIR)/$$FILE; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0minstall : \033[34m$(IMAGEDIR)/$$FILE\033[0m"; \
- fi; \
- done \
- fi
-
-uninstall:
- @if [ -e $(DESTDIR)/lib$(PLUGIN).so ]; then \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(DESTDIR)/lib$(PLUGIN).so\033[0m"; \
- else \
- $(ECHO) "uninstall : $(DESTDIR)/lib$(PLUGIN).so"; \
- fi; \
- rm -f $(DESTDIR)/lib$(PLUGIN).so; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0muninstall : \033[34m$(DESTDIR)/lib$(PLUGIN).so\033[0m"; \
- fi; \
- fi
- @if [ -e $(XMLDIR)/$(PLUGIN).xml ]; then \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \
- else \
- $(ECHO) "uninstall : $(XMLDIR)/$(PLUGIN).xml"; \
- fi; \
- rm -f $(XMLDIR)/$(PLUGIN).xml; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0muninstall : \033[34m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \
- fi; \
- fi
- @if [ -n "$(hdr-install-target)" -a -e $(CINCDIR)/compiz/$(hdr-install-target) ]; then \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(CINCDIR)/compiz/$(hdr-install-target)\033[0m"; \
- else \
- $(ECHO) "uninstall : $(CINCDIR)/compiz/$(hdr-install-target)"; \
- fi; \
- rm -f $(CINCDIR)/compiz/$(hdr-install-target); \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0muninstall : \033[34m$(CINCDIR)/compiz/$(hdr-install-target)\033[0m"; \
- fi; \
- fi
- @if [ -n "$(pkg-target)" -a -e $(PKGDIR)/compiz-$(PLUGIN).pc ]; then \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(PKGDIR)/compiz-$(PLUGIN).pc\033[0m"; \
- else \
- $(ECHO) "uninstall : $(PKGDIR)/compiz-$(PLUGIN).pc"; \
- fi; \
- rm -f $(PKGDIR)/compiz-$(PLUGIN).pc; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0muninstall : \033[34m$(PKGDIR)/compiz-$(PLUGIN).pc\033[0m"; \
- fi; \
- fi
- @if [ -n "$(data-files)" ]; then \
- for FILE in $(data-files); do \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(DATADIR)/$$FILE\033[0m"; \
- else \
- $(ECHO) "uninstall : $(DATADIR)/$$FILE"; \
- fi; \
- rm -f $(DATADIR)/$$FILE; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0muninstall : \033[34m$(DATADIR)/$$FILE\033[0m"; \
- fi; \
- done \
- fi
- @if [ -n "$(image-files)" ]; then \
- for FILE in $(image-files); do \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(IMAGEDIR)/$$FILE\033[0m"; \
- else \
- $(ECHO) "uninstall : $(IMAGEDIR)/$$FILE"; \
- fi; \
- rm -f $(IMAGEDIR)/$$FILE; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0muninstall : \033[34m$(IMAGEDIR)/$$FILE\033[0m"; \
- fi; \
- done \
- fi
diff --git a/movement.c b/movement.c
deleted file mode 100644
index 026d714..0000000
--- a/movement.c
+++ /dev/null
@@ -1,124 +0,0 @@
-#include "snowglobe-internal.h"
-#include "snowglobe_options.h"
-#include <math.h>
-#include <float.h>
-
-
-void
-SnowflakeTransform (snowflakeRec * snow)
-{
-
- glTranslatef (snow->y, snow->z, snow->x);
- glRotatef (-snow->psi, 0.0, 1.0, 0.0);
- glRotatef (snow->theta, 1.0, 0.0, 0.0);
-}
-
-void
-newSnowflakePosition(SnowglobeScreen *as, int i)
-{
- int sector = NRAND(as->hsize);
- float ang = randf(as->arcAngle*toRadians)-0.5*as->arcAngle*toRadians;
- float r = (as->radius-0.01*as->snow[i].size/2);
- float factor = sinf(0.5*(PI-as->arcAngle*toRadians))/
- sinf(0.5*(PI-as->arcAngle*toRadians)+fabsf(ang));
- ang += (0.5+((float) sector))*as->arcAngle*toRadians;
- ang = fmodf(ang,2*PI);
-
- float d = randf(1);
- d=(1-d*d)*r*factor;
-
- as->snow[i].x = d*cosf(ang);
- as->snow[i].y = d*sinf(ang);
- as->snow[i].z = 0.5;
-}
-
-void
-SnowflakeDrift (CompScreen *s, int index)
-{
- float progress;
-
- SNOWGLOBE_SCREEN (s);
- CUBE_SCREEN (s);
-
- //float oldXRotate = as->xRotate;
- //float oldVRotate = as->vRotate;
-
- (*cs->getRotation) (s, &(as->xRotate), &(as->vRotate), &progress);
-
- as->xRotate = fmodf( as->xRotate-cs->invert * (360.0f / s->hsize) *
- ((s->x* cs->nOutput)), 360 );
-
- snowflakeRec * snow = &(as->snow[index]);
-
- float speed = snow->speed*as->speedFactor;
- speed/=1000;
- float x = snow->x;
- float y = snow->y;
- float z = snow->z;
-
- float sideways = 2*(randf(2*speed)-speed);
- float vertical = -speed;
-
- if (snowglobeGetShakeCube(s))
- {
- x+= sideways*cosf(as->xRotate*toRadians)*cosf(as->vRotate*toRadians)
- -vertical*cosf(as->xRotate*toRadians)*sinf(as->vRotate*toRadians);
-
- y+= sideways*sinf(as->xRotate*toRadians)*cosf(as->vRotate*toRadians)
- +vertical*sinf(as->xRotate*toRadians)*sinf(as->vRotate*toRadians);
-
- z+= sideways*sinf(as->vRotate*toRadians)
- +vertical*cosf(as->vRotate*toRadians);
- }
- else
- {
- x+=sideways;
- y+=sideways;
- z+=vertical;
- }
-
-
- float bottom = (snowglobeGetShowGround(s) ? getHeight(as->ground, x, y) : -0.5)+0.01*snow->size/2;
-
- if (z<bottom)
- {
- z = 0.5;
- newSnowflakePosition(as, index);
-
- x = snow->x;
- y = snow->y;
- }
-
- float top = 0.5-0.01*snow->size/2;
- if (z>top)
- {
- z = top;
- }
-
-
- float ang = atan2f(y, x);
-
- int i;
- for (i=0; i< as->hsize; i++)
- {
- float cosAng = cosf(fmodf(i*as->arcAngle*toRadians-ang, 2*PI));
- if (cosAng<=0)
- continue;
-
- float r = hypotf(x, y);
- float d = r*cosAng-(as->distance-0.01*snow->size/2);
-
- if (d>0)
- {
- x -= d*cosf(ang)*fabsf(cosf(i*as->arcAngle*toRadians));
- y -= d*sinf(ang)*fabsf(sinf(i*as->arcAngle*toRadians));
- }
- }
-
- snow->x = x;
- snow->y = y;
- snow->z = z;
-
- snow->psi = fmodf(snow->psi+snow->dpsi*as->speedFactor, 360);
- snow->theta= fmodf(snow->theta+snow->dtheta*as->speedFactor, 360);
-}
diff --git a/plugin.info b/plugin.info
deleted file mode 100644
index 9fa954e..0000000
--- a/plugin.info
+++ /dev/null
@@ -1,2 +0,0 @@
-PLUGIN = snowglobe
-PKG_DEP = compiz-cube
diff --git a/snowglobe-internal.h b/snowglobe-internal.h
deleted file mode 100644
index af082ac..0000000
--- a/snowglobe-internal.h
+++ /dev/null
@@ -1,170 +0,0 @@
-#ifndef _SNOWGLOBE_INTERNAL_H
-#define _SNOWGLOBE_INTERNAL_H
-
-#define LRAND() ((long) (random() & 0x7fffffff))
-#define NRAND(n) ((int) (LRAND() % (n)))
-#define MAXRAND (2147483648.0) /* unsigned 1<<31 as a float */
-
-
-#include <math.h>
-#include <float.h>
-
-/* some constants */
-#define PI M_PI
-#define PIdiv2 M_PI_2
-#define toDegrees (180.0f * M_1_PI)
-#define toRadians (M_PI / 180.0f)
-
-//return random number in range [0,x)
-#define randf(x) ((float) (rand()/(((double)RAND_MAX + 1)/(x))))
-
-
-#include <compiz-core.h>
-#include <compiz-cube.h>
-
-extern int snowglobeDisplayPrivateIndex;
-extern int cubeDisplayPrivateIndex;
-
-#define GET_SNOWGLOBE_DISPLAY(d) \
- ((SnowglobeDisplay *) (d)->base.privates[snowglobeDisplayPrivateIndex].ptr)
-#define SNOWGLOBE_DISPLAY(d) \
- SnowglobeDisplay *ad = GET_SNOWGLOBE_DISPLAY(d);
-
-#define GET_SNOWGLOBE_SCREEN(s, ad) \
- ((SnowglobeScreen *) (s)->base.privates[(ad)->screenPrivateIndex].ptr)
-#define SNOWGLOBE_SCREEN(s) \
- SnowglobeScreen *as = GET_SNOWGLOBE_SCREEN(s, GET_SNOWGLOBE_DISPLAY(s->display))
-
-
-typedef struct _snowflakeRec
-{
- float x, y, z;
- float theta, psi;
- float dpsi, dtheta;
- float speed, size;
-}
-snowflakeRec;
-
-typedef struct _Vertex
-{
- float v[3];
- float n[3];
-}
-Vertex;
-
-typedef struct _Water
-{
- int size;
- float distance;
- int sDiv;
-
- float bh;
- float wa;
- float swa;
- float wf;
- float swf;
-
- Vertex *vertices;
- unsigned int *indices;
-
- unsigned int nVertices;
- unsigned int nIndices;
-
- unsigned int nSVer;
- unsigned int nSIdx;
- unsigned int nWVer;
- unsigned int nWIdx;
-
- float wave1;
- float wave2;
-}
-Water;
-
-typedef struct _SnowglobeDisplay
-{
- int screenPrivateIndex;
-}
-SnowglobeDisplay;
-
-typedef struct _SnowglobeScreen
-{
- DonePaintScreenProc donePaintScreen;
- PreparePaintScreenProc preparePaintScreen;
-
- CubeClearTargetOutputProc clearTargetOutput;
- CubePaintInsideProc paintInside;
-
- Bool damage;
-
- int numSnowflakes;
-
- snowflakeRec *snow;
-
- Water *water;
- Water *ground;
-
- float xRotate;
- float vRotate;
-
- float waterHeight; //water surface height
-
- int hsize;
- float distance; //perpendicular distance to wall from centre
- float radius; //radius on which the hSize points lie
- float arcAngle; //360 degrees / horizontal size
-
- float speedFactor; // multiply snowflake speeds by this value
-
- GLuint snowflakeDisplayList;
-}
-SnowglobeScreen;
-
-void
-updateWater (CompScreen *s, float time);
-
-void
-updateGround (CompScreen *s, float time);
-
-void
-updateHeight (Water *w);
-
-void
-freeWater (Water *w);
-
-void
-drawWater (Water *w, Bool full, Bool wire);
-
-void
-drawGround (Water *w, Water *g);
-
-void
-drawBottomGround (int size, float distance, float bottom);
-
-Bool
-isInside (CompScreen *s, float x, float y, float z);
-
-float
-getHeight (Water *w, float x, float z);
-
-
-
-void SnowflakeTransform(snowflakeRec *);
-void newSnowflakePosition(SnowglobeScreen *, int);
-void SnowflakeDrift (CompScreen *, int);
-
-void initializeWorldVariables(CompScreen *);
-void updateSpeedFactor(float);
-void RenderWater(int, float, Bool, Bool);
-
-void DrawSnowflake (int);
-void initDrawSnowflake(void);
-void finDrawSnowflake(void);
-
-void DrawSnowman (int);
-
-
-//All calculations that matter with angles are done clockwise from top.
-//I think of it as x=radius, y=0 being the top (towards 1st desktop from above view)
-//and the z coordinate as height.
-
-#endif
diff --git a/snowglobe.c b/snowglobe.c
deleted file mode 100644
index 442a26b..0000000
--- a/snowglobe.c
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
- * Compiz cube snowglobe plugin
- *
- * snowglobe.c
- *
- * This is a test plugin to show falling snow inside
- * of the transparent cube
- *
- * Written in 2007 by David Mikos
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-/*
- * Based on atlantis and snow plugins
- */
-
-/**
- * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
- * (c) Copyright 1993, 1994, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
- * any purpose and without fee is hereby granted, provided that the above
- * copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
- * the name of Silicon Graphics, Inc. not be used in advertising
- * or publicity pertaining to distribution of the software without specific,
- * written prior permission.
- *
- * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
- * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
- * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
- * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
- * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
- * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
- * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
- * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
- * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
- * Use, duplication, or disclosure by the Government is subject to
- * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
- * (c)(1)(ii) of the Rights in Technical Data and Computer Software
- * clause at DFARS 252.227-7013 and/or in similar or successor
- * clauses in the FAR or the DOD or NASA FAR Supplement.
- * Unpublished-- rights reserved under the copyright laws of the
- * United States. Contractor/manufacturer is Silicon Graphics,
- * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
- *
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <signal.h>
-#include <unistd.h>
-#include <math.h>
-
-
-
-#include "snowglobe-internal.h"
-#include "snowglobe_options.h"
-
-
-int snowglobeDisplayPrivateIndex;
-
-int cubeDisplayPrivateIndex;
-
-
-
-static void
-initSnowglobe (CompScreen *s)
-{
-
- SNOWGLOBE_SCREEN (s);
-
- as->water = NULL;
- as->ground = NULL;
-
- as->numSnowflakes = snowglobeGetNumSnowflakes(s);
-
- as->snow = calloc(as->numSnowflakes, sizeof(snowflakeRec));
-
- initializeWorldVariables(s);
-
- int i;
- for (i=0; i< as->numSnowflakes; i++)
- {
- as->snow[i].size = snowglobeGetSnowflakeSize(s)
- +sqrt(randf(snowglobeGetSnowflakeSize(s)));
-
- newSnowflakePosition(as, i);
-
- as->snow[i].psi = randf(2*PI);
- as->snow[i].theta= randf(PI);
-
- as->snow[i].dpsi = randf(5);
- as->snow[i].dtheta = randf(5);
-
- as->snow[i].speed = randf(0.4)+0.2;
-
- }
-
- as->waterHeight = 50000;
-
- as->snowflakeDisplayList = glGenLists(1);
- glNewList(as->snowflakeDisplayList, GL_COMPILE);
- DrawSnowflake(0);
- glEndList();
-}
-
-void
-initializeWorldVariables(CompScreen *s)
-{
- SNOWGLOBE_SCREEN (s);
- CUBE_SCREEN (s);
-
- as->speedFactor = snowglobeGetSpeedFactor(s);
-
- as->hsize = s->hsize * cs->nOutput;
-
- as->arcAngle = 360.0f / as->hsize;
- as->radius = cs->distance/sinf(0.5*(PI-as->arcAngle*toRadians));
- as->distance = cs->distance;
-}
-
-static void
-freeSnowglobe (CompScreen *s)
-{
- SNOWGLOBE_SCREEN (s);
-
- if (as->snow)
- free (as->snow);
-
- freeWater (as->water);
- freeWater (as->ground);
-
- glDeleteLists(as->snowflakeDisplayList, 1);
-}
-
-static void
-updateSnowglobe (CompScreen *s)
-{
- freeSnowglobe (s);
- initSnowglobe (s);
-}
-static void
-snowglobeScreenOptionChange (CompScreen *s,
- CompOption *opt,
- SnowglobeScreenOptions num)
-{
- updateSnowglobe (s);
-}
-static void
-snowglobeSpeedFactorOptionChange (CompScreen *s,
- CompOption *opt,
- SnowglobeScreenOptions num)
-{
- SNOWGLOBE_SCREEN (s);
- as->speedFactor = snowglobeGetSpeedFactor(s);
-}
-
-static void
-snowglobeClearTargetOutput (CompScreen *s,
- float xRotate,
- float vRotate)
-{
- SNOWGLOBE_SCREEN (s);
- CUBE_SCREEN (s);
-
- UNWRAP (as, cs, clearTargetOutput);
- (*cs->clearTargetOutput) (s, xRotate, vRotate);
- WRAP (as, cs, clearTargetOutput, snowglobeClearTargetOutput);
-
- glClear (GL_DEPTH_BUFFER_BIT);
-}
-
-
-static void
-snowglobePaintInside (CompScreen *s,
- const ScreenPaintAttrib *sAttrib,
- const CompTransform *transform,
- CompOutput *output,
- int size)
-{
- SNOWGLOBE_SCREEN (s);
- CUBE_SCREEN (s);
-
- int i;
-
- as->waterHeight = 50000;
-
- if (as->hsize!=s->hsize) updateSnowglobe (s);
-
-
- static const float mat_shininess[] = { 60.0 };
- static const float mat_specular[] = { 0.8, 0.8, 0.8, 1.0 };
- static const float mat_diffuse[] = { 0.46, 0.66, 0.795, 1.0 };
- static const float mat_ambient[] = { 0.1, 0.1, 0.3, 1.0 };
- static const float lmodel_ambient[] = { 1.0, 1.0, 1.0, 1.0 };
- static const float lmodel_localviewer[] = { 0.0 };
-
- ScreenPaintAttrib sA = *sAttrib;
- CompTransform mT = *transform;
-
- if (snowglobeGetShowWater(s))
- updateHeight(as->water);
-
- sA.yRotate += cs->invert * (360.0f / size) *
- (cs->xRotations - (s->x* cs->nOutput));
-
- (*s->applyScreenTransform)(s, &sA, output, &mT);
-
- glPushMatrix();
-
- glLoadMatrixf(mT.m);
-
- glTranslatef(cs->outputXOffset, -cs->outputYOffset, 0.0f);
-
- glScalef(cs->outputXScale, cs->outputYScale, 1.0f);
-
- Bool enabledCull = FALSE;
-
- glPushAttrib(GL_COLOR_BUFFER_BIT | GL_TEXTURE_BIT | GL_LIGHTING_BIT);
-
- glEnable(GL_BLEND);
-
- if (glIsEnabled(GL_CULL_FACE))
- {
- enabledCull = TRUE;
- }
-
- int cull;
-
- glGetIntegerv(GL_CULL_FACE_MODE, &cull);
- glEnable(GL_CULL_FACE);
-
- glCullFace(~cull & (GL_FRONT | GL_BACK));
-
- if (snowglobeGetShowWater(s))
- {
- glColor4usv(snowglobeGetWaterColor(s));
- drawWater(as->water, TRUE, FALSE);
- }
- glCullFace(cull);
-
- if (snowglobeGetShowGround(s))
- {
- glColor4f(0.8, 0.8, 0.8, 1.0);
- drawGround(NULL, as->ground);
-
- }
-
- glPushMatrix();
-
- glColor4usv(defaultColor);
-
- glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
- glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse);
- glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient);
- glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
- glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_localviewer);
-
- glEnable(GL_NORMALIZE);
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT1);
- glEnable(GL_LIGHT0);
-
- glEnable(GL_COLOR_MATERIAL);
-
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
- for (i = 0; i < as->numSnowflakes; i++)
- {
- glPushMatrix();
- SnowflakeTransform(&(as->snow[i]));
-
- float scale = 0.01*as->snow[i].size;
- glScalef(scale, scale, scale);
-
- initDrawSnowflake();
- glCallList(as->snowflakeDisplayList);
- finDrawSnowflake();
- glPopMatrix();
- }
-
- if (snowglobeGetShowSnowman(s))
- {
- glPushMatrix();
-
- float bottom = -0.5;
- if (snowglobeGetShowGround(s))
- bottom = getHeight(as->ground, 0, 0);
- glTranslatef(0, bottom, 0);
-
- float scale = 0.4*snowglobeGetSnowmanSize(s)*(0.5-bottom);
- glScalef(scale, scale, scale);
-
- glColor4f(1.0, 1.0, 1.0, 1.0);
-
- DrawSnowman(0);
- glPopMatrix();
- }
-
- glPopMatrix();
-
- if (snowglobeGetShowWater(s))
- {
- glEnable(GL_CULL_FACE);
- glColor4usv(snowglobeGetWaterColor(s));
- drawWater(as->water, snowglobeGetShowWater(s), 0);
- }
-
- if (snowglobeGetShowGround(s))
- {
- glColor4f(0.8, 0.8, 0.8, 1.0);
- drawBottomGround(s->hsize * cs->nOutput, cs->distance, -0.4999);
- }
-
- glDisable(GL_LIGHT1);
- glDisable(GL_NORMALIZE);
-
- if (!s->lighting)
- glDisable(GL_LIGHTING);
-
- glDisable(GL_DEPTH_TEST);
-
- if (enabledCull)
- glDisable(GL_CULL_FACE);
-
- glPopMatrix();
-
- glPopAttrib();
-
- as->damage = TRUE;
-
- UNWRAP (as, cs, paintInside);
- (*cs->paintInside)(s, sAttrib, transform, output, size);
- WRAP (as, cs, paintInside, snowglobePaintInside);
-}
-
-static void
-snowglobePreparePaintScreen (CompScreen *s,
- int ms)
-{
- SNOWGLOBE_SCREEN (s);
-
- int i;
-
- for (i = 0; i < as->numSnowflakes; i++)
- {
- SnowflakeDrift(s, i);
- }
-
- updateWater(s, (float)ms / 1000.0);
- updateGround(s, (float)ms / 1000.0);
-
- UNWRAP (as, s, preparePaintScreen);
- (*s->preparePaintScreen)(s, ms);
- WRAP (as, s, preparePaintScreen, snowglobePreparePaintScreen);
-}
-
-static void
-snowglobeDonePaintScreen (CompScreen * s)
-{
- SNOWGLOBE_SCREEN (s);
-
- if (as->damage)
- {
- damageScreen (s);
- as->damage = FALSE;
- }
-
- UNWRAP (as, s, donePaintScreen);
- (*s->donePaintScreen) (s);
- WRAP (as, s, donePaintScreen, snowglobeDonePaintScreen);
-}
-
-static Bool
-snowglobeInitDisplay (CompPlugin *p,
- CompDisplay *d)
-{
- SnowglobeDisplay *ad;
-
- if (!checkPluginABI("core", CORE_ABIVERSION)
- || !checkPluginABI("cube", CUBE_ABIVERSION))
- return FALSE;
-
- if (!getPluginDisplayIndex(d, "cube", &cubeDisplayPrivateIndex))
- return FALSE;
-
- ad = malloc(sizeof(SnowglobeDisplay));
-
- if (!ad)
- return FALSE;
-
- ad->screenPrivateIndex = allocateScreenPrivateIndex(d);
-
- if (ad->screenPrivateIndex < 0)
- {
- free(ad);
- return FALSE;
- }
-
- d->base.privates[snowglobeDisplayPrivateIndex].ptr = ad;
-
- return TRUE;
-}
-
-static void
-snowglobeFiniDisplay (CompPlugin *p,
- CompDisplay *d)
-{
- SNOWGLOBE_DISPLAY (d);
-
- freeScreenPrivateIndex(d, ad->screenPrivateIndex);
- free(ad);
-}
-
-static Bool
-snowglobeInitScreen (CompPlugin *p,
- CompScreen *s)
-{
- static const float ambient[] = { 0.3, 0.3, 0.3, 1.0 };
- static const float diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
- static const float position[] = { 0.0, 1.0, 0.0, 0.0 };
-
- SnowglobeScreen *as;
-
- SNOWGLOBE_DISPLAY (s->display);
- CUBE_SCREEN (s);
-
- as = malloc(sizeof(SnowglobeScreen));
-
- if (!as)
- return FALSE;
-
- s->base.privates[ad->screenPrivateIndex].ptr = as;
-
- as->damage = FALSE;
-
- glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);
- glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse);
- glLightfv(GL_LIGHT1, GL_POSITION, position);
-
- initSnowglobe(s);
-
- snowglobeSetSpeedFactorNotify(s, snowglobeSpeedFactorOptionChange);
-
- snowglobeSetNumSnowflakesNotify(s, snowglobeScreenOptionChange);
- snowglobeSetSnowflakeSizeNotify(s, snowglobeScreenOptionChange);
-
- WRAP (as, s, donePaintScreen, snowglobeDonePaintScreen);
- WRAP (as, s, preparePaintScreen, snowglobePreparePaintScreen);
- WRAP (as, cs, clearTargetOutput, snowglobeClearTargetOutput);
- WRAP (as, cs, paintInside, snowglobePaintInside);
-
- return TRUE;
-}
-
-static void
-snowglobeFiniScreen (CompPlugin *p,
- CompScreen *s)
-{
- SNOWGLOBE_SCREEN (s);
- CUBE_SCREEN (s);
-
- freeSnowglobe(s);
-
- UNWRAP (as, s, donePaintScreen);
- UNWRAP (as, s, preparePaintScreen);
- UNWRAP (as, cs, clearTargetOutput);
- UNWRAP (as, cs, paintInside);
-
- free(as);
-}
-
-static Bool
-snowglobeInit (CompPlugin * p)
-{
- snowglobeDisplayPrivateIndex = allocateDisplayPrivateIndex();
-
- if (snowglobeDisplayPrivateIndex < 0)
- return FALSE;
-
- return TRUE;
-}
-
-static void
-snowglobeFini (CompPlugin * p)
-{
- if (snowglobeDisplayPrivateIndex >= 0)
- freeDisplayPrivateIndex (snowglobeDisplayPrivateIndex);
-}
-
-static CompBool
-snowglobeInitObject (CompPlugin *p,
- CompObject *o)
-{
- static InitPluginObjectProc dispTab[] = {
- (InitPluginObjectProc) 0, /* InitCore */
- (InitPluginObjectProc) snowglobeInitDisplay,
- (InitPluginObjectProc) snowglobeInitScreen
- };
-
- RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
-}
-
-static void
-snowglobeFiniObject (CompPlugin *p,
- CompObject *o)
-{
- static FiniPluginObjectProc dispTab[] = {
- (FiniPluginObjectProc) 0, /* FiniCore */
- (FiniPluginObjectProc) snowglobeFiniDisplay,
- (FiniPluginObjectProc) snowglobeFiniScreen
- };
-
- DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
-}
-
-CompPluginVTable snowglobeVTable = {
-
- "snowglobe",
- 0,
- snowglobeInit,
- snowglobeFini,
- snowglobeInitObject,
- snowglobeFiniObject,
- 0,
- 0
-};
-
-
-CompPluginVTable *
-getCompPluginInfo (void)
-{
- return &snowglobeVTable;
-}
diff --git a/snowglobe.xml.in b/snowglobe.xml.in
index b4dbe69..1ad0684 100644
--- a/snowglobe.xml.in
+++ b/snowglobe.xml.in
@@ -11,82 +11,83 @@
<plugin>vpswitch</plugin>
</relation>
<requirement>
- <plugin>cube</plugin>
+ <plugin>opengl</plugin>
+ <plugin>composite</plugin>
+ <plugin>cube</plugin>
</requirement>
</deps>
- <screen>
- <option name="speed_factor" type="float">
- <short>Speed factor</short>
- <long>Multiply the speed of the snowflakes by this factor.</long>
- <default>1</default>
- <min>0.5</min>
- <max>10</max>
- <precision>0.01</precision>
- </option>
- <option name="num_snowflakes" type="int">
- <_short>Number of snowflakes</_short>
- <_long>Maximum number of snowflakes.</_long>
- <default>100</default>
- <min>0</min>
- <max>1000</max>
- </option>
- <option name="snowflake_size" type="float">
- <_short>Size of snowflakes</_short>
- <_long>Size of snowflakes.</_long>
- <default>1</default>
- <min>0.1</min>
- <max>5</max>
- <precision>0.01</precision>
- </option>
- <option name="show_snowman" type="bool">
- <short>Render snowman</short>
- <long>Render a snowman inside the cube.</long>
- <default>false</default>
- </option>
- <option name="snowman_size" type="float">
- <_short>Size of snowman</_short>
- <_long>Size of snowman inside the cube.</_long>
- <default>0.6</default>
- <min>0.1</min>
- <max>1</max>
- <precision>0.01</precision>
- </option>
- <option name="shake_cube" type="bool">
- <short>Interaction</short>
- <long>Snowflakes fall according to cube orientation.</long>
- <default>true</default>
- </option>
- <group>
- <short>Water / Ground</short>
- <option name="show_water" type="bool">
- <short>Render water</short>
- <long>Render water inside the cube.</long>
- <default>true</default>
- </option>
- <option name="show_ground" type="bool">
- <short>Render ground</short>
- <long>Render ground inside the cube.</long>
- <default>true</default>
- </option>
- <option name="water_color" type="color">
- <short>Water opacity</short>
- <long>Opacity of water in the cube.</long>
- <default>
- <red>0x0800</red>
- <green>0x0800</green>
- <blue>0x3000</blue>
- <alpha>0xf00</alpha>
- </default>
- </option>
- <option name="grid_quality" type="int">
- <short>Ground grid smoothnes</short>
- <long>Number of subdivisions that create a finer grid.</long>
- <default>3</default>
- <min>1</min>
- <max>10</max>
- </option>
- </group>
-
- </screen>
+ <options>
+ <option name="speed_factor" type="float">
+ <short>Speed factor</short>
+ <long>Multiply the speed of the snowflakes by this factor.</long>
+ <default>1</default>
+ <min>0.5</min>
+ <max>10</max>
+ <precision>0.01</precision>
+ </option>
+ <option name="num_snowflakes" type="int">
+ <_short>Number of snowflakes</_short>
+ <_long>Maximum number of snowflakes.</_long>
+ <default>100</default>
+ <min>0</min>
+ <max>1000</max>
+ </option>
+ <option name="snowflake_size" type="float">
+ <_short>Size of snowflakes</_short>
+ <_long>Size of snowflakes.</_long>
+ <default>1</default>
+ <min>0.1</min>
+ <max>5</max>
+ <precision>0.01</precision>
+ </option>
+ <option name="show_snowman" type="bool">
+ <short>Render snowman</short>
+ <long>Render a snowman inside the cube.</long>
+ <default>false</default>
+ </option>
+ <option name="snowman_size" type="float">
+ <_short>Size of snowman</_short>
+ <_long>Size of snoscreenwman inside the cube.</_long>
+ <default>0.6</default>
+ <min>0.1</min>
+ <max>1</max>
+ <precision>0.01</precision>
+ </option>
+ <option name="shake_cube" type="bool">
+ <short>Interaction</short>
+ <long>Snowflakes fall according to cube orientation.</long>
+ <default>true</default>
+ </option>
+ <group>
+ <short>Water / Ground</short>
+ <option name="show_water" type="bool">
+ <short>Render water</short>
+ <long>Render water inside the cube.</long>
+ <default>true</default>
+ </option>
+ <option name="show_ground" type="bool">
+ <short>Render ground</short>
+ <long>Render ground inside the cube.</long>
+ <default>true</default>
+ </option>
+ <option name="water_color" type="color">
+ <short>Water opacity</short>
+ <long>Opacity of water in the cube.</long>
+ <default>
+ <red>0x0800</red>
+ <green>0x0800</green>
+ <blue>0x3000</blue>
+ <alpha>0xf00</alpha>
+ </default>
+ </option>
+ <option name="grid_quality" type="int">
+ <short>Ground grid smoothnes</short>
+ <long>Number of subdivisions that create a finer grid.</long>
+ <default>3</default>
+ <min>1</min>
+ <max>10</max>
+ </option>
+ </group>
+ </options>
</plugin>
</compiz>
diff --git a/src/movement.cpp b/src/movement.cpp
new file mode 100644
index 0000000..11f6c14
--- /dev/null
+++ b/src/movement.cpp
@@ -0,0 +1,116 @@
+#include <cmath>
+#include "snowglobe.h"
+
+
+void
+SnowflakeTransform (snowflakeRec * snow)
+{
+ glTranslatef (snow->y, snow->z, snow->x);
+ glRotatef (snow->theta, 1.0, 0.0, 0.0);
+}
+
+void
+SnowglobeScreen::newSnowflakePosition (int i)
+{
+ SnowglobeScreen *as = this;
+
+ int sector = NRAND(as->mHsize);
+ float ang = randf(as->mArcAngle*toRadians)-0.5*as->mArcAngle*toRadians;
+ float r = (as->mRadius-0.01*as->mSnow[i].size/2);
+ float factor = sinf(0.5*(PI-as->mArcAngle*toRadians))/
+ sinf(0.5*(PI-as->mArcAngle*toRadians)+fabsf(ang));
+ ang += (0.5+((float) sector))*as->mArcAngle*toRadians;
+ ang = fmodf(ang,2*PI);
+
+ float d = randf(1);
+ d=(1-d*d)*r*factor;
+
+ as->mSnow[i].x = d*cosf(ang);
+ as->mSnow[i].y = d*sinf(ang);
+ as->mSnow[i].z = 0.5;
+}
+
+void
+SnowglobeScreen::SnowflakeDrift (int index)
+{
+ float progress;
+
+ csScreen->cubeGetRotation (mXRotate, mVRotate, progress);
+
+ mXRotate = fmodf (mXRotate - csScreen->invert () * (360.0f / screen->vpSize ().width ()) *
+ ((screen->vp ().x () * csScreen->nOutput ())), 360 );
+
+ snowflakeRec * snow = &(mSnow[index]);
+
+ float speed = snow->speed * mSpeedFactor;
+ speed /= 1000;
+ float x = snow->x;
+ float y = snow->y;
+ float z = snow->z;
+
+ float sideways = 2 * (randf (2 * speed) - speed);
+ float vertical = -speed;
+
+ if (optionGetShakeCube ())
+ {
+ x+= sideways * cosf (mXRotate * toRadians) * cosf (mVRotate * toRadians)
+ -vertical * cosf (mXRotate * toRadians) * sinf (mVRotate * toRadians);
+
+ y+= sideways * sinf(mXRotate * toRadians) * cosf (mVRotate * toRadians)
+ + vertical * sinf(mXRotate * toRadians) * sinf (mVRotate * toRadians);
+
+ z+= sideways * sinf (mVRotate * toRadians)
+ + vertical * cosf (mVRotate * toRadians);
+ }
+ else
+ {
+ x += sideways;
+ y += sideways;
+ z += vertical;
+ }
+
+
+ float bottom = (optionGetShowGround () ? getHeight (mGround, x, y) : -0.5) + 0.01 * snow->size / 2;
+
+ if (z < bottom)
+ {
+ z = 0.5;
+ newSnowflakePosition (index);
+
+ x = snow->x;
+ y = snow->y;
+ }
+
+ float top = 0.5-0.01 * snow->size / 2;
+ if (z > top)
+ {
+ z = top;
+ }
+
+
+ float ang = atan2f(y, x);
+
+ int i;
+ for (i = 0; i < mHsize; i++)
+ {
+ float cosAng = cosf (fmodf (i * mArcAngle * toRadians - ang, 2 * PI));
+ if (cosAng <= 0)
+ continue;
+
+ float r = hypotf (x, y);
+ float d = r * cosAng - (mDistance - 0.01 * snow->size / 2);
+
+ if (d>0)
+ {
+ x -= d * cosf (ang) * fabsf (cosf (i * mArcAngle * toRadians));
+ y -= d * sinf (ang) * fabsf (sinf (i * mArcAngle * toRadians));
+ }
+ }
+
+ snow->x = x;
+ snow->y = y;
+ snow->z = z;
+
+ snow->psi = fmodf (snow->psi + snow->dpsi * mSpeedFactor, 360);
+ snow->theta= fmodf (snow->theta + snow->dtheta * mSpeedFactor, 360);
+}
diff --git a/snowflake.c b/src/snowflake.cpp
index 087ab14..7e68b4a 100644
--- a/snowflake.c
+++ b/src/snowflake.cpp
@@ -1,4 +1,4 @@
-#include "snowglobe-internal.h"
+#include "snowglobe.h"
//points are of the form (y,z,x).
//model made using Blender and generated using script.
diff --git a/src/snowglobe.cpp b/src/snowglobe.cpp
new file mode 100644
index 0000000..9c2c004
--- /dev/null
+++ b/src/snowglobe.cpp
@@ -0,0 +1,392 @@
+/*
+ * Compiz cube snowglobe plugin
+ *
+ * snowglobe.c
+ *
+ * This is a test plugin to show falling snow inside
+ * of the transparent cube
+ *
+ * Written in 2007 by David Mikos
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+/*
+ * Based on atlantis and snow plugins
+ */
+
+/**
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ * (c) Copyright 1993, 1994, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <signal.h>
+#include <unistd.h>
+#include <math.h>
+
+#include "snowglobe.h"
+
+COMPIZ_PLUGIN_20090315 (snowglobe, SnowglobePluginVTable);
+
+void
+SnowglobeScreen::initSnowglobe ()
+{
+ mWater = NULL;
+ mGround = NULL;
+
+ mNumSnowflakes = optionGetNumSnowflakes ();
+
+ mSnow = (snowflakeRec *) calloc (mNumSnowflakes, sizeof (snowflakeRec));
+
+ initializeWorldVariables ();
+
+ int i;
+ for (i = 0; i< mNumSnowflakes; i++)
+ {
+ mSnow[i].size = optionGetSnowflakeSize()
+ +sqrt(randf(optionGetSnowflakeSize()));
+
+ newSnowflakePosition (i);
+
+ mSnow[i].psi = randf(2*PI);
+ mSnow[i].theta= randf(PI);
+
+ mSnow[i].dpsi = randf(5);
+ mSnow[i].dtheta = randf(5);
+
+ mSnow[i].speed = randf(0.4)+0.2;
+
+ }
+
+ mWaterHeight = 50000;
+
+ mSnowflakeDisplayList = glGenLists(1);
+ glNewList(mSnowflakeDisplayList, GL_COMPILE);
+ DrawSnowflake(0);
+ glEndList();
+}
+
+void
+SnowglobeScreen::initializeWorldVariables ()
+{
+ mSpeedFactor = optionGetSpeedFactor();
+
+ mHsize = screen->vpSize ().width () * csScreen->nOutput ();
+
+ mArcAngle = 360.0f / mHsize;
+ mRadius = csScreen->distance () / sinf (0.5 * (PI - mArcAngle * toRadians));
+ mDistance = csScreen->distance ();
+}
+
+void
+SnowglobeScreen::freeSnowglobe ()
+{
+ if (mSnow)
+ free (mSnow);
+
+ freeWater (mWater);
+ freeWater (mGround);
+
+ glDeleteLists(mSnowflakeDisplayList, 1);
+}
+
+void
+SnowglobeScreen::updateSnowglobe ()
+{
+ freeSnowglobe ();
+ initSnowglobe ();
+}
+
+void
+SnowglobeScreen::optionChange (CompOption *opt,
+ SnowglobeOptions::Options num)
+{
+ updateSnowglobe ();
+
+ mSpeedFactor = optionGetSpeedFactor ();
+}
+
+void
+SnowglobeScreen::cubeClearTargetOutput (float xRotate,
+ float vRotate)
+{
+ csScreen->cubeClearTargetOutput (xRotate, vRotate);
+
+ glClear (GL_DEPTH_BUFFER_BIT);
+}
+
+void
+SnowglobeScreen::cubePaintInside (const GLScreenPaintAttrib &attrib,
+ const GLMatrix &transform,
+ CompOutput *output,
+ int size)
+{
+ int i;
+
+ mWaterHeight = 50000;
+
+ if (mHsize != screen->vpSize ().width ())
+ updateSnowglobe ();
+
+ static const float mat_shininess[] = { 60.0 };
+ static const float mat_specular[] = { 0.8, 0.8, 0.8, 1.0 };
+ static const float mat_diffuse[] = { 0.46, 0.66, 0.795, 1.0 };
+ static const float mat_ambient[] = { 0.1, 0.1, 0.3, 1.0 };
+ static const float lmodel_ambient[] = { 1.0, 1.0, 1.0, 1.0 };
+ static const float lmodel_localviewer[] = { 0.0 };
+
+ GLScreenPaintAttrib sAttrib (attrib);
+ GLMatrix mT (transform);
+
+ if (optionGetShowWater())
+ updateHeight(mWater);
+
+ sAttrib.yRotate += csScreen->invert () * (360.0f / size) *
+ (csScreen->xRotations () - (screen->vp ().x () * csScreen->nOutput ()));
+
+ gScreen->glApplyTransform (sAttrib, output, &mT);
+
+ glPushMatrix();
+ glLoadMatrixf(mT.getMatrix ());
+
+ glTranslatef(-csScreen->outputXOffset (), -csScreen->outputYOffset (), 0.0f);
+
+ glScalef(csScreen->outputXScale (), csScreen->outputYScale (), 1.0f);
+
+ bool enabledCull = false;
+
+ glPushAttrib(GL_COLOR_BUFFER_BIT | GL_TEXTURE_BIT | GL_LIGHTING_BIT);
+
+ glEnable(GL_BLEND);
+
+ if (glIsEnabled(GL_CULL_FACE))
+ {
+ enabledCull = true;
+ }
+
+ int cull;
+
+ glGetIntegerv(GL_CULL_FACE_MODE, &cull);
+ glEnable(GL_CULL_FACE);
+
+ glCullFace(~cull & (GL_FRONT | GL_BACK));
+
+ if (optionGetShowWater())
+ {
+ glColor4usv(optionGetWaterColor());
+ drawWater(mWater, true, false);
+ }
+ glCullFace(cull);
+
+ if (optionGetShowGround())
+ {
+ glColor4f(0.8, 0.8, 0.8, 1.0);
+ drawGround(NULL, mGround);
+ }
+
+ glPushMatrix();
+
+ glColor4usv(defaultColor);
+
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient);
+ glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+ glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_localviewer);
+
+ glEnable(GL_NORMALIZE);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT1);
+ glEnable(GL_LIGHT0);
+
+ glEnable(GL_COLOR_MATERIAL);
+
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+ for (i = 0; i < mNumSnowflakes; i++)
+ {
+ glPushMatrix ();
+ SnowflakeTransform(&(mSnow[i]));
+
+ float scale = 0.01 * mSnow[i].size;
+ glScalef(scale, scale, scale);
+
+ initDrawSnowflake ();
+ glCallList(mSnowflakeDisplayList);
+ finDrawSnowflake ();
+ glPopMatrix ();
+ }
+
+ if (optionGetShowSnowman())
+ {
+ glPushMatrix ();
+
+ float bottom = -0.5;
+ if (optionGetShowGround ())
+ bottom = getHeight (mGround, 0, 0);
+ glTranslatef (0, bottom, 0);
+
+ float scale = 0.4 * optionGetSnowmanSize () * (0.5 - bottom);
+ glScalef (scale, scale, scale);
+
+ glColor4f (1.0, 1.0, 1.0, 1.0);
+
+ DrawSnowman (0);
+ glPopMatrix ();
+ }
+
+ glPopMatrix ();
+
+ if (optionGetShowWater ())
+ {
+ glEnable(GL_CULL_FACE);
+ glColor4usv(optionGetWaterColor());
+ drawWater(mWater, optionGetShowWater(), 0);
+ }
+
+ if (optionGetShowGround())
+ {
+ glColor4f(0.8, 0.8, 0.8, 1.0);
+ drawBottomGround(screen->vpSize ().width () * csScreen->nOutput (), csScreen->distance (), -0.4999);
+ }
+
+ glDisable(GL_LIGHT1);
+ glDisable(GL_NORMALIZE);
+
+ if (!gScreen->lighting ())
+ glDisable(GL_LIGHTING);
+
+ glDisable(GL_DEPTH_TEST);
+
+ if (enabledCull)
+ glDisable(GL_CULL_FACE);
+
+ glPopMatrix();
+
+ glPopAttrib();
+
+ mDamage = true;
+
+ csScreen->cubePaintInside (sAttrib, transform, output, size);
+}
+
+void
+SnowglobeScreen::preparePaint (int ms)
+{
+ int i;
+
+ for (i = 0; i < mNumSnowflakes; i++)
+ {
+ SnowflakeDrift (i);
+ }
+
+ updateWater ((float) ms / 1000.0);
+ updateGround ((float ) ms / 1000.0);
+
+ cScreen->preparePaint (ms);
+}
+
+void
+SnowglobeScreen::donePaint ()
+{
+ if (mDamage)
+ {
+ cScreen->damageScreen ();
+ mDamage = false;
+ }
+
+ cScreen->donePaint ();
+}
+
+SnowglobeScreen::SnowglobeScreen (CompScreen *s) :
+ PluginClassHandler <SnowglobeScreen, CompScreen> (s),
+ cScreen (CompositeScreen::get (screen)),
+ gScreen (GLScreen::get (screen)),
+ csScreen (CubeScreen::get (screen)),
+ mDamage (false)
+{
+ static const float ambient[] = { 0.3, 0.3, 0.3, 1.0 };
+ static const float diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
+ static const float position[] = { 0.0, 1.0, 0.0, 0.0 };
+
+ CompositeScreenInterface::setHandler (cScreen, true);
+ CubeScreenInterface::setHandler (csScreen, true);
+
+ glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);
+ glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse);
+ glLightfv(GL_LIGHT1, GL_POSITION, position);
+
+ initSnowglobe ();
+
+ optionSetSpeedFactorNotify (boost::bind (&SnowglobeScreen::optionChange,
+ this, _1, _2));
+
+ optionSetNumSnowflakesNotify (boost::bind (&SnowglobeScreen::optionChange,
+ this, _1, _2));
+ optionSetSnowflakeSizeNotify (boost::bind (&SnowglobeScreen::optionChange,
+ this, _1, _2));
+}
+
+SnowglobeScreen::~SnowglobeScreen ()
+{
+ freeSnowglobe ();
+}
+
+bool
+SnowglobePluginVTable::init ()
+{
+ if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) ||
+ !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) ||
+ !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI) ||
+ !CompPlugin::checkPluginABI ("cube", COMPIZ_CUBE_ABI))
+ return false;
+
+ return true;
+
+} \ No newline at end of file
diff --git a/src/snowglobe.h b/src/snowglobe.h
new file mode 100644
index 0000000..6bc852f
--- /dev/null
+++ b/src/snowglobe.h
@@ -0,0 +1,259 @@
+/*
+ * Compiz cube snowglobe plugin
+ *
+ * snowglobe.h
+ *
+ * This is a test plugin to show falling snow inside
+ * of the transparent cube
+ *
+ * Written in 2007: Copyright (c) 2007 David Mikos
+ * Ported to Compiz 0.9.x:
+ * Copyright (c) 2010 Sam Spilsbury
+ * Compright (c) 2010 Scott Moreau
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+/*
+ * Based on atlantis and snow plugins
+ */
+
+/**
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ * (c) Copyright 1993, 1994, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ */
+
+#ifndef _SNOWGLOBE_INTERNAL_H
+#define _SNOWGLOBE_INTERNAL_H
+
+#define LRAND() ((long) (random() & 0x7fffffff))
+#define NRAND(n) ((int) (LRAND() % (n)))
+#define MAXRAND (2147483648.0) /* unsigned 1<<31 as a float */
+
+
+#include <math.h>
+#include <float.h>
+
+/* some constants */
+#define PI M_PI
+#define PIdiv2 M_PI_2
+#define toDegrees (180.0f * M_1_PI)
+#define toRadians (M_PI / 180.0f)
+
+//return random number in range [0,x)
+#define randf(x) ((float) (rand()/(((double)RAND_MAX + 1)/(x))))
+
+#include <core/core.h>
+#include <composite/composite.h>
+#include <opengl/opengl.h>
+#include <cube/cube.h>
+
+#include "snowglobe_options.h"
+
+extern int snowglobeDisplayPrivateIndex;
+extern int cubeDisplayPrivateIndex;
+
+
+typedef struct _snowflakeRec
+{
+ float x, y, z;
+ float theta, psi;
+ float dpsi, dtheta;
+ float speed, size;
+}
+snowflakeRec;
+
+typedef struct _Vertex
+{
+ float v[3];
+ float n[3];
+}
+Vertex;
+
+typedef struct _Water
+{
+ int size;
+ float distance;
+ int sDiv;
+
+ float bh;
+ float wa;
+ float swa;
+ float wf;
+ float swf;
+
+ Vertex *vertices;
+ unsigned int *indices;
+
+ unsigned int nVertices;
+ unsigned int nIndices;
+
+ unsigned int nSVer;
+ unsigned int nSIdx;
+ unsigned int nWVer;
+ unsigned int nWIdx;
+
+ float wave1;
+ float wave2;
+}
+Water;
+
+class SnowglobeScreen :
+ public PluginClassHandler <SnowglobeScreen, CompScreen>,
+ public CompositeScreenInterface,
+ public CubeScreenInterface,
+ public SnowglobeOptions
+{
+ public:
+
+ SnowglobeScreen (CompScreen *);
+ ~SnowglobeScreen ();
+
+ CompositeScreen *cScreen;
+ GLScreen *gScreen;
+ CubeScreen *csScreen;
+
+ bool mDamage;
+
+ int mNumSnowflakes;
+
+ snowflakeRec *mSnow;
+
+ Water *mWater;
+ Water *mGround;
+
+ float mXRotate;
+ float mVRotate;
+
+ float mWaterHeight; //water surface height
+
+ int mHsize;
+ float mDistance; //perpendicular distance to wall from centre
+ float mRadius; //radius on which the hSize points lie
+ float mArcAngle; //360 degrees / horizontal size
+
+ float mSpeedFactor; // multiply snowflake speeds by this value
+
+ GLuint mSnowflakeDisplayList;
+
+ void
+ optionChange (CompOption *option,
+ Options num);
+
+ void
+ cubeClearTargetOutput (float xRotate,
+ float vRotate);
+
+ void
+ preparePaint (int ms);
+
+ void
+ cubePaintInside (const GLScreenPaintAttrib &sAttrib,
+ const GLMatrix &transform,
+ CompOutput *output,
+ int size);
+ void
+ donePaint ();
+
+ void
+ updateWater (float time);
+
+ void
+ updateGround (float time);
+
+ void newSnowflakePosition (int);
+ void SnowflakeDrift (int);
+
+ void initializeWorldVariables ();
+
+ void initSnowglobe ();
+ void freeSnowglobe ();
+ void updateSnowglobe ();
+};
+
+#define SNOWGLOBE_SCREEN(s) \
+ SnowglobeScreen *as = SnowglobeScreen::get (s);
+
+class SnowglobePluginVTable :
+public CompPlugin::VTableForScreen <SnowglobeScreen>
+{
+public:
+
+ bool init ();
+};
+
+//All calculations that matter with angles are done clockwise from top.
+//I think of it as x=radius, y=0 being the top (towards 1st desktop from above view)
+//and the z coordinate as height.
+
+void
+updateHeight (Water *w);
+
+void
+freeWater (Water *w);
+
+void
+drawWater (Water *w, bool full, bool wire);
+
+void
+drawGround (Water *w, Water *g);
+
+void
+drawBottomGround (int size, float distance, float bottom);
+
+float
+getHeight (Water *w, float x, float z);
+
+
+
+void DrawSnowflake (int);
+void initDrawSnowflake (void);
+void finDrawSnowflake (void);
+
+void DrawSnowman (int);
+
+void SnowflakeTransform (snowflakeRec *);
+
+#endif
diff --git a/snowman.c b/src/snowman.cpp
index b96a6e6..c734a11 100644
--- a/snowman.c
+++ b/src/snowman.cpp
@@ -1,4 +1,4 @@
-#include "snowglobe-internal.h"
+#include "snowglobe.h"
//points are of the form (y,z,x).
//model made using Blender and generated using script.
diff --git a/water.c b/src/water.cpp
index 30fb943..1fbd224 100644
--- a/water.c
+++ b/src/water.cpp
@@ -24,9 +24,8 @@
/* Uses water amplitude calculation by David Mikos */
-#include "snowglobe-internal.h"
-#include "math.h"
-#include "snowglobe_options.h"
+#include <cmath>
+#include "snowglobe.h"
static void
genTriMesh (Vertex *vertices,
@@ -183,7 +182,7 @@ genWater (int size, int sDiv, float distance, float bottom)
if (size < 3)
return NULL;
- w = malloc (sizeof (Water));
+ w = (Water *) malloc (sizeof (Water));
if (!w)
return NULL;
@@ -209,14 +208,14 @@ genWater (int size, int sDiv, float distance, float bottom)
w->wave1 = 0.0;
w->wave2 = 0.0;
- w->vertices = calloc (1,sizeof (Vertex) * w->nVertices);
+ w->vertices = (Vertex * )calloc (1,sizeof (Vertex) * w->nVertices);
if (!w->vertices)
{
free (w);
return NULL;
}
- w->indices = calloc (1,sizeof (int) * w->nIndices);
+ w->indices = (unsigned int *) calloc (1,sizeof (int) * w->nIndices);
if (!w->indices)
{
free (w->vertices);
@@ -310,7 +309,7 @@ setAmplitude (Vertex *v,
void
updateHeight (Water *w)
{
- int i;
+ unsigned int i;
if (!w)
return;
@@ -321,94 +320,86 @@ updateHeight (Water *w)
}
void
-updateWater (CompScreen *s, float time)
+SnowglobeScreen::updateWater (float time)
{
- SNOWGLOBE_SCREEN (s);
- CUBE_SCREEN (s);
-
int sDiv = 0;
- int size = s->hsize * cs->nOutput;
+ int size = screen->vpSize ().width () * csScreen->nOutput ();
- if (!as->water)
- as->water = genWater (size, sDiv, cs->distance, -0.5);
+ if (!mWater)
+ mWater = genWater (size, sDiv, csScreen->distance (), -0.5);
- if (!as->water)
+ if (!mWater)
return;
-
-
- if (as->water->size != size || as->water->sDiv != sDiv ||
- as->water->distance != cs->distance)
+ if (mWater->size != size || mWater->sDiv != sDiv ||
+ mWater->distance != csScreen->distance ())
{
- freeWater (as->water);
- as->water = genWater (size, sDiv, cs->distance, -0.5);
+ freeWater (mWater);
+ mWater = genWater (size, sDiv, csScreen->distance (), -0.5);
- if (!as->water)
+ if (!mWater)
return;
}
- as->water->wave1 += 0;
- as->water->wave2 += 0;
+ mWater->wave1 += 0;
+ mWater->wave2 += 0;
- as->water->wave1 = 0;
- as->water->wave2 = 0;
- as->water->bh = 0.5;
+ mWater->wave1 = 0;
+ mWater->wave2 = 0;
+ mWater->bh = 0.5;
- as->water->wa = 0.0;
- as->water->swa = 0.0;
- as->water->wf = 0.0;
- as->water->swf = 0.0;
+ mWater->wa = 0.0;
+ mWater->swa = 0.0;
+ mWater->wf = 0.0;
+ mWater->swf = 0.0;
}
void
-updateGround (CompScreen *s, float time)
+SnowglobeScreen::updateGround (float time)
{
- SNOWGLOBE_SCREEN (s);
- CUBE_SCREEN (s);
-
- int sDiv = snowglobeGetGridQuality (s);
- int size = s->hsize * cs->nOutput;
-
- Bool update = FALSE;
+ int sDiv = optionGetGridQuality ();
+ int size = screen->vpSize ().width () * csScreen->nOutput ();
+
+ bool update = false;
- if (!as->ground)
+ if (!mGround)
{
- as->ground = genWater (size, sDiv, cs->distance, -0.5);
- update = TRUE;
+ mGround = genWater (size, sDiv, csScreen->distance (), -0.5);
+ update = true;
}
- if (!as->ground)
+ if (!mGround)
return;
- if (as->ground->size != size || as->ground->sDiv != sDiv ||
- as->ground->distance != cs->distance)
+ if (mGround->size != size || mGround->sDiv != sDiv ||
+ mGround->distance != csScreen->distance ())
{
- freeWater (as->ground);
- as->ground = genWater (size, sDiv, cs->distance, -0.5);
+ freeWater (mGround);
+ mGround = genWater (size, sDiv, csScreen->distance (), -0.5);
- update = TRUE;
- if (!as->ground)
+ update = true;
+ if (!mGround)
return;
}
if (!update)
return;
- as->ground->wave1 = (float)(rand() & 15) / 15.0;
- as->ground->wave2 = (float)(rand() & 15) / 15.0;
+ mGround->wave1 = (float)(rand() & 15) / 15.0;
+ mGround->wave2 = (float)(rand() & 15) / 15.0;
- as->ground->bh = -0.45;
- as->ground->wa = 0.1;
- as->ground->swa = 0.02;
- as->ground->wf = 2.0;
- as->ground->swf = 10.0;
+ mGround->bh = -0.45;
+ mGround->wa = 0.1;
+ mGround->swa = 0.02;
+ mGround->wf = 2.0;
+ mGround->swf = 10.0;
- updateHeight (as->ground);
+ updateHeight (mGround);
}
void
-drawWater (Water *w, Bool full, Bool wire)
+drawWater (Water *w, bool full, bool wire)
{
static const float mat_shininess[] = { 50.0 };
static const float mat_specular[] = { 0.5, 0.5, 0.5, 1.0 };
@@ -457,7 +448,7 @@ drawWater (Water *w, Bool full, Bool wire)
if (wire)
{
- int i, j;
+ unsigned int i, j;
glColor4usv (defaultColor);