[ROSAPPS/SCREENSAVERS]
authorAmine Khaldi <amine.khaldi@reactos.org>
Sat, 1 Oct 2011 21:28:47 +0000 (21:28 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sat, 1 Oct 2011 21:28:47 +0000 (21:28 +0000)
* Add a new Starfield screensaver. By Carlo Bramini (carlo DOT bramix AT libero DOT it).
* Adapted the build system files to get it to compile with current trunk.
See issue #6270 for more details.

svn path=/trunk/; revision=53920

15 files changed:
rosapps/applications/screensavers/ssstars/CMakeLists.txt [new file with mode: 0644]
rosapps/applications/screensavers/ssstars/lang/en-US.rc [new file with mode: 0644]
rosapps/applications/screensavers/ssstars/lang/it-IT.rc [new file with mode: 0644]
rosapps/applications/screensavers/ssstars/lang/pl-PL.rc [new file with mode: 0644]
rosapps/applications/screensavers/ssstars/lang/ru-RU.rc [new file with mode: 0644]
rosapps/applications/screensavers/ssstars/makefile [new file with mode: 0644]
rosapps/applications/screensavers/ssstars/res/cosmicfractal.bmp [new file with mode: 0644]
rosapps/applications/screensavers/ssstars/res/icon_stars.ico [new file with mode: 0644]
rosapps/applications/screensavers/ssstars/res/star.bmp [new file with mode: 0644]
rosapps/applications/screensavers/ssstars/resource.h [new file with mode: 0644]
rosapps/applications/screensavers/ssstars/resource.rc [new file with mode: 0644]
rosapps/applications/screensavers/ssstars/settings.c [new file with mode: 0644]
rosapps/applications/screensavers/ssstars/settings.h [new file with mode: 0644]
rosapps/applications/screensavers/ssstars/ssstars.c [new file with mode: 0644]
rosapps/applications/screensavers/ssstars/ssstars.rbuild [new file with mode: 0644]

diff --git a/rosapps/applications/screensavers/ssstars/CMakeLists.txt b/rosapps/applications/screensavers/ssstars/CMakeLists.txt
new file mode 100644 (file)
index 0000000..9010379
--- /dev/null
@@ -0,0 +1,15 @@
+
+set_rc_compiler()
+
+add_executable(ssstars
+    ssstars.c
+    settings.c
+    resource.rc)
+
+set_module_type(ssstars win32gui UNICODE)
+set_target_properties(ssstars PROPERTIES SUFFIX ".scr")
+
+target_link_libraries(ssstars scrnsave)
+add_importlibs(ssstars user32 gdi32 opengl32 glu32 advapi32 comctl32 shell32 msvcrt kernel32)
+
+add_cd_file(TARGET ssstars DESTINATION reactos/system32 FOR all)
diff --git a/rosapps/applications/screensavers/ssstars/lang/en-US.rc b/rosapps/applications/screensavers/ssstars/lang/en-US.rc
new file mode 100644 (file)
index 0000000..ae75a45
--- /dev/null
@@ -0,0 +1,52 @@
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+// Dialog
+
+DLG_SCRNSAVECONFIGURE DIALOGEX 0, 0, 292, 282
+STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION
+CAPTION "Settings"
+FONT 8, "MS Shell Dlg"
+BEGIN
+    GROUPBOX        "Options",IDC_STATIC,16,100,260,76
+    RTEXT           "Number of stars:",IDC_STATIC,24,116,68,12,
+                    SS_CENTERIMAGE
+    CONTROL         "Slider1",IDC_SLIDER_NUM_OF_STARS,"msctls_trackbar32",
+                    TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,96,116,140,12
+    CTEXT           "Static",IDC_TEXT_NUM_OF_STARS,240,116,24,12,
+                    SS_CENTERIMAGE,WS_EX_STATICEDGE
+    RTEXT           "Speed:",IDC_STATIC,24,137,68,12,SS_CENTERIMAGE
+    CONTROL         "Slider1",IDC_SLIDER_SPEED,"msctls_trackbar32",TBS_BOTH | 
+                    TBS_NOTICKS | WS_TABSTOP,96,137,140,12
+    CTEXT           "Static",IDC_TEXT_SPEED,240,137,24,12,SS_CENTERIMAGE,
+                    WS_EX_STATICEDGE
+    RTEXT           "Rotation:",IDC_STATIC,24,156,68,12,SS_CENTERIMAGE
+    COMBOBOX        IDC_COMBO_ROTATION,100,156,80,60,CBS_DROPDOWNLIST | 
+                    WS_TABSTOP
+    CONTROL         "",IDC_IMAGE_COSMOS,"Static",SS_BITMAP | SS_CENTERIMAGE,
+                    4,4,284,92
+    GROUPBOX        "Advanced",IDC_STATIC,16,180,260,72
+    CONTROL         "Enable background blending",IDC_CHECK_DOBLENDING,
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,196,110,10
+    CONTROL         "Enable accurate perspective correction",
+                    IDC_CHECK_PERSPECTIVE,"Button",BS_AUTOCHECKBOX | 
+                    WS_TABSTOP,24,208,142,10
+    CONTROL         "Enable texture filtering",IDC_CHECK_FILTERING,
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,220,90,10
+    CONTROL         "Enable smooth shading",IDC_CHECK_SHADING,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,24,232,100,10
+    PUSHBUTTON      "OK",IDOK,60,260,52,16
+    PUSHBUTTON      "Cancel",IDCANCEL,120,260,52,16
+    PUSHBUTTON      "About",IDC_BUTTON_ABOUT,179,260,52,16
+END
+
+// String Tables
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_DESCRIPTION         "Starfield"
+    IDS_ROTATION_NONE       "None"
+    IDS_ROTATION_LINEAR     "Linear"
+    IDS_ROTATION_PERIODIC   "Periodic"
+    IDS_LICENSE             "Starfield is free software released under GNU GPL license."
+    IDS_AUTHOR              "Written by Carlo Bramini"
+END
diff --git a/rosapps/applications/screensavers/ssstars/lang/it-IT.rc b/rosapps/applications/screensavers/ssstars/lang/it-IT.rc
new file mode 100644 (file)
index 0000000..7fabe6c
--- /dev/null
@@ -0,0 +1,52 @@
+LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL
+
+// Dialog
+
+DLG_SCRNSAVECONFIGURE DIALOGEX 0, 0, 292, 282
+STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION
+CAPTION "Impostazioni"
+FONT 8, "MS Shell Dlg"
+BEGIN
+    GROUPBOX        "Opzioni",IDC_STATIC,16,100,260,76
+    RTEXT           "Numero di stelle:",IDC_STATIC,24,116,68,12,
+                    SS_CENTERIMAGE
+    CONTROL         "Slider1",IDC_SLIDER_NUM_OF_STARS,"msctls_trackbar32",
+                    TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,96,116,140,12
+    CTEXT           "Static",IDC_TEXT_NUM_OF_STARS,240,116,24,12,
+                    SS_CENTERIMAGE,WS_EX_STATICEDGE
+    RTEXT           "Velocità:",IDC_STATIC,24,137,68,12,SS_CENTERIMAGE
+    CONTROL         "Slider1",IDC_SLIDER_SPEED,"msctls_trackbar32",TBS_BOTH | 
+                    TBS_NOTICKS | WS_TABSTOP,96,137,140,12
+    CTEXT           "Static",IDC_TEXT_SPEED,240,137,24,12,SS_CENTERIMAGE,
+                    WS_EX_STATICEDGE
+    RTEXT           "Rotazione:",IDC_STATIC,24,156,68,12,SS_CENTERIMAGE
+    COMBOBOX        IDC_COMBO_ROTATION,100,156,80,60,CBS_DROPDOWNLIST | 
+                    WS_TABSTOP
+    CONTROL         "",IDC_IMAGE_COSMOS,"Static",SS_BITMAP | SS_CENTERIMAGE,
+                    4,4,284,92
+    GROUPBOX        "Avanzate",IDC_STATIC,16,180,260,72
+    CONTROL         "Attiva blending sullo sfondo",IDC_CHECK_DOBLENDING,
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,196,102,10
+    CONTROL         "Attiva correzione prospettica accurata",
+                    IDC_CHECK_PERSPECTIVE,"Button",BS_AUTOCHECKBOX | 
+                    WS_TABSTOP,24,208,135,10
+    CONTROL         "Attiva filtraggio delle texture",IDC_CHECK_FILTERING,
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,220,110,10
+    CONTROL         "Attiva illuminazione accurata",IDC_CHECK_SHADING,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,24,232,110,10
+    PUSHBUTTON      "OK",IDOK,60,260,52,16
+    PUSHBUTTON      "Annulla",IDCANCEL,120,260,52,16
+    PUSHBUTTON      "Info",IDC_BUTTON_ABOUT,179,260,52,16
+END
+
+// String Tables
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_DESCRIPTION         "Campo stellare"
+    IDS_ROTATION_NONE       "Nessuna"
+    IDS_ROTATION_LINEAR     "Lineare"
+    IDS_ROTATION_PERIODIC   "Periodica"
+    IDS_LICENSE             "Campo stellare e` software libero rilasciato sotto licenza GNU GPL."
+    IDS_AUTHOR              "Scritto da Carlo Bramini"
+END
diff --git a/rosapps/applications/screensavers/ssstars/lang/pl-PL.rc b/rosapps/applications/screensavers/ssstars/lang/pl-PL.rc
new file mode 100644 (file)
index 0000000..53327f0
--- /dev/null
@@ -0,0 +1,52 @@
+LANGUAGE LANG_POLISH, SUBLANG_NEUTRAL
+
+// Dialog
+
+DLG_SCRNSAVECONFIGURE DIALOGEX 0, 0, 292, 282
+STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION
+CAPTION "Ustawienia"
+FONT 8, "MS Shell Dlg"
+BEGIN
+    GROUPBOX        "Opcje",IDC_STATIC,16,100,260,76
+    RTEXT           "Liczba gwiazd:",IDC_STATIC,24,116,68,12,
+                    SS_CENTERIMAGE
+    CONTROL         "Slider1",IDC_SLIDER_NUM_OF_STARS,"msctls_trackbar32",
+                    TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,96,116,140,12
+    CTEXT           "Static",IDC_TEXT_NUM_OF_STARS,240,116,24,12,
+                    SS_CENTERIMAGE,WS_EX_STATICEDGE
+    RTEXT           "Szybkość:",IDC_STATIC,24,137,68,12,SS_CENTERIMAGE
+    CONTROL         "Slider1",IDC_SLIDER_SPEED,"msctls_trackbar32",TBS_BOTH | 
+                    TBS_NOTICKS | WS_TABSTOP,96,137,140,12
+    CTEXT           "Static",IDC_TEXT_SPEED,240,137,24,12,SS_CENTERIMAGE,
+                    WS_EX_STATICEDGE
+    RTEXT           "Obroty:",IDC_STATIC,24,156,68,12,SS_CENTERIMAGE
+    COMBOBOX        IDC_COMBO_ROTATION,100,156,80,60,CBS_DROPDOWNLIST | 
+                    WS_TABSTOP
+    CONTROL         "",IDC_IMAGE_COSMOS,"Static",SS_BITMAP | SS_CENTERIMAGE,
+                    4,4,284,92
+    GROUPBOX        "Advanced",IDC_STATIC,16,180,260,72
+    CONTROL         "Enable background blending",IDC_CHECK_DOBLENDING,
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,196,110,10
+    CONTROL         "Enable accurate perspective correction",
+                    IDC_CHECK_PERSPECTIVE,"Button",BS_AUTOCHECKBOX | 
+                    WS_TABSTOP,24,208,142,10
+    CONTROL         "Enable texture filtering",IDC_CHECK_FILTERING,
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,220,90,10
+    CONTROL         "Enable smooth shading",IDC_CHECK_SHADING,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,24,232,100,10
+    PUSHBUTTON      "OK",IDOK,60,260,52,16
+    PUSHBUTTON      "Anuluj",IDCANCEL,120,260,52,16
+    PUSHBUTTON      "O wygaszaczu",IDC_BUTTON_ABOUT,179,260,52,16
+END
+
+// String Tables
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_DESCRIPTION         "Gwiezdne pole"
+    IDS_ROTATION_NONE       "brak"
+    IDS_ROTATION_LINEAR     "Liniowo"
+    IDS_ROTATION_PERIODIC   "Okresowo"
+    IDS_LICENSE             "Gwiezdne pole to darmowe oprogramowanie wydane na licencji GNU GPL."
+    IDS_AUTHOR              "Napisane przez Carlo Bramini"
+END
diff --git a/rosapps/applications/screensavers/ssstars/lang/ru-RU.rc b/rosapps/applications/screensavers/ssstars/lang/ru-RU.rc
new file mode 100644 (file)
index 0000000..24b41ae
--- /dev/null
@@ -0,0 +1,52 @@
+LANGUAGE LANG_RUSSIAN, SUBLANG_NEUTRAL
+
+// Dialog
+
+DLG_SCRNSAVECONFIGURE DIALOGEX 0, 0, 292, 282
+STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION
+CAPTION "Ïàðàìåòðû çàñòàâêè"
+FONT 8, "MS Shell Dlg"
+BEGIN
+    GROUPBOX        "Íàñòðîéêè",IDC_STATIC,16,100,260,76
+    RTEXT           "Êîëè÷åñòâî çâ¸çä:",IDC_STATIC,24,116,68,12,
+                    SS_CENTERIMAGE
+    CONTROL         "Slider1",IDC_SLIDER_NUM_OF_STARS,"msctls_trackbar32",
+                    TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,96,116,140,12
+    CTEXT           "Static",IDC_TEXT_NUM_OF_STARS,240,116,24,12,
+                    SS_CENTERIMAGE,WS_EX_STATICEDGE
+    RTEXT           "Ñêîðîñòü:",IDC_STATIC,24,137,68,12,SS_CENTERIMAGE
+    CONTROL         "Slider1",IDC_SLIDER_SPEED,"msctls_trackbar32",TBS_BOTH | 
+                    TBS_NOTICKS | WS_TABSTOP,96,137,140,12
+    CTEXT           "Static",IDC_TEXT_SPEED,240,137,24,12,SS_CENTERIMAGE,
+                    WS_EX_STATICEDGE
+    RTEXT           "Âðàùåíèå:",IDC_STATIC,24,156,68,12,SS_CENTERIMAGE
+    COMBOBOX        IDC_COMBO_ROTATION,100,156,80,60,CBS_DROPDOWNLIST | 
+                    WS_TABSTOP
+    CONTROL         "",IDC_IMAGE_COSMOS,"Static",SS_BITMAP | SS_CENTERIMAGE,
+                    4,4,284,92
+    GROUPBOX        "Advanced",IDC_STATIC,16,180,260,72
+    CONTROL         "Enable background blending",IDC_CHECK_DOBLENDING,
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,196,110,10
+    CONTROL         "Enable accurate perspective correction",
+                    IDC_CHECK_PERSPECTIVE,"Button",BS_AUTOCHECKBOX | 
+                    WS_TABSTOP,24,208,142,10
+    CONTROL         "Enable texture filtering",IDC_CHECK_FILTERING,
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,220,90,10
+    CONTROL         "Enable smooth shading",IDC_CHECK_SHADING,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,24,232,100,10
+    PUSHBUTTON      "OK",IDOK,60,260,52,16
+    PUSHBUTTON      "Îòìåíà",IDCANCEL,120,260,52,16
+    PUSHBUTTON      "Πïðîãðàììå",IDC_BUTTON_ABOUT,179,260,52,16
+END
+
+// String Tables
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_DESCRIPTION         "Çâ¸çäíîå ïîëå"
+    IDS_ROTATION_NONE       "Îòñóòñòâóåò"
+    IDS_ROTATION_LINEAR     "Ëèíåéíîå"
+    IDS_ROTATION_PERIODIC   "Ïåðèîäè÷åñêîå"
+    IDS_LICENSE             "Çâ¸çäíîå ïîëå - ýòî ñâîáîäíîå ÏÎ, ðàñïðîñòðàíÿåìîå ïîä ëèöåíçèåé GNU GPL."
+    IDS_AUTHOR              "Çàñòàâêó ñîçäàë Carlo Bramini"
+END
diff --git a/rosapps/applications/screensavers/ssstars/makefile b/rosapps/applications/screensavers/ssstars/makefile
new file mode 100644 (file)
index 0000000..83180ee
--- /dev/null
@@ -0,0 +1,79 @@
+# Makefile for Starfield screensaver
+#
+# syntax:
+#   make <platform> <unicode>
+#
+# parameters:
+#   <platform>
+#       x68_64=1 : compile for x86_64
+#       undefined: use default tools (typically IA_32)
+#   <unicode>
+#       unicode=1: compile as UNICODE application
+#       undefined: compile as ASCII application
+
+# Makefile for Starfield screensaver
+
+# Default tools
+TOOL_PREFIX=
+
+ifdef x86-64
+TOOL_PREFIX=x86_64-pc-mingw32-
+endif
+
+CPP     = $(TOOL_PREFIX)g++.exe
+CC      = $(TOOL_PREFIX)gcc.exe
+WINDRES = $(TOOL_PREFIX)windres.exe
+
+# Define some variables
+INCLUDE  = 
+DEBUG    = -Wall
+OPTIMIZE = -O2 -fomit-frame-pointer
+
+ifdef x86-64
+# nothing here
+else
+OPTIMIZE+= -mpreferred-stack-boundary=2
+endif
+
+# Strip, typical mingw flag, help library
+LIBS     = -lopengl32 -lglu32 -lscrnsave -lcomctl32 -s -mwindows
+
+# Base files
+FILES = stars settings
+
+# Check the UNICODE support
+ifeq ($(unicode), 1)
+UNICODE=u
+DEFS  += -DUNICODE -D_UNICODE
+else
+UNICODE=a
+endif
+
+CFLAGS   = $(DEFS) $(INCLUDE) $(DEBUG) $(OPTIMIZE)
+
+DIR_OBJECTS = obj/$(TOOL_PREFIX)$(UNICODE)/
+
+# target file name
+TARGET   = $(DIR_OBJECTS)ssstars.scr
+
+OBJS= $(addprefix $(DIR_OBJECTS), $(addsuffix .o, $(FILES)))
+RES = $(DIR_OBJECTS)resource.res
+
+.PHONY: all all-before all-after clean clean-custom
+
+all: all-before $(TARGET) all-after
+
+clean: clean-custom
+       $(RM) $(OBJ) $(TARGET)
+
+$(TARGET): $(OBJS) $(RES)
+       $(CC) $^ -o $@ $(LIBS)
+
+$(DIR_OBJECTS)%.o: %.c $(DIR_OBJECTS)
+       $(CC) -c $< -o $@ $(CFLAGS)
+
+$(RES): resource.rc 
+       $(WINDRES) -i $< --input-format=rc -o $@ -O coff 
+
+$(DIR_OBJECTS):
+       -mkdir $@
diff --git a/rosapps/applications/screensavers/ssstars/res/cosmicfractal.bmp b/rosapps/applications/screensavers/ssstars/res/cosmicfractal.bmp
new file mode 100644 (file)
index 0000000..e524c07
Binary files /dev/null and b/rosapps/applications/screensavers/ssstars/res/cosmicfractal.bmp differ
diff --git a/rosapps/applications/screensavers/ssstars/res/icon_stars.ico b/rosapps/applications/screensavers/ssstars/res/icon_stars.ico
new file mode 100644 (file)
index 0000000..80d759c
Binary files /dev/null and b/rosapps/applications/screensavers/ssstars/res/icon_stars.ico differ
diff --git a/rosapps/applications/screensavers/ssstars/res/star.bmp b/rosapps/applications/screensavers/ssstars/res/star.bmp
new file mode 100644 (file)
index 0000000..0c240c2
Binary files /dev/null and b/rosapps/applications/screensavers/ssstars/res/star.bmp differ
diff --git a/rosapps/applications/screensavers/ssstars/resource.h b/rosapps/applications/screensavers/ssstars/resource.h
new file mode 100644 (file)
index 0000000..cbd1d96
--- /dev/null
@@ -0,0 +1,25 @@
+#define IDS_DESCRIPTION                 1
+#define IDS_ROTATION_NONE               2
+#define IDS_ROTATION_LINEAR             3
+#define IDS_ROTATION_PERIODIC           4
+
+#define IDS_LICENSE                     5
+#define IDS_AUTHOR                      6
+
+#define IDI_STARFIELD                   101
+
+#define IDB_COSMOS                      102
+#define IDB_STAR                        103
+
+#define IDC_SLIDER_NUM_OF_STARS         1000
+#define IDC_SLIDER_SPEED                1001
+#define IDC_TEXT_NUM_OF_STARS           1002
+#define IDC_TEXT_SPEED                  1003
+#define IDC_COMBO_ROTATION              1004
+#define IDC_IMAGE_COSMOS                1005
+#define IDC_BUTTON_ABOUT                1006
+
+#define IDC_CHECK_DOBLENDING            1007
+#define IDC_CHECK_PERSPECTIVE           1008
+#define IDC_CHECK_FILTERING             1009
+#define IDC_CHECK_SHADING               1010
diff --git a/rosapps/applications/screensavers/ssstars/resource.rc b/rosapps/applications/screensavers/ssstars/resource.rc
new file mode 100644 (file)
index 0000000..4d17224
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * ReactOS Starfield (global resource file)
+ *
+ * Copyright 2011, Carlo Bramini
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <windows.h>
+#include <scrnsave.h>
+
+#include "resource.h"
+
+#ifndef IDC_STATIC
+#define IDC_STATIC    -1
+#endif
+
+#ifndef DS_SHELLFONT
+#define DS_SHELLFONT DS_SETFONT|DS_FIXEDSYS
+#endif
+
+// Common resources
+
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+
+// Icons
+IDI_STARFIELD           ICON    DISCARDABLE     "res/icon_stars.ico"
+
+// Bitmap
+
+IDB_COSMOS              BITMAP  DISCARDABLE     "res/cosmicfractal.bmp"
+IDB_STAR                BITMAP  DISCARDABLE     "res/star.bmp"
+
+
+// Language resources
+#include "lang/en-US.rc"
+#include "lang/it-IT.rc"
+#include "lang/ru-RU.rc"
+
+// UTF-8
+#pragma code_page(65001)
+
+#include "lang/pl-PL.rc"
diff --git a/rosapps/applications/screensavers/ssstars/settings.c b/rosapps/applications/screensavers/ssstars/settings.c
new file mode 100644 (file)
index 0000000..d470daf
--- /dev/null
@@ -0,0 +1,335 @@
+/*
+ * Star field screensaver
+ *
+ * Copyright 2011 Carlo Bramini
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <tchar.h>
+#include <commctrl.h>
+#include <shellapi.h>
+
+#include "resource.h"
+#include "settings.h"
+
+#define SIZEOF(_v)  (sizeof(_v) / sizeof(*_v))
+
+// Options for the starfield
+SSSTARS Settings;
+
+// Factory default settings.
+static const SSSTARS FactoryDefaults = {
+    MAX_STARS,
+    20,
+    ROTATION_PERIODIC,
+
+    TRUE,
+    TRUE,
+    TRUE,
+    TRUE
+};
+
+static const DWORD RotoStrings[] = {
+    IDS_ROTATION_NONE,
+    IDS_ROTATION_LINEAR,
+    IDS_ROTATION_PERIODIC
+};
+
+static DWORD QueryDWORD(HKEY hKey, LPCTSTR pszValueName, DWORD Default)
+{
+    DWORD dwData, dwType, cbData;
+    LONG  lRes;
+
+    dwType = REG_DWORD;
+    cbData = sizeof(DWORD);
+
+    lRes = RegQueryValueEx(
+                hKey,
+                pszValueName,
+                NULL,
+                &dwType,
+                (LPBYTE)&dwData,
+                &cbData);
+
+    if (lRes != ERROR_SUCCESS || dwType != REG_DWORD)
+        return Default;
+
+    return dwData;
+}
+
+static void SaveDWORD(HKEY hKey, LPCTSTR pszValueName, DWORD dwValue)
+{
+    RegSetValueEx(hKey, pszValueName, 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(dwValue));
+}
+
+
+void LoadSettings(void)
+{
+    HKEY  hKey;
+    LONG  lRes;
+
+    Settings = FactoryDefaults;
+
+    lRes = RegCreateKeyEx(
+            HKEY_CURRENT_USER,
+            _T("Software\\Microsoft\\ScreenSavers\\Ssstars"),
+            0,
+            _T(""),
+            0,
+            KEY_READ,
+            NULL,
+            &hKey,
+            NULL);
+
+    if (lRes != ERROR_SUCCESS)
+        return;
+
+    Settings.uiNumStars = QueryDWORD(hKey, _T("NumberOfStars"),  Settings.uiNumStars);
+    Settings.uiSpeed    = QueryDWORD(hKey, _T("Speed"),          Settings.uiSpeed);
+    Settings.uiRotation = QueryDWORD(hKey, _T("TypeOfRotation"), Settings.uiRotation);
+
+    Settings.bDoBlending      = QueryDWORD(hKey, _T("DoBlending"),      Settings.bDoBlending);
+    Settings.bFinePerspective = QueryDWORD(hKey, _T("FinePerspective"), Settings.bFinePerspective);
+    Settings.bEnableFiltering = QueryDWORD(hKey, _T("EnableFiltering"), Settings.bEnableFiltering);
+    Settings.bSmoothShading   = QueryDWORD(hKey, _T("SmoothShading"),   Settings.bSmoothShading);
+
+    // Check the number of stars to be in range
+    if (Settings.uiNumStars < MIN_STARS)
+        Settings.uiNumStars = MIN_STARS;
+    else
+    if (Settings.uiNumStars > MAX_STARS)
+        Settings.uiNumStars = MAX_STARS;
+
+    // Check the speed to be in range
+    if (Settings.uiSpeed < MIN_SPEED)
+        Settings.uiSpeed = MIN_SPEED;
+    else
+    if (Settings.uiSpeed > MAX_SPEED)
+        Settings.uiSpeed = MAX_SPEED;
+
+    // Check type of rotation to be in range
+    if (Settings.uiRotation != ROTATION_NONE &&
+        Settings.uiRotation != ROTATION_LINEAR &&
+        Settings.uiRotation != ROTATION_PERIODIC)
+        Settings.uiRotation = ROTATION_PERIODIC;
+
+    RegCloseKey(hKey);
+}
+
+void SaveSettings(void)
+{
+    HKEY  hKey;
+    LONG  lRes;
+
+    lRes = RegCreateKeyEx(
+            HKEY_CURRENT_USER,
+            _T("Software\\Microsoft\\ScreenSavers\\Ssstars"),
+            0,
+            _T(""),
+            0,
+            KEY_WRITE,
+            NULL,
+            &hKey,
+            NULL);
+
+    if (lRes != ERROR_SUCCESS)
+        return;
+
+    SaveDWORD(hKey, _T("NumberOfStars"),  Settings.uiNumStars);
+    SaveDWORD(hKey, _T("Speed"),          Settings.uiSpeed);
+    SaveDWORD(hKey, _T("TypeOfRotation"), Settings.uiRotation);
+
+    SaveDWORD(hKey, _T("DoBlending"),      Settings.bDoBlending);
+    SaveDWORD(hKey, _T("FinePerspective"), Settings.bFinePerspective);
+    SaveDWORD(hKey, _T("EnableFiltering"), Settings.bEnableFiltering);
+    SaveDWORD(hKey, _T("SmoothShading"),   Settings.bSmoothShading);
+
+    RegCloseKey(hKey);
+}
+
+static void SetupControls(HWND hWnd)
+{
+    TCHAR     Strings[256];
+    HINSTANCE hInstance;
+    UINT      x, gap;
+    LOGFONT   lf;
+    HFONT     hFont;
+    HBITMAP   hCosmos;
+    HDC       hDC, hMemDC;
+    HGDIOBJ   hOldBmp, hOldFnt;
+    SIZE      sizeReactOS;
+    SIZE      sizeStarfield;
+    BITMAP    bm;
+
+    hInstance = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE);
+
+    SendDlgItemMessage(hWnd, IDC_SLIDER_NUM_OF_STARS, TBM_SETRANGE, FALSE, MAKELPARAM(MIN_STARS, MAX_STARS));
+
+    SendDlgItemMessage(hWnd, IDC_SLIDER_SPEED, TBM_SETRANGE, FALSE, MAKELPARAM(1, 100));
+
+    for (x = 0; x < ROTATION_ITEMS; x++)
+    {
+        LoadString(hInstance, RotoStrings[x], Strings, sizeof(Strings)/sizeof(TCHAR));
+        SendDlgItemMessage(hWnd, IDC_COMBO_ROTATION, CB_ADDSTRING, 0, (LPARAM)Strings);
+    }
+
+    hCosmos = LoadImage(hInstance, MAKEINTRESOURCE(IDB_COSMOS), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
+
+    hDC = GetDC(hWnd);
+    hMemDC = CreateCompatibleDC(hDC);
+
+    // Create the font for the title
+    ZeroMemory(&lf, sizeof(lf));
+
+    lf.lfWeight  = FW_THIN;
+    lf.lfCharSet = ANSI_CHARSET;
+    lf.lfQuality = PROOF_QUALITY;
+    lf.lfHeight  = 36;
+    _tcscpy(lf.lfFaceName, _T("Tahoma"));
+
+    hFont = CreateFontIndirect(&lf);
+
+    hOldBmp = SelectObject(hMemDC, hCosmos);
+    hOldFnt = SelectObject(hMemDC, hFont);
+
+    SetBkMode(hMemDC, TRANSPARENT);
+    SetTextColor(hMemDC, RGB(0xFF, 0xFF, 0xFF));
+
+    x = LoadString(hInstance, IDS_DESCRIPTION, Strings, sizeof(Strings)/sizeof(TCHAR));
+
+    GetTextExtentPoint32(hMemDC, _T("ReactOS"), 7, &sizeReactOS);
+    GetTextExtentPoint32(hMemDC, Strings,       x, &sizeStarfield);
+
+    GetObject(hCosmos, sizeof(BITMAP), &bm);
+
+    gap = bm.bmHeight - sizeReactOS.cy - sizeStarfield.cy;
+
+    TextOut(hMemDC, 16, gap * 2 / 5, _T("ReactOS"), 7);
+    TextOut(hMemDC, 16, gap * 3 / 5 + sizeReactOS.cy, Strings, x);
+
+    SelectObject(hMemDC, hOldBmp);
+    SelectObject(hMemDC, hOldFnt);
+
+    DeleteObject(hFont);
+
+    DeleteDC(hMemDC);
+    ReleaseDC(hWnd, hDC);
+
+    SendDlgItemMessage(hWnd, IDC_IMAGE_COSMOS, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hCosmos);
+}
+
+static void ApplySettings(HWND hWnd)
+{
+    SendDlgItemMessage(hWnd, IDC_SLIDER_NUM_OF_STARS, TBM_SETPOS, TRUE, Settings.uiNumStars);
+    SetDlgItemInt(hWnd, IDC_TEXT_NUM_OF_STARS, Settings.uiNumStars, FALSE);
+
+    SendDlgItemMessage(hWnd, IDC_SLIDER_SPEED, TBM_SETPOS, TRUE, Settings.uiSpeed);
+    SetDlgItemInt(hWnd, IDC_TEXT_SPEED, Settings.uiSpeed, FALSE);
+
+    SendDlgItemMessage(hWnd, IDC_COMBO_ROTATION, CB_SETCURSEL, (WPARAM)Settings.uiRotation, 0);
+
+    SendDlgItemMessage(hWnd, IDC_CHECK_DOBLENDING,  BM_SETCHECK, (WPARAM)Settings.bDoBlending, 0);
+    SendDlgItemMessage(hWnd, IDC_CHECK_PERSPECTIVE, BM_SETCHECK, (WPARAM)Settings.bFinePerspective, 0);
+    SendDlgItemMessage(hWnd, IDC_CHECK_FILTERING,   BM_SETCHECK, (WPARAM)Settings.bEnableFiltering, 0);
+    SendDlgItemMessage(hWnd, IDC_CHECK_SHADING,     BM_SETCHECK, (WPARAM)Settings.bSmoothShading, 0);
+}
+
+static void ReadSettings(HWND hWnd)
+{
+    Settings.uiNumStars = SendDlgItemMessage(hWnd, IDC_SLIDER_NUM_OF_STARS, TBM_GETPOS, 0, 0);
+    SetDlgItemInt(hWnd, IDC_TEXT_NUM_OF_STARS, Settings.uiNumStars, FALSE);
+
+    Settings.uiSpeed = SendDlgItemMessage(hWnd, IDC_SLIDER_SPEED, TBM_GETPOS, 0, 0);
+    SetDlgItemInt(hWnd, IDC_TEXT_SPEED, Settings.uiSpeed, FALSE);
+
+    Settings.uiRotation = SendDlgItemMessage(hWnd, IDC_COMBO_ROTATION, CB_GETCURSEL, 0, 0);
+
+    Settings.bDoBlending      = SendDlgItemMessage(hWnd, IDC_CHECK_DOBLENDING,  BM_GETCHECK, 0, 0);
+    Settings.bFinePerspective = SendDlgItemMessage(hWnd, IDC_CHECK_PERSPECTIVE, BM_GETCHECK, 0, 0);
+    Settings.bEnableFiltering = SendDlgItemMessage(hWnd, IDC_CHECK_FILTERING,   BM_GETCHECK, 0, 0);
+    Settings.bSmoothShading   = SendDlgItemMessage(hWnd, IDC_CHECK_SHADING,     BM_GETCHECK, 0, 0);
+}
+
+static BOOL OnCommandAbout(HWND hWnd)
+{
+    HINSTANCE hInstance;
+    HICON     hIcon;
+    TCHAR     szAppName[256];
+    TCHAR     szAuthor[256];
+    TCHAR     szLicense[1024];
+
+    hInstance = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE);
+
+    hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_STARFIELD));
+
+    LoadString(hInstance, IDS_DESCRIPTION, szAppName, SIZEOF(szAppName));
+    LoadString(hInstance, IDS_AUTHOR,      szAuthor,  SIZEOF(szAuthor));
+    LoadString(hInstance, IDS_LICENSE,     szLicense, SIZEOF(szLicense));
+
+    _tcscat(szAppName, _T("#"));
+    _tcscat(szAppName, szAuthor);
+
+    ShellAbout(hWnd, szAppName, szLicense, hIcon);
+
+    return TRUE;
+}
+
+//
+// Dialogbox procedure for Configuration window
+//
+BOOL CALLBACK ScreenSaverConfigureDialog(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+    switch (uMsg) {
+    case WM_INITDIALOG:
+        LoadSettings();
+        SetupControls(hDlg);
+        ApplySettings(hDlg);
+        return TRUE;
+
+    case WM_COMMAND:
+        switch (LOWORD( wParam )) { 
+
+        case IDOK:
+            // Write configuration
+            SaveSettings();
+
+            // Fall down...
+        case IDCANCEL: 
+            EndDialog( hDlg, LOWORD( wParam )); 
+            return TRUE;
+
+        case IDC_BUTTON_ABOUT:
+            return OnCommandAbout(hDlg);
+        }
+
+    case WM_HSCROLL:
+        ReadSettings(hDlg);
+        return TRUE;
+
+    }
+
+    return FALSE;
+}
+
+BOOL WINAPI RegisterDialogClasses(HANDLE hInst)
+{
+    InitCommonControls();
+
+    return TRUE;
+}
+
diff --git a/rosapps/applications/screensavers/ssstars/settings.h b/rosapps/applications/screensavers/ssstars/settings.h
new file mode 100644 (file)
index 0000000..198132c
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Star field screensaver
+ *
+ * Copyright 2011 Carlo Bramini
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __SETTINGS_H__
+#define __SETTINGS_H__
+
+#define ROTATION_NONE       0
+#define ROTATION_LINEAR     1
+#define ROTATION_PERIODIC   2
+#define ROTATION_ITEMS      3
+
+#define MIN_STARS           10
+#define MAX_STARS           500
+
+#define MIN_SPEED           1
+#define MAX_SPEED           100
+
+typedef struct {
+    DWORD   uiNumStars;
+    DWORD   uiSpeed;
+    DWORD   uiRotation;
+    DWORD   bDoBlending;
+    DWORD   bFinePerspective;
+    DWORD   bEnableFiltering;
+    DWORD   bSmoothShading;
+} SSSTARS;
+
+extern SSSTARS Settings;
+
+void LoadSettings(void);
+void SaveSettings(void);
+
+#endif
diff --git a/rosapps/applications/screensavers/ssstars/ssstars.c b/rosapps/applications/screensavers/ssstars/ssstars.c
new file mode 100644 (file)
index 0000000..2a2c724
--- /dev/null
@@ -0,0 +1,636 @@
+/*
+ * Star field screensaver
+ *
+ * Copyright 2011 Carlo Bramini
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <tchar.h>
+#include <scrnsave.h>
+
+#include <stdlib.h>
+#include <time.h>
+#include <math.h>
+
+#include <gl/gl.h>
+#include <gl/glu.h>
+
+#include "resource.h"
+#include "settings.h"
+
+#define FAR_PLANE       -80.0f
+#define NEAR_PLANE      3.0f
+#define GAP             0.0f
+#define FIELD_WIDTH     50.f
+#define FIELD_HEIGHT    45.f
+#define FIELD_DEPTH     (NEAR_PLANE - FAR_PLANE + GAP)
+
+#define STAR_RED        0.f
+#define STAR_GREEN      0.f
+#define STAR_BLUE       0.10f
+#define STAR_TAIL       0.9f
+
+typedef struct {
+    float x1;
+    float y1;
+    float x2;
+    float y2;
+    float z;
+} VERTEX;
+
+static VERTEX  Vertex[MAX_STARS];
+static HGLRC   hRC;        // Permanent Rendering Context
+static HDC     hDC;        // Private GDI Device Context
+static float   fAngle;
+static GLuint  glStarTex;
+
+// Light position
+static GLfloat g_light_position[4] = {
+    0.0f, 0.0f, 3.0f, 1.0f
+};
+
+static PIXELFORMATDESCRIPTOR pfd=       // Pixel Format Descriptor
+{
+    sizeof(PIXELFORMATDESCRIPTOR),      // Size Of This Pixel Format Descriptor
+    1,                                  // Version Number (?)
+    PFD_DRAW_TO_WINDOW |                // Format Must Support Window
+    PFD_SUPPORT_OPENGL |                // Format Must Support OpenGL
+    PFD_DOUBLEBUFFER,                   // Must Support Double Buffering
+    PFD_TYPE_RGBA,                      // Request An RGBA Format
+    16,                                 // Select A 16Bit Color Depth
+    0, 0, 0, 0, 0, 0,                   // Color Bits Ignored (?)
+    0,                                  // No Alpha Buffer
+    0,                                  // Shift Bit Ignored (?)
+    0,                                  // No Accumulation Buffer
+    0, 0, 0, 0,                         // Accumulation Bits Ignored (?)
+    16,                                 // 16Bit Z-Buffer (Depth Buffer)
+    0,                                  // No Stencil Buffer
+    0,                                  // No Auxiliary Buffer (?)
+    PFD_MAIN_PLANE,                     // Main Drawing Layer
+    0,                                  // Reserved (?)
+    0, 0, 0                             // Layer Masks Ignored (?)
+};
+
+static HBITMAP CreateStarBitmap(HWND hWnd, HDC hDC)
+{
+    BITMAPINFO bi;
+    LPBYTE     lpBits;
+    LPBYTE    *lppBits;
+    HBITMAP    hTextBmp, hFileBmp;
+    HDC        hTextDC, hFileDC;
+    HGDIOBJ    hOldText, hOldFile;
+    UINT       i;
+    DWORD     *Ptr32;
+    BITMAP     bm;
+    HINSTANCE  hInstance;
+
+    // Get instance for loading the texture
+    hInstance = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE);
+
+    // Load the texture
+    hFileBmp = (HBITMAP)
+              LoadImage(
+                    hInstance,
+                    MAKEINTRESOURCE(IDB_STAR),
+                    IMAGE_BITMAP,
+                    0, 0,
+                    LR_CREATEDIBSECTION | LR_DEFAULTSIZE
+              );
+
+    // Get texture specs
+    GetObject(hFileBmp, sizeof(BITMAP), &bm);
+
+    // Allocate new 32 bit texture
+    ZeroMemory(&bi, sizeof(bi));
+
+    bi.bmiHeader.biSize        = sizeof(BITMAPINFOHEADER);
+    bi.bmiHeader.biWidth       = bm.bmWidth;
+    bi.bmiHeader.biHeight      = -bm.bmHeight;
+    bi.bmiHeader.biPlanes      = 1;
+    bi.bmiHeader.biBitCount    = 32;
+    bi.bmiHeader.biCompression = BI_RGB;
+
+    // Makes GCC happy ;-|
+    lppBits = &lpBits;
+
+    hTextBmp = CreateDIBSection(hDC,
+                                (BITMAPINFO*)&bi,
+                                DIB_RGB_COLORS,
+                                (void**)lppBits,
+                                NULL,
+                                0);
+
+    // Save new texture specs
+//    GetObject(hTextBmp, sizeof(BITMAP), &bmStarTex);
+//    bmStarTex.bmBits = lpBits;
+
+    // Copy 24 bit texture in 32 texture
+    hTextDC = CreateCompatibleDC(hDC);
+    hFileDC = CreateCompatibleDC(hDC);
+
+    hOldText = SelectObject(hTextDC, hTextBmp);
+    hOldFile = SelectObject(hFileDC, hFileBmp);
+
+    BitBlt(hTextDC, 0, 0, bm.bmWidth, bm.bmHeight, hFileDC, 0, 0, SRCCOPY);
+
+    SelectObject(hTextDC, hOldText);
+    SelectObject(hFileDC, hOldFile);
+
+    DeleteDC(hTextDC);
+    DeleteDC(hFileDC);
+
+    // Delete 24 bit texture
+    DeleteObject(hFileBmp);
+
+    GetObject(hTextBmp, sizeof(BITMAP), &bm);
+
+    // Apply ALPHA channel to new texture
+    for (Ptr32=(DWORD *)lpBits, i=0; i < (UINT)(bm.bmWidth * bm.bmHeight); i++)
+    {
+        DWORD Color = Ptr32[i] & 0x00FFFFFF;
+        DWORD Alpha = Color & 0xFF;
+
+        Color |= Alpha << 24;
+
+        Ptr32[i] = Color;
+    }
+
+    return hTextBmp;
+}
+
+static void InitGL(HBITMAP hStarTex)
+{
+    BITMAP       bm;
+    unsigned int i;
+    float        xp, yp, zp;
+
+    // set the GL clear color - use when the color buffer is cleared
+    glClearColor(STAR_RED, STAR_GREEN, STAR_BLUE, STAR_TAIL);
+
+    if (Settings.bSmoothShading)
+        // set the shading model to 'smooth'
+        glShadeModel( GL_SMOOTH );
+    else
+        // set the shading model to 'flat'
+        glShadeModel( GL_FLAT );
+
+    // set GL to render front of polygons
+    glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
+    // enable depth test
+    glDisable( GL_DEPTH_TEST );
+
+    // enable lighting
+    glEnable( GL_LIGHTING );
+    // enable lighting for front
+    glLightModeli( GL_FRONT, GL_TRUE );
+    // material have diffuse and ambient lighting 
+    glColorMaterial( GL_FRONT, GL_AMBIENT_AND_DIFFUSE );
+    // enable color
+    glEnable( GL_COLOR_MATERIAL );
+    // enable light 0
+    glEnable( GL_LIGHT0 );
+
+    // set light attenuation
+    glLightf( GL_LIGHT0, GL_CONSTANT_ATTENUATION,  0.01f); //0.01f );
+    glLightf( GL_LIGHT0, GL_LINEAR_ATTENUATION,    0.01f); //0.2f );
+    glLightf( GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.005f); //0.001f );
+
+    // clear the color buffer once
+    glClear( GL_COLOR_BUFFER_BIT );
+
+    // randomly generate
+    srand( time( NULL ) );
+
+    // Initialize *ALL* stars vertexes (not just programmed ones).
+    for (i = 0; i < MAX_STARS; i++)
+    {
+        xp = ( (float) rand() / RAND_MAX - .5f ) * FIELD_WIDTH;
+        yp = ( (float) rand() / RAND_MAX - .5f ) * FIELD_HEIGHT;
+        zp = ( (float) rand() / RAND_MAX       ) * FIELD_DEPTH + FAR_PLANE;
+
+        Vertex[i].x1 = -1.f + xp;
+        Vertex[i].y1 = -1.f + yp;
+        Vertex[i].x2 =  1.f + xp;
+        Vertex[i].y2 =  1.f + yp;
+        Vertex[i].z  = zp;
+    }
+
+    glGenTextures(1, &glStarTex);           // Create One Texture
+
+    // Create Linear Filtered Texture
+    glBindTexture(GL_TEXTURE_2D, glStarTex);
+
+    if (Settings.bEnableFiltering)
+    {
+        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
+        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
+    } else {
+        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
+        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
+    }
+
+    // Get Texture properties
+    GetObject(hStarTex, sizeof(BITMAP), &bm);
+
+    // Create texture as a mipmap
+#if 0
+    glTexImage2D(GL_TEXTURE_2D, 0, 4, bm.bmWidth, bm.bmHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, bm.bmBits);
+#else
+    gluBuild2DMipmaps(GL_TEXTURE_2D, 4, bm.bmWidth, bm.bmHeight, GL_RGBA, GL_UNSIGNED_BYTE, bm.bmBits);
+#endif
+
+    // Disable Texture Mapping (background smoothing)
+    glDisable(GL_TEXTURE_2D);
+
+    if (Settings.bFinePerspective)
+        // Really Fast Perspective Calculations
+        glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
+    else
+        // Really Nice Perspective Calculations
+        glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
+
+    // enable blending
+    glEnable( GL_BLEND );
+}
+
+static void
+render(void)
+{
+    unsigned int i;
+    float        fSpin;
+    float        fSpeed;
+    float        xp, yp;
+
+    // Initialize current speed
+    fSpeed = (float)Settings.uiSpeed / 100.f;
+
+    glEnable(GL_TEXTURE_2D);                // Enable Texture Mapping
+
+    glBlendFunc(GL_SRC_ALPHA,GL_ONE);           // Set The Blending Function For Translucency
+
+    switch (Settings.uiRotation) {
+    case ROTATION_LINEAR:
+        fAngle += fSpeed;
+        glRotatef( fAngle, 0.0f, 0.0f, 1.0f );
+        break;
+
+    case ROTATION_PERIODIC:
+        fAngle += fSpeed / 75.f;
+        fSpin = (float)(50. * cos(fAngle));
+        glRotatef( fSpin, 0.0f, 0.0f, 1.0f );
+        break;
+    }
+
+    glColor3ub(255, 255, 255);
+
+    glBegin(GL_QUADS);              // Begin Drawing The Textured Quad
+
+    // Draw the stars
+    for (i = 0; i < Settings.uiNumStars; i++)
+    {
+        glTexCoord2f(0.0f, 0.0f); glVertex3f(Vertex[i].x1, Vertex[i].y1, Vertex[i].z);
+        glTexCoord2f(1.0f, 0.0f); glVertex3f(Vertex[i].x2, Vertex[i].y1, Vertex[i].z);
+        glTexCoord2f(1.0f, 1.0f); glVertex3f(Vertex[i].x2, Vertex[i].y2, Vertex[i].z);
+        glTexCoord2f(0.0f, 1.0f); glVertex3f(Vertex[i].x1, Vertex[i].y2, Vertex[i].z);
+
+        // increment z
+        Vertex[i].z += fSpeed;
+
+        // check to see if passed view
+        if( Vertex[i].z > NEAR_PLANE + GAP ||
+            Vertex[i].z < FAR_PLANE )
+        {
+            xp = ( (float) rand() / RAND_MAX - .5f ) * FIELD_WIDTH;
+            yp = ( (float) rand() / RAND_MAX - .5f ) * FIELD_HEIGHT;
+
+            Vertex[i].x1 = -1.f + xp;
+            Vertex[i].y1 = -1.f + yp;
+            Vertex[i].x2 =  1.f + xp;
+            Vertex[i].y2 =  1.f + yp;
+            Vertex[i].z  = FAR_PLANE;
+        }
+    }
+
+    glEnd();                    // Done Drawing The Textured Quad
+
+    glDisable(GL_TEXTURE_2D);               // Enable Texture Mapping
+}
+
+static LRESULT CALLBACK
+OnCreate(HWND hWnd, WPARAM wParam, LPARAM lParam)
+{
+    GLuint  PixelFormat;
+    HBITMAP hStarTex;
+
+    LoadSettings();
+
+    // Gets A Device Context For The Window
+    hDC = GetDC(hWnd);
+
+    // Finds The Closest Match To The Pixel Format We Set Above
+    PixelFormat = ChoosePixelFormat(hDC, &pfd);
+
+    // No Matching Pixel Format?
+    if (!PixelFormat)
+    {
+        MessageBox(0, _T("Can't Find A Suitable PixelFormat."), _T("Error"),MB_OK | MB_ICONERROR);
+
+        // This Sends A 'Message' Telling The Program To Quit
+        PostQuitMessage(0);
+        return 0;
+    }
+
+    // Can We Set The Pixel Mode?
+    if (!SetPixelFormat(hDC, PixelFormat, &pfd))
+    {
+        MessageBox(0, _TEXT("Can't Set The PixelFormat."), _T("Error"), MB_OK | MB_ICONERROR);
+
+        // This Sends A 'Message' Telling The Program To Quit
+        PostQuitMessage(0);
+        return 0;
+    }
+
+    // Grab A Rendering Context
+    hRC = wglCreateContext(hDC);
+
+    // Did We Get One?
+    if (!hRC)
+    {
+        MessageBox(0, _T("Can't Create A GL Rendering Context."), _T("Error"), MB_OK | MB_ICONERROR);
+
+        // This Sends A 'Message' Telling The Program To Quit
+        PostQuitMessage(0);
+        return 0;
+    }
+
+    // Can We Make The RC Active?
+    if (!wglMakeCurrent(hDC, hRC))
+    {
+        MessageBox(0, _T("Can't Activate GLRC."), _TEXT("Error"), MB_OK | MB_ICONERROR);
+
+        // This Sends A 'Message' Telling The Program To Quit
+        PostQuitMessage(0);
+        return 0;
+    }
+
+    // Load star texture
+    hStarTex = CreateStarBitmap(hWnd, hDC);
+
+    // Initialize The GL Screen Using Screen Info
+    InitGL(hStarTex);
+
+    // Delete GDI object for texture
+    DeleteObject(hStarTex);
+
+    // Update screen every 10ms
+    SetTimer(hWnd, 1, 10, NULL);
+
+    // Initialize spinning angle
+    fAngle = 0.f;
+
+    return 0L;
+}
+
+static LRESULT CALLBACK
+OnDestroy(HWND hWnd, WPARAM wParam, LPARAM lParam)
+{
+    // Delete update timer
+    KillTimer(hWnd, 1);
+
+    // Disable Fullscreen Mode
+    ChangeDisplaySettings(NULL, 0);
+
+    // Make The DC Current
+    wglMakeCurrent(hDC, NULL);
+
+    // Kill The RC
+    wglDeleteContext(hRC);
+
+    // Free The DC
+    ReleaseDC(hWnd, hDC);
+
+#ifdef _DEBUG_SSTARS
+    PostQuitMessage(0);
+#endif
+
+    return 0L;
+}
+
+static LRESULT CALLBACK
+OnPaint(HWND hWnd, WPARAM wParam, LPARAM lParam)
+{
+    if (Settings.bDoBlending)
+    {
+        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+
+        // disable lighting
+        glDisable( GL_LIGHTING );
+
+        // blend in a polygon
+        glColor4f(STAR_RED, STAR_GREEN, STAR_BLUE, STAR_TAIL);
+
+        // Restore both model view and projection to identity
+        glMatrixMode(GL_MODELVIEW);
+        glPushMatrix();
+        glLoadIdentity();
+
+        glMatrixMode(GL_PROJECTION);
+        glPushMatrix();
+        glLoadIdentity();
+
+        // Blur the background
+        glBegin( GL_QUADS );
+            glVertex3f( -1.0f, -1.0f, -1.0f );
+            glVertex3f( -1.0f,  1.0f, -1.0f );
+            glVertex3f(  1.0f,  1.0f, -1.0f );
+            glVertex3f(  1.0f, -1.0f, -1.0f );
+        glEnd();
+
+        // Recover previous matrix
+        glPopMatrix();
+        glMatrixMode(GL_MODELVIEW);
+        glPopMatrix();
+
+        // enable lighting
+        glEnable( GL_LIGHTING );
+    } else {
+        glClear(GL_COLOR_BUFFER_BIT);
+    }
+
+    // save the current matrix state, so transformation will
+    // not persist across displayFunc calls, since we
+    // will do a glPopMatrix() at the end of this function
+    glPushMatrix();
+
+    // render the scene
+    render();
+
+    // restore the matrix state
+    glPopMatrix();
+
+    // flush the buffer
+    glFlush();
+
+    // swap the double buffer
+    SwapBuffers(hDC);
+
+    // Clear redraw event
+    ValidateRect(hWnd, NULL);
+
+    return 0L;
+}
+
+static LRESULT CALLBACK
+OnSize(HWND hWnd, WPARAM wParam, LPARAM lParam)
+{
+    GLsizei w = LOWORD(lParam);
+    GLsizei h = HIWORD(lParam);
+
+    // map the view port to the entire client area
+    glViewport(0, 0, w, h);
+
+    // set the matrix mode to projection matrix
+    glMatrixMode(GL_PROJECTION);
+
+    // load the identity matrix
+    glLoadIdentity();
+
+    // set the perspective matrix
+    gluPerspective( 64.0, (GLdouble) w / (GLdouble)h, .1, 300.0 );
+
+    // set the matrix mode to the modelview matrix
+    glMatrixMode(GL_MODELVIEW);
+
+    // load the identity matrix into the modelview matrix
+    glLoadIdentity();
+
+    // set the 'camera'
+    gluLookAt( 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 2.0, 3.0 );
+
+    // set the position of the light
+    glLightfv( GL_LIGHT0, GL_POSITION, g_light_position );
+
+    return 0L;
+}
+
+LRESULT CALLBACK
+ScreenSaverProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+    switch (uMsg) {
+    case WM_CREATE:
+        return OnCreate(hWnd, wParam, lParam);
+
+    case WM_TIMER:
+        InvalidateRect(hWnd, NULL, FALSE);
+        return 0L;
+
+    case WM_DESTROY:
+        return OnDestroy(hWnd, wParam, lParam);
+
+    case WM_PAINT:
+        return OnPaint(hWnd, wParam, lParam);
+
+    case WM_SIZE: // Resizing The Screen
+        return OnSize(hWnd, wParam, lParam);
+    }
+
+#ifdef _DEBUG_SSTARS
+    return DefWindowProc(hWnd, uMsg, wParam, lParam);
+#else
+    return DefScreenSaverProc(hWnd, uMsg, wParam, lParam);
+#endif
+}
+
+#ifdef _DEBUG_SSTARS
+
+ATOM InitApp(HINSTANCE hInstance, LPCTSTR szClassName)
+{
+    WNDCLASS wc;
+
+    ZeroMemory(&wc, sizeof(wc));
+
+    wc.style         = CS_HREDRAW | CS_VREDRAW;
+    wc.lpfnWndProc   = ScreenSaverProc;
+    wc.cbClsExtra    = 0;
+    wc.cbWndExtra    = 0;
+    wc.hInstance     = hInstance;
+    wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
+    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
+    wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
+    wc.lpszMenuName  = NULL;
+    wc.lpszClassName = szClassName;
+
+    return RegisterClass(&wc);
+}
+
+HWND InitInstance(HINSTANCE hInstance, int nCmdShow)
+{
+    HWND  hWnd;
+    TCHAR szClass[] = _T("CLASS");
+    TCHAR szTitle[] = _T("TITLE");
+
+    InitApp(hInstance, szClass);
+
+    hWnd = CreateWindow(
+            szClass,
+            szTitle,
+            WS_OVERLAPPEDWINDOW,
+            CW_USEDEFAULT,
+            CW_USEDEFAULT,
+            192*3, //CW_USEDEFAULT,
+            108*3, //CW_USEDEFAULT,
+            NULL,
+            NULL,
+            hInstance,
+            NULL);
+
+    if (hWnd)
+    {
+        ShowWindow(hWnd, nCmdShow);
+        UpdateWindow(hWnd);
+    }
+
+    return hWnd;
+}
+
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
+{
+    MSG     msg;
+    HWND    hWnd;
+    HWND    hDlg;
+
+    RegisterDialogClasses(hInstance);
+
+    hWnd = InitInstance(hInstance, nShowCmd);
+
+    hDlg = CreateDialog(hInstance, MAKEINTRESOURCE(DLG_SCRNSAVECONFIGURE), NULL, ScreenSaverConfigureDialog);
+    ShowWindow(hDlg, SW_SHOW);
+    UpdateWindow(hDlg);
+
+    for (;;)
+    {
+        if (GetMessage(&msg, NULL, 0, 0) <= 0)
+            break;
+
+        TranslateMessage(&msg);
+        DispatchMessage(&msg);
+    }
+
+    return 0;
+}
+#endif
diff --git a/rosapps/applications/screensavers/ssstars/ssstars.rbuild b/rosapps/applications/screensavers/ssstars/ssstars.rbuild
new file mode 100644 (file)
index 0000000..5fe7403
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
+<module name="ssstars" type="win32scr" installbase="system32" installname="ssstars.scr" unicode="yes">
+       <library>scrnsave</library>
+       <library>chkstk</library>
+       <library>user32</library>
+       <library>gdi32</library>
+       <library>opengl32</library>
+       <library>glu32</library>
+       <library>advapi32</library>
+       <library>comctl32</library>
+       <library>shell32</library>
+
+       <file>ssstars.c</file>
+       <file>settings.c</file>
+       <file>resource.rc</file>
+
+       <metadata description="Starfield screensaver" />
+</module>