ReactOS  0.4.12-dev-712-ge6be187
ssstars.c File Reference
#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"
Include dependency graph for ssstars.c:

Go to the source code of this file.

Classes

struct  VERTEX
 

Macros

#define WIN32_LEAN_AND_MEAN
 
#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
 

Functions

static HBITMAP CreateStarBitmap (HWND hWnd, HDC hDC)
 
static void InitGL (HBITMAP hStarTex)
 
static void render (void)
 
static LRESULT CALLBACK OnCreate (HWND hWnd, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK OnDestroy (HWND hWnd, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK OnPaint (HWND hWnd, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK OnSize (HWND hWnd, WPARAM wParam, LPARAM lParam)
 
LRESULT CALLBACK ScreenSaverProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

static VERTEX Vertex [MAX_STARS]
 
static HGLRC hRC
 
static HDC hDC
 
static float fAngle
 
static GLuint glStarTex
 
static GLfloat g_light_position [4]
 
static PIXELFORMATDESCRIPTOR pfd
 

Macro Definition Documentation

◆ FAR_PLANE

#define FAR_PLANE   -80.0f

Definition at line 36 of file ssstars.c.

◆ FIELD_DEPTH

#define FIELD_DEPTH   (NEAR_PLANE - FAR_PLANE + GAP)

Definition at line 41 of file ssstars.c.

◆ FIELD_HEIGHT

#define FIELD_HEIGHT   45.f

Definition at line 40 of file ssstars.c.

◆ FIELD_WIDTH

#define FIELD_WIDTH   50.f

Definition at line 39 of file ssstars.c.

◆ GAP

#define GAP   0.0f

Definition at line 38 of file ssstars.c.

◆ NEAR_PLANE

#define NEAR_PLANE   3.0f

Definition at line 37 of file ssstars.c.

◆ STAR_BLUE

#define STAR_BLUE   0.10f

Definition at line 45 of file ssstars.c.

◆ STAR_GREEN

#define STAR_GREEN   0.f

Definition at line 44 of file ssstars.c.

◆ STAR_RED

#define STAR_RED   0.f

Definition at line 43 of file ssstars.c.

◆ STAR_TAIL

#define STAR_TAIL   0.9f

Definition at line 46 of file ssstars.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 21 of file ssstars.c.

Function Documentation

◆ CreateStarBitmap()

static HBITMAP CreateStarBitmap ( HWND  hWnd,
HDC  hDC 
)
static

Definition at line 89 of file ssstars.c.

90 {
91  BITMAPINFO bi;
92  LPBYTE lpBits;
93  LPBYTE *lppBits;
94  HBITMAP hTextBmp, hFileBmp;
95  HDC hTextDC, hFileDC;
96  HGDIOBJ hOldText, hOldFile;
97  UINT i;
98  DWORD *Ptr32;
99  BITMAP bm;
101 
102  // Get instance for loading the texture
104 
105  // Load the texture
106  hFileBmp = (HBITMAP)
107  LoadImage(
108  hInstance,
110  IMAGE_BITMAP,
111  0, 0,
113  );
114 
115  // Get texture specs
116  GetObject(hFileBmp, sizeof(BITMAP), &bm);
117 
118  // Allocate new 32 bit texture
119  ZeroMemory(&bi, sizeof(bi));
120 
121  bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
122  bi.bmiHeader.biWidth = bm.bmWidth;
123  bi.bmiHeader.biHeight = -bm.bmHeight;
124  bi.bmiHeader.biPlanes = 1;
125  bi.bmiHeader.biBitCount = 32;
127 
128  // Makes GCC happy ;-|
129  lppBits = &lpBits;
130 
131  hTextBmp = CreateDIBSection(hDC,
132  (BITMAPINFO*)&bi,
134  (void**)lppBits,
135  NULL,
136  0);
137 
138  // Save new texture specs
139 // GetObject(hTextBmp, sizeof(BITMAP), &bmStarTex);
140 // bmStarTex.bmBits = lpBits;
141 
142  // Copy 24 bit texture in 32 texture
143  hTextDC = CreateCompatibleDC(hDC);
144  hFileDC = CreateCompatibleDC(hDC);
145 
146  hOldText = SelectObject(hTextDC, hTextBmp);
147  hOldFile = SelectObject(hFileDC, hFileBmp);
148 
149  BitBlt(hTextDC, 0, 0, bm.bmWidth, bm.bmHeight, hFileDC, 0, 0, SRCCOPY);
150 
151  SelectObject(hTextDC, hOldText);
152  SelectObject(hFileDC, hOldFile);
153 
154  DeleteDC(hTextDC);
155  DeleteDC(hFileDC);
156 
157  // Delete 24 bit texture
158  DeleteObject(hFileBmp);
159 
160  GetObject(hTextBmp, sizeof(BITMAP), &bm);
161 
162  // Apply ALPHA channel to new texture
163  for (Ptr32=(DWORD *)lpBits, i=0; i < (UINT)(bm.bmWidth * bm.bmHeight); i++)
164  {
165  DWORD Color = Ptr32[i] & 0x00FFFFFF;
166  DWORD Alpha = Color & 0xFF;
167 
168  Color |= Alpha << 24;
169 
170  Ptr32[i] = Color;
171  }
172 
173  return hTextBmp;
174 }
#define HDC
Definition: msvc.h:22
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define HBITMAP
Definition: msvc.h:28
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1454
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
static HDC hDC
Definition: ssstars.c:58
HWND hWnd
Definition: settings.c:17
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define ZeroMemory
Definition: winbase.h:1635
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
static VOID NTAPI BitBlt(IN ULONG Left, IN ULONG Top, IN ULONG Width, IN ULONG Height, IN PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:416
struct Color Color
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HINSTANCE hInstance
Definition: charmap.c:20
unsigned char * LPBYTE
Definition: typedefs.h:52
DWORD biCompression
Definition: amvideo.idl:35
#define IDB_STAR
Definition: resource.h:12
smooth NULL
Definition: ftsmooth.c:416
#define LR_DEFAULTSIZE
Definition: winuser.h:1084
unsigned int UINT
Definition: ndis.h:50
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GetObject
Definition: wingdi.h:4446
HANDLE HINSTANCE
Definition: typedefs.h:75
BOOL WINAPI DeleteDC(_In_ HDC)
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
Definition: bl.h:1331
#define LR_CREATEDIBSECTION
Definition: winuser.h:1088
#define IMAGE_BITMAP
Definition: winuser.h:211
#define GWLP_HINSTANCE
Definition: winuser.h:850
#define LoadImage
Definition: winuser.h:5681
#define GetWindowLongPtr
Definition: treelist.c:73
#define DIB_RGB_COLORS
Definition: wingdi.h:366
#define UINT
Definition: msvc.h:27
#define BI_RGB
Definition: precomp.h:35
#define SRCCOPY
Definition: wingdi.h:332

Referenced by OnCreate().

◆ InitGL()

static void InitGL ( HBITMAP  hStarTex)
static

Definition at line 176 of file ssstars.c.

177 {
178  BITMAP bm;
179  unsigned int i;
180  float xp, yp, zp;
181 
182  // set the GL clear color - use when the color buffer is cleared
184 
185  if (Settings.bSmoothShading)
186  // set the shading model to 'smooth'
188  else
189  // set the shading model to 'flat'
191 
192  // set GL to render front of polygons
194  // enable depth test
196 
197  // enable lighting
199  // enable lighting for front
201  // material have diffuse and ambient lighting
203  // enable color
205  // enable light 0
206  glEnable( GL_LIGHT0 );
207 
208  // set light attenuation
209  glLightf( GL_LIGHT0, GL_CONSTANT_ATTENUATION, 0.01f); //0.01f );
210  glLightf( GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.01f); //0.2f );
211  glLightf( GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.005f); //0.001f );
212 
213  // clear the color buffer once
215 
216  // randomly generate
217  srand( time( NULL ) );
218 
219  // Initialize *ALL* stars vertexes (not just programmed ones).
220  for (i = 0; i < MAX_STARS; i++)
221  {
222  xp = ( (float) rand() / RAND_MAX - .5f ) * FIELD_WIDTH;
223  yp = ( (float) rand() / RAND_MAX - .5f ) * FIELD_HEIGHT;
224  zp = ( (float) rand() / RAND_MAX ) * FIELD_DEPTH + FAR_PLANE;
225 
226  Vertex[i].x1 = -1.f + xp;
227  Vertex[i].y1 = -1.f + yp;
228  Vertex[i].x2 = 1.f + xp;
229  Vertex[i].y2 = 1.f + yp;
230  Vertex[i].z = zp;
231  }
232 
233  glGenTextures(1, &glStarTex); // Create One Texture
234 
235  // Create Linear Filtered Texture
237 
238  if (Settings.bEnableFiltering)
239  {
242  } else {
245  }
246 
247  // Get Texture properties
248  GetObject(hStarTex, sizeof(BITMAP), &bm);
249 
250  // Create texture as a mipmap
251 #if 0
252  glTexImage2D(GL_TEXTURE_2D, 0, 4, bm.bmWidth, bm.bmHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, bm.bmBits);
253 #else
254  gluBuild2DMipmaps(GL_TEXTURE_2D, 4, bm.bmWidth, bm.bmHeight, GL_RGBA, GL_UNSIGNED_BYTE, bm.bmBits);
255 #endif
256 
257  // Disable Texture Mapping (background smoothing)
259 
260  if (Settings.bFinePerspective)
261  // Really Fast Perspective Calculations
263  else
264  // Really Nice Perspective Calculations
266 
267  // enable blending
268  glEnable( GL_BLEND );
269 }
#define GL_CONSTANT_ATTENUATION
Definition: gl.h:321
#define GL_FASTEST
Definition: gl.h:584
#define GL_COLOR_BUFFER_BIT
Definition: gl.h:716
GLAPI void GLAPIENTRY glClear(GLbitfield mask)
static VERTEX Vertex[MAX_STARS]
Definition: ssstars.c:56
#define gluBuild2DMipmaps
Definition: glu_mangle.h:35
#define GL_FLAT
Definition: gl.h:338
#define GL_BLEND
Definition: gl.h:371
float x2
Definition: ssstars.c:51
GLAPI void GLAPIENTRY glBindTexture(GLenum target, GLuint texture)
GLAPI void GLAPIENTRY glPolygonMode(GLenum face, GLenum mode)
#define GL_NEAREST
Definition: gl.h:678
#define GL_UNSIGNED_BYTE
Definition: gl.h:178
GLAPI void GLAPIENTRY glColorMaterial(GLenum face, GLenum mode)
void __cdecl srand(_In_ unsigned int _Seed)
static GLuint glStarTex
Definition: ssstars.c:60
#define GL_PERSPECTIVE_CORRECTION_HINT
Definition: gl.h:578
__u16 time
Definition: mkdosfs.c:366
GLAPI void GLAPIENTRY glGenTextures(GLsizei n, GLuint *textures)
#define GL_SMOOTH
Definition: gl.h:339
GLAPI void GLAPIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
GLAPI void GLAPIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
#define GL_FRONT_AND_BACK
Definition: gl.h:336
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define GL_LIGHT0
Definition: gl.h:311
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
#define GL_FRONT
Definition: gl.h:270
smooth NULL
Definition: ftsmooth.c:416
#define STAR_TAIL
Definition: ssstars.c:46
GLAPI void GLAPIENTRY glShadeModel(GLenum mode)
#define GL_TEXTURE_MIN_FILTER
Definition: gl.h:649
GLAPI void GLAPIENTRY glDisable(GLenum cap)
GLfloat f
Definition: glext.h:7540
#define STAR_GREEN
Definition: ssstars.c:44
#define GL_AMBIENT_AND_DIFFUSE
Definition: gl.h:331
GLAPI void GLAPIENTRY glLightf(GLenum light, GLenum pname, GLfloat param)
#define GL_COLOR_MATERIAL
Definition: gl.h:340
#define GL_LIGHTING
Definition: gl.h:310
#define GL_LINEAR
Definition: gl.h:421
#define GetObject
Definition: wingdi.h:4446
SETTINGS Settings
Definition: charmap.c:26
GLAPI void GLAPIENTRY glHint(GLenum target, GLenum mode)
float z
Definition: vmr9.c:2546
#define STAR_RED
Definition: ssstars.c:43
#define GL_NICEST
Definition: gl.h:585
GLAPI void GLAPIENTRY glEnable(GLenum cap)
#define MAX_STARS
Definition: settings.h:30
#define FAR_PLANE
Definition: ssstars.c:36
#define RAND_MAX
Definition: stdlib.h:99
float y1
Definition: ssstars.c:50
float y2
Definition: ssstars.c:52
GLAPI void GLAPIENTRY glLightModeli(GLenum pname, GLint param)
#define GL_FILL
Definition: gl.h:267
#define GL_QUADRATIC_ATTENUATION
Definition: gl.h:323
#define GL_DEPTH_TEST
Definition: gl.h:301
#define GL_TEXTURE_MAG_FILTER
Definition: gl.h:648
#define FIELD_HEIGHT
Definition: ssstars.c:40
Definition: bl.h:1331
#define GL_TRUE
Definition: gl.h:174
#define GL_TEXTURE_2D
Definition: gl.h:645
GLAPI void GLAPIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
#define FIELD_DEPTH
Definition: ssstars.c:41
#define STAR_BLUE
Definition: ssstars.c:45
#define GL_LINEAR_ATTENUATION
Definition: gl.h:322
#define GL_RGBA
Definition: gl.h:503
float x1
Definition: ssstars.c:49
#define FIELD_WIDTH
Definition: ssstars.c:39

Referenced by OnCreate().

◆ OnCreate()

static LRESULT CALLBACK OnCreate ( HWND  hWnd,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 335 of file ssstars.c.

336 {
338  HBITMAP hStarTex;
339 
340  LoadSettings();
341 
342  // Gets A Device Context For The Window
343  hDC = GetDC(hWnd);
344 
345  // Finds The Closest Match To The Pixel Format We Set Above
347 
348  // No Matching Pixel Format?
349  if (!PixelFormat)
350  {
351  MessageBox(0, _T("Can't Find A Suitable PixelFormat."), _T("Error"),MB_OK | MB_ICONERROR);
352 
353  // This Sends A 'Message' Telling The Program To Quit
354  PostQuitMessage(0);
355  return 0;
356  }
357 
358  // Can We Set The Pixel Mode?
360  {
361  MessageBox(0, _TEXT("Can't Set The PixelFormat."), _T("Error"), MB_OK | MB_ICONERROR);
362 
363  // This Sends A 'Message' Telling The Program To Quit
364  PostQuitMessage(0);
365  return 0;
366  }
367 
368  // Grab A Rendering Context
370 
371  // Did We Get One?
372  if (!hRC)
373  {
374  MessageBox(0, _T("Can't Create A GL Rendering Context."), _T("Error"), MB_OK | MB_ICONERROR);
375 
376  // This Sends A 'Message' Telling The Program To Quit
377  PostQuitMessage(0);
378  return 0;
379  }
380 
381  // Can We Make The RC Active?
382  if (!wglMakeCurrent(hDC, hRC))
383  {
384  MessageBox(0, _T("Can't Activate GLRC."), _TEXT("Error"), MB_OK | MB_ICONERROR);
385 
386  // This Sends A 'Message' Telling The Program To Quit
387  PostQuitMessage(0);
388  return 0;
389  }
390 
391  // Load star texture
392  hStarTex = CreateStarBitmap(hWnd, hDC);
393 
394  // Initialize The GL Screen Using Screen Info
395  InitGL(hStarTex);
396 
397  // Delete GDI object for texture
398  DeleteObject(hStarTex);
399 
400  // Update screen every 10ms
401  SetTimer(hWnd, 1, 10, NULL);
402 
403  // Initialize spinning angle
404  fAngle = 0.f;
405 
406  return 0L;
407 }
#define HBITMAP
Definition: msvc.h:28
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC hDC
Definition: ssstars.c:58
HWND hWnd
Definition: settings.c:17
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI SetPixelFormat(_In_ HDC, _In_ int, _In_ const PIXELFORMATDESCRIPTOR *)
static float fAngle
Definition: ssstars.c:59
void LoadSettings(void)
Definition: settings.c:53
smooth NULL
Definition: ftsmooth.c:416
static HGLRC hRC
Definition: ssstars.c:57
#define _TEXT(x)
Definition: tchar.h:1543
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define _T(x)
Definition: vfdio.h:22
int WINAPI ChoosePixelFormat(_In_ HDC hdc, _In_ const PIXELFORMATDESCRIPTOR *ppfd)
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
INT PixelFormat
static const WCHAR L[]
Definition: oid.c:1250
#define MB_ICONERROR
Definition: winuser.h:781
#define MessageBox
Definition: winuser.h:5688
BOOL WINAPI wglMakeCurrent(HDC hdc, HGLRC hglrc)
Definition: wgl.c:650
unsigned int GLuint
Definition: gl.h:159
#define MB_OK
Definition: winuser.h:784
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
static HBITMAP CreateStarBitmap(HWND hWnd, HDC hDC)
Definition: ssstars.c:89
HGLRC WINAPI wglCreateContext(HDC hdc)
Definition: wgl.c:383
static void InitGL(HBITMAP hStarTex)
Definition: ssstars.c:176

Referenced by ScreenSaverProc().

◆ OnDestroy()

static LRESULT CALLBACK OnDestroy ( HWND  hWnd,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 410 of file ssstars.c.

411 {
412  // Delete update timer
413  KillTimer(hWnd, 1);
414 
415  // Disable Fullscreen Mode
416  ChangeDisplaySettings(NULL, 0);
417 
418  // Make The DC Current
420 
421  // Kill The RC
423 
424  // Free The DC
425  ReleaseDC(hWnd, hDC);
426 
427 #ifdef _DEBUG_SSTARS
428  PostQuitMessage(0);
429 #endif
430 
431  return 0L;
432 }
BOOL WINAPI wglDeleteContext(HGLRC hglrc)
Definition: wgl.c:514
static HDC hDC
Definition: ssstars.c:58
HWND hWnd
Definition: settings.c:17
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
static HGLRC hRC
Definition: ssstars.c:57
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
static const WCHAR L[]
Definition: oid.c:1250
BOOL WINAPI wglMakeCurrent(HDC hdc, HGLRC hglrc)
Definition: wgl.c:650
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)

Referenced by ScreenSaverProc().

◆ OnPaint()

static LRESULT CALLBACK OnPaint ( HWND  hWnd,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 435 of file ssstars.c.

436 {
437  if (Settings.bDoBlending)
438  {
440 
441  // disable lighting
443 
444  // blend in a polygon
446 
447  // Restore both model view and projection to identity
449  glPushMatrix();
450  glLoadIdentity();
451 
453  glPushMatrix();
454  glLoadIdentity();
455 
456  // Blur the background
457  glBegin( GL_QUADS );
458  glVertex3f( -1.0f, -1.0f, -1.0f );
459  glVertex3f( -1.0f, 1.0f, -1.0f );
460  glVertex3f( 1.0f, 1.0f, -1.0f );
461  glVertex3f( 1.0f, -1.0f, -1.0f );
462  glEnd();
463 
464  // Recover previous matrix
465  glPopMatrix();
467  glPopMatrix();
468 
469  // enable lighting
471  } else {
473  }
474 
475  // save the current matrix state, so transformation will
476  // not persist across displayFunc calls, since we
477  // will do a glPopMatrix() at the end of this function
478  glPushMatrix();
479 
480  // render the scene
481  render();
482 
483  // restore the matrix state
484  glPopMatrix();
485 
486  // flush the buffer
487  glFlush();
488 
489  // swap the double buffer
490  SwapBuffers(hDC);
491 
492  // Clear redraw event
494 
495  return 0L;
496 }
#define GL_COLOR_BUFFER_BIT
Definition: gl.h:716
GLAPI void GLAPIENTRY glClear(GLbitfield mask)
#define GL_QUADS
Definition: gl.h:197
GLAPI void GLAPIENTRY glMatrixMode(GLenum mode)
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
static HDC hDC
Definition: ssstars.c:58
HWND hWnd
Definition: settings.c:17
GLAPI void GLAPIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
smooth NULL
Definition: ftsmooth.c:416
#define STAR_TAIL
Definition: ssstars.c:46
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
BOOL WINAPI SwapBuffers(HDC)
Definition: wingl.c:187
GLAPI void GLAPIENTRY glDisable(GLenum cap)
GLfloat f
Definition: glext.h:7540
#define STAR_GREEN
Definition: ssstars.c:44
static void render(void)
Definition: ssstars.c:272
BOOL WINAPI ValidateRect(_In_opt_ HWND, _In_opt_ LPCRECT)
#define GL_LIGHTING
Definition: gl.h:310
SETTINGS Settings
Definition: charmap.c:26
#define STAR_RED
Definition: ssstars.c:43
GLAPI void GLAPIENTRY glBegin(GLenum mode)
static const WCHAR L[]
Definition: oid.c:1250
#define GL_PROJECTION
Definition: gl.h:246
GLAPI void GLAPIENTRY glEnable(GLenum cap)
GLAPI void GLAPIENTRY glPushMatrix(void)
GLAPI void GLAPIENTRY glFlush(void)
GLAPI void GLAPIENTRY glPopMatrix(void)
GLAPI void GLAPIENTRY glLoadIdentity(void)
#define GL_MODELVIEW
Definition: gl.h:245
#define GL_ONE_MINUS_SRC_ALPHA
Definition: gl.h:379
#define STAR_BLUE
Definition: ssstars.c:45
GLAPI void GLAPIENTRY glEnd(void)
#define GL_SRC_ALPHA
Definition: gl.h:378

Referenced by ScreenSaverProc().

◆ OnSize()

static LRESULT CALLBACK OnSize ( HWND  hWnd,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 499 of file ssstars.c.

500 {
501  GLsizei w = LOWORD(lParam);
502  GLsizei h = HIWORD(lParam);
503 
504  // map the view port to the entire client area
505  glViewport(0, 0, w, h);
506 
507  // set the matrix mode to projection matrix
509 
510  // load the identity matrix
511  glLoadIdentity();
512 
513  // set the perspective matrix
514  gluPerspective( 64.0, (GLdouble) w / (GLdouble)h, .1, 300.0 );
515 
516  // set the matrix mode to the modelview matrix
518 
519  // load the identity matrix into the modelview matrix
520  glLoadIdentity();
521 
522  // set the 'camera'
523  gluLookAt( 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 2.0, 3.0 );
524 
525  // set the position of the light
527 
528  return 0L;
529 }
double GLdouble
Definition: gl.h:163
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLAPI void GLAPIENTRY glMatrixMode(GLenum mode)
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define gluPerspective
Definition: glu_mangle.h:28
#define GL_LIGHT0
Definition: gl.h:311
int GLsizei
Definition: gl.h:160
static const WCHAR L[]
Definition: oid.c:1250
#define GL_PROJECTION
Definition: gl.h:246
GLAPI void GLAPIENTRY glLightfv(GLenum light, GLenum pname, const GLfloat *params)
GLAPI void GLAPIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
GLAPI void GLAPIENTRY glLoadIdentity(void)
#define GL_MODELVIEW
Definition: gl.h:245
static GLfloat g_light_position[4]
Definition: ssstars.c:63
#define HIWORD(l)
Definition: typedefs.h:246
#define GL_POSITION
Definition: gl.h:329
#define gluLookAt
Definition: glu_mangle.h:26
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by ScreenSaverProc().

◆ render()

static void render ( void  )
static

Definition at line 272 of file ssstars.c.

273 {
274  unsigned int i;
275  float fSpin;
276  float fSpeed;
277  float xp, yp;
278 
279  // Initialize current speed
280  fSpeed = (float)Settings.uiSpeed / 100.f;
281 
282  glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
283 
284  glBlendFunc(GL_SRC_ALPHA,GL_ONE); // Set The Blending Function For Translucency
285 
286  switch (Settings.uiRotation) {
287  case ROTATION_LINEAR:
288  fAngle += fSpeed;
289  glRotatef( fAngle, 0.0f, 0.0f, 1.0f );
290  break;
291 
292  case ROTATION_PERIODIC:
293  fAngle += fSpeed / 75.f;
294  fSpin = (float)(50. * cos(fAngle));
295  glRotatef( fSpin, 0.0f, 0.0f, 1.0f );
296  break;
297  }
298 
299  glColor3ub(255, 255, 255);
300 
301  glBegin(GL_QUADS); // Begin Drawing The Textured Quad
302 
303  // Draw the stars
304  for (i = 0; i < Settings.uiNumStars; i++)
305  {
306  glTexCoord2f(0.0f, 0.0f); glVertex3f(Vertex[i].x1, Vertex[i].y1, Vertex[i].z);
307  glTexCoord2f(1.0f, 0.0f); glVertex3f(Vertex[i].x2, Vertex[i].y1, Vertex[i].z);
308  glTexCoord2f(1.0f, 1.0f); glVertex3f(Vertex[i].x2, Vertex[i].y2, Vertex[i].z);
309  glTexCoord2f(0.0f, 1.0f); glVertex3f(Vertex[i].x1, Vertex[i].y2, Vertex[i].z);
310 
311  // increment z
312  Vertex[i].z += fSpeed;
313 
314  // check to see if passed view
315  if( Vertex[i].z > NEAR_PLANE + GAP ||
316  Vertex[i].z < FAR_PLANE )
317  {
318  xp = ( (float) rand() / RAND_MAX - .5f ) * FIELD_WIDTH;
319  yp = ( (float) rand() / RAND_MAX - .5f ) * FIELD_HEIGHT;
320 
321  Vertex[i].x1 = -1.f + xp;
322  Vertex[i].y1 = -1.f + yp;
323  Vertex[i].x2 = 1.f + xp;
324  Vertex[i].y2 = 1.f + yp;
325  Vertex[i].z = FAR_PLANE;
326  }
327  }
328 
329  glEnd(); // Done Drawing The Textured Quad
330 
331  glDisable(GL_TEXTURE_2D); // Enable Texture Mapping
332 }
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG y1
Definition: winddi.h:3706
static VERTEX Vertex[MAX_STARS]
Definition: ssstars.c:56
#define GL_ONE
Definition: gl.h:375
#define GL_QUADS
Definition: gl.h:197
float x2
Definition: ssstars.c:51
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
GLAPI void GLAPIENTRY glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
#define NEAR_PLANE
Definition: ssstars.c:37
static float fAngle
Definition: ssstars.c:59
#define ROTATION_LINEAR
Definition: settings.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
GLdouble GLdouble z
Definition: glext.h:5874
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
GLAPI void GLAPIENTRY glDisable(GLenum cap)
GLfloat f
Definition: glext.h:7540
GLAPI void GLAPIENTRY glColor3ub(GLubyte red, GLubyte green, GLubyte blue)
SETTINGS Settings
Definition: charmap.c:26
float z
Definition: vmr9.c:2546
GLAPI void GLAPIENTRY glBegin(GLenum mode)
GLAPI void GLAPIENTRY glEnable(GLenum cap)
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG _In_ LONG y2
Definition: winddi.h:3706
#define FAR_PLANE
Definition: ssstars.c:36
#define RAND_MAX
Definition: stdlib.h:99
float y1
Definition: ssstars.c:50
float y2
Definition: ssstars.c:52
#define FIELD_HEIGHT
Definition: ssstars.c:40
#define GAP
Definition: ssstars.c:38
GLAPI void GLAPIENTRY glTexCoord2f(GLfloat s, GLfloat t)
#define GL_TEXTURE_2D
Definition: gl.h:645
#define ROTATION_PERIODIC
Definition: settings.h:26
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3706
GLAPI void GLAPIENTRY glEnd(void)
#define GL_SRC_ALPHA
Definition: gl.h:378
float x1
Definition: ssstars.c:49
#define FIELD_WIDTH
Definition: ssstars.c:39

Referenced by check_messages_(), D3DXCreateRenderToEnvMap(), D3DXCreateRenderToSurface(), D3DXRenderToEnvMap_AddRef(), D3DXRenderToEnvMap_BeginCube(), D3DXRenderToEnvMap_End(), D3DXRenderToEnvMap_Face(), D3DXRenderToEnvMap_GetDesc(), D3DXRenderToEnvMap_GetDevice(), D3DXRenderToEnvMap_Release(), D3DXRenderToSurface_AddRef(), D3DXRenderToSurface_BeginScene(), D3DXRenderToSurface_EndScene(), D3DXRenderToSurface_GetDesc(), D3DXRenderToSurface_GetDevice(), D3DXRenderToSurface_Release(), ft_add_renderer(), FT_Get_Glyph(), ft_raster1_get_cbox(), ft_raster1_init(), ft_raster1_render(), ft_raster1_set_mode(), ft_raster1_transform(), ft_remove_renderer(), ft_smooth_get_cbox(), ft_smooth_init(), ft_smooth_render(), ft_smooth_render_generic(), ft_smooth_render_lcd(), ft_smooth_render_lcd_v(), ft_smooth_set_mode(), ft_smooth_transform(), OleCreateFromClip(), OleCreateLinkFromClip(), OleQueryCreateFromClip(), OleQueryLinkFromClip(), OnPaint(), and VMR9_ImagePresenter_PresentImage().

◆ ScreenSaverProc()

LRESULT CALLBACK ScreenSaverProc ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 532 of file ssstars.c.

533 {
534  switch (uMsg) {
535  case WM_CREATE:
536  return OnCreate(hWnd, wParam, lParam);
537 
538  case WM_TIMER:
540  return 0L;
541 
542  case WM_DESTROY:
543  return OnDestroy(hWnd, wParam, lParam);
544 
545  case WM_PAINT:
546  return OnPaint(hWnd, wParam, lParam);
547 
548  case WM_SIZE: // Resizing The Screen
549  return OnSize(hWnd, wParam, lParam);
550  }
551 
552 #ifdef _DEBUG_SSTARS
553  return DefWindowProc(hWnd, uMsg, wParam, lParam);
554 #else
555  return DefScreenSaverProc(hWnd, uMsg, wParam, lParam);
556 #endif
557 }
HWND hWnd
Definition: settings.c:17
static LRESULT CALLBACK OnPaint(HWND hWnd, WPARAM wParam, LPARAM lParam)
Definition: ssstars.c:435
static LRESULT CALLBACK OnSize(HWND hWnd, WPARAM wParam, LPARAM lParam)
Definition: ssstars.c:499
WPARAM wParam
Definition: combotst.c:138
smooth NULL
Definition: ftsmooth.c:416
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define WM_SIZE
Definition: winuser.h:1593
#define WM_TIMER
Definition: winuser.h:1718
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define WM_PAINT
Definition: winuser.h:1602
static const WCHAR L[]
Definition: oid.c:1250
static LRESULT CALLBACK OnCreate(HWND hWnd, WPARAM wParam, LPARAM lParam)
Definition: ssstars.c:335
static LRESULT CALLBACK OnDestroy(HWND hWnd, WPARAM wParam, LPARAM lParam)
Definition: ssstars.c:410
#define WM_CREATE
Definition: winuser.h:1590
LRESULT WINAPI DefScreenSaverProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: scrnsave.c:95
LPARAM lParam
Definition: combotst.c:139

Variable Documentation

◆ fAngle

float fAngle
static

Definition at line 59 of file ssstars.c.

Referenced by OnCreate(), and render().

◆ g_light_position

GLfloat g_light_position[4]
static
Initial value:
= {
0.0f, 0.0f, 3.0f, 1.0f
}

Definition at line 63 of file ssstars.c.

Referenced by OnSize().

◆ glStarTex

GLuint glStarTex
static

Definition at line 60 of file ssstars.c.

Referenced by InitGL().

◆ hDC

HDC hDC
static

Definition at line 58 of file ssstars.c.

Referenced by CreateStarBitmap(), OnCreate(), OnDestroy(), and OnPaint().

◆ hRC

HGLRC hRC
static

Definition at line 57 of file ssstars.c.

Referenced by OnCreate(), and OnDestroy().

◆ pfd

Initial value:
=
{
1,
16,
0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0,
16,
0,
0,
0,
0, 0, 0
}
#define PFD_MAIN_PLANE
Definition: wingdi.h:297
#define PFD_DOUBLEBUFFER
Definition: wingdi.h:300
#define PFD_TYPE_RGBA
Definition: wingdi.h:295
struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR
#define PFD_SUPPORT_OPENGL
Definition: wingdi.h:305
#define PFD_DRAW_TO_WINDOW
Definition: wingdi.h:302

Definition at line 67 of file ssstars.c.

Referenced by context_choose_pixel_format(), dump_TLBFuncDesc(), dump_TLBFuncDescOne(), FileSystemBindData_GetFindData(), FileSystemBindData_SetFindData(), fsbd_GetFindData_invalid(), fsbd_GetFindData_junk(), fsbd_GetFindData_nul(), fsbd_GetFindData_valid(), get_hwnd_from_ifiledialog(), CFileSysBindData::GetFindData(), CShellLink::GetPath(), IFileDialogEvents_fnOnFolderChange(), IFileSystemBindData_Constructor(), InitOGLWindow(), MyPixelFormat(), netconn_create(), OnCreate(), rpc_broadcast_exp(), RunBatch(), ScreenSaverProc(), CFileSysBindData::SetFindData(), SHGetDataFromIDListA(), SHGetDataFromIDListW(), START_TEST(), test_acceleration(), test_advise(), test_advise_helper(), test_bitmap_colors(), test_bitmap_rendering(), test_choosepixelformat(), test_customize_dlgproc(), test_customize_onfolderchange(), test_events(), test_format(), test_instantiation(), test_pack_EMRPIXELFORMAT(), test_pfd(), test_screen_colors(), test_setpixelformat(), wined3d_adapter_init_fb_cfgs(), and wined3d_caps_gl_ctx_create().

◆ Vertex

VERTEX Vertex[MAX_STARS]
static

Definition at line 56 of file ssstars.c.

Referenced by DECLARE_INTERFACE_(), InitGL(), and render().