ReactOS 0.4.16-dev-297-gc569aee
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,
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}
HWND hWnd
Definition: settings.c:17
HINSTANCE hInstance
Definition: charmap.c:19
#define NULL
Definition: types.h:112
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
#define BI_RGB
Definition: precomp.h:56
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
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 IDB_STAR
Definition: resource.h:12
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
unsigned int UINT
Definition: ndis.h:50
static HDC hDC
Definition: ssstars.c:58
Definition: bl.h:1331
USHORT biBitCount
Definition: precomp.h:46
ULONG biCompression
Definition: precomp.h:47
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
#define GetWindowLongPtr
Definition: treelist.c:73
HANDLE HINSTANCE
Definition: typedefs.h:77
unsigned char * LPBYTE
Definition: typedefs.h:53
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
#define ZeroMemory
Definition: winbase.h:1737
#define DIB_RGB_COLORS
Definition: wingdi.h:367
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define SRCCOPY
Definition: wingdi.h:333
#define GetObject
Definition: wingdi.h:4468
BOOL WINAPI DeleteDC(_In_ HDC)
#define IMAGE_BITMAP
Definition: winuser.h:211
#define LR_CREATEDIBSECTION
Definition: winuser.h:1101
#define GWLP_HINSTANCE
Definition: winuser.h:859
#define LoadImage
Definition: winuser.h:5827
#define LR_DEFAULTSIZE
Definition: winuser.h:1097
#define MAKEINTRESOURCE
Definition: winuser.h:591

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
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
269}
#define GL_TRUE
Definition: gl.h:174
#define GL_FASTEST
Definition: gl.h:584
#define GL_NICEST
Definition: gl.h:585
#define GL_TEXTURE_MIN_FILTER
Definition: gl.h:649
GLAPI void GLAPIENTRY glEnable(GLenum cap)
#define GL_AMBIENT_AND_DIFFUSE
Definition: gl.h:331
#define GL_FRONT_AND_BACK
Definition: gl.h:336
GLAPI void GLAPIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
GLAPI void GLAPIENTRY glColorMaterial(GLenum face, GLenum mode)
GLAPI void GLAPIENTRY glHint(GLenum target, GLenum mode)
#define GL_QUADRATIC_ATTENUATION
Definition: gl.h:323
#define GL_DEPTH_TEST
Definition: gl.h:301
#define GL_LINEAR
Definition: gl.h:421
#define GL_SMOOTH
Definition: gl.h:339
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 glBindTexture(GLenum target, GLuint texture)
#define GL_COLOR_BUFFER_BIT
Definition: gl.h:716
#define GL_FILL
Definition: gl.h:267
GLAPI void GLAPIENTRY glGenTextures(GLsizei n, GLuint *textures)
GLAPI void GLAPIENTRY glLightf(GLenum light, GLenum pname, GLfloat param)
#define GL_COLOR_MATERIAL
Definition: gl.h:340
#define GL_RGBA
Definition: gl.h:503
#define GL_LINEAR_ATTENUATION
Definition: gl.h:322
#define GL_BLEND
Definition: gl.h:371
GLAPI void GLAPIENTRY glLightModeli(GLenum pname, GLint param)
GLAPI void GLAPIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
#define GL_TEXTURE_MAG_FILTER
Definition: gl.h:648
GLAPI void GLAPIENTRY glDisable(GLenum cap)
#define GL_TEXTURE_2D
Definition: gl.h:645
#define GL_FRONT
Definition: gl.h:270
#define GL_FLAT
Definition: gl.h:338
#define GL_CONSTANT_ATTENUATION
Definition: gl.h:321
#define GL_PERSPECTIVE_CORRECTION_HINT
Definition: gl.h:578
GLAPI void GLAPIENTRY glShadeModel(GLenum mode)
GLAPI void GLAPIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
#define GL_LIGHT0
Definition: gl.h:311
#define GL_LIGHTING
Definition: gl.h:310
GLAPI void GLAPIENTRY glClear(GLbitfield mask)
#define gluBuild2DMipmaps
Definition: glu_mangle.h:35
void __cdecl srand(_In_ unsigned int _Seed)
#define RAND_MAX
Definition: stdlib.h:87
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
__u16 time
Definition: mkdosfs.c:8
#define MAX_STARS
Definition: settings.h:30
static float(__cdecl *square_half_float)(float x
#define FIELD_WIDTH
Definition: ssstars.c:39
#define STAR_GREEN
Definition: ssstars.c:44
#define STAR_BLUE
Definition: ssstars.c:45
#define STAR_RED
Definition: ssstars.c:43
#define FIELD_HEIGHT
Definition: ssstars.c:40
#define FIELD_DEPTH
Definition: ssstars.c:41
static VERTEX Vertex[MAX_STARS]
Definition: ssstars.c:56
static GLuint glStarTex
Definition: ssstars.c:60
#define FAR_PLANE
Definition: ssstars.c:36
#define STAR_TAIL
Definition: ssstars.c:46
float y2
Definition: ssstars.c:52
float x1
Definition: ssstars.c:49
float y1
Definition: ssstars.c:50
float x2
Definition: ssstars.c:51
float z
Definition: vmr9.c:2546
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_POWER_POLICY_IDLE_SETTINGS Settings
Definition: wdfdevice.h:2595

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
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
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
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
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}
void LoadSettings(void)
Definition: settings.c:53
INT PixelFormat
unsigned int GLuint
Definition: gl.h:159
#define _TEXT(x)
Definition: tchar.h:1535
#define L(x)
Definition: ntvdm.h:50
static float fAngle
Definition: ssstars.c:59
static HBITMAP CreateStarBitmap(HWND hWnd, HDC hDC)
Definition: ssstars.c:89
static HGLRC hRC
Definition: ssstars.c:57
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
static void InitGL(HBITMAP hStarTex)
Definition: ssstars.c:176
#define _T(x)
Definition: vfdio.h:22
HGLRC WINAPI wglCreateContext(HDC hdc)
Definition: wgl.c:383
BOOL WINAPI wglMakeCurrent(HDC hdc, HGLRC hglrc)
Definition: wgl.c:650
int WINAPI ChoosePixelFormat(_In_ HDC hdc, _In_ const PIXELFORMATDESCRIPTOR *ppfd)
BOOL WINAPI SetPixelFormat(_In_ HDC, _In_ int, _In_ const PIXELFORMATDESCRIPTOR *)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define MB_ICONERROR
Definition: winuser.h:790
HDC WINAPI GetDC(_In_opt_ HWND)
#define MB_OK
Definition: winuser.h:793
#define MessageBox
Definition: winuser.h:5834

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
426
427#ifdef _DEBUG_SSTARS
429#endif
430
431 return 0L;
432}
BOOL WINAPI wglDeleteContext(HGLRC hglrc)
Definition: wgl.c:514
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)

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();
451
453 glPushMatrix();
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
491
492 // Clear redraw event
494
495 return 0L;
496}
#define GL_QUADS
Definition: gl.h:197
#define GL_SRC_ALPHA
Definition: gl.h:378
GLAPI void GLAPIENTRY glPushMatrix(void)
GLAPI void GLAPIENTRY glLoadIdentity(void)
#define GL_PROJECTION
Definition: gl.h:246
#define GL_MODELVIEW
Definition: gl.h:245
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
GLAPI void GLAPIENTRY glBegin(GLenum mode)
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
GLAPI void GLAPIENTRY glPopMatrix(void)
#define GL_ONE_MINUS_SRC_ALPHA
Definition: gl.h:379
GLAPI void GLAPIENTRY glEnd(void)
GLAPI void GLAPIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
GLAPI void GLAPIENTRY glMatrixMode(GLenum mode)
GLAPI void GLAPIENTRY glFlush(void)
static void render(void)
Definition: ssstars.c:272
BOOL WINAPI SwapBuffers(HDC)
Definition: wingl.c:187
BOOL WINAPI ValidateRect(_In_opt_ HWND, _In_opt_ LPCRECT)

Referenced by ScreenSaverProc().

◆ OnSize()

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

Definition at line 499 of file ssstars.c.

500{
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
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
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}
LPARAM lParam
Definition: combotst.c:139
#define GL_POSITION
Definition: gl.h:329
double GLdouble
Definition: gl.h:163
GLAPI void GLAPIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
int GLsizei
Definition: gl.h:160
GLAPI void GLAPIENTRY glLightfv(GLenum light, GLenum pname, const GLfloat *params)
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define gluPerspective
Definition: glu_mangle.h:28
#define gluLookAt
Definition: glu_mangle.h:26
#define LOWORD(l)
Definition: pedump.c:82
static GLfloat g_light_position[4]
Definition: ssstars.c:63
#define HIWORD(l)
Definition: typedefs.h:247

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
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}
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)
GLAPI void GLAPIENTRY glTexCoord2f(GLfloat s, GLfloat t)
#define GL_ONE
Definition: gl.h:375
GLAPI void GLAPIENTRY glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
GLAPI void GLAPIENTRY glColor3ub(GLubyte red, GLubyte green, GLubyte blue)
GLdouble GLdouble z
Definition: glext.h:5874
#define ROTATION_LINEAR
Definition: settings.h:25
#define ROTATION_PERIODIC
Definition: settings.h:26
#define GAP
Definition: ssstars.c:38
#define NEAR_PLANE
Definition: ssstars.c:37
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3710
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG y1
Definition: winddi.h:3709
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3708
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG _In_ LONG y2
Definition: winddi.h:3711

Referenced by check_ID3DXRenderToSurface(), 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(), Subdivider::monosplitInT(), OleCreateFromClip(), OleCreateLinkFromClip(), OleQueryCreateFromClip(), OleQueryLinkFromClip(), OnPaint(), test_D3DXCreateRenderToEnvMap(), test_D3DXCreateRenderToSurface(), test_ID3DXRenderToEnvMap(), test_ID3DXRenderToEnvMap_cube_map(), test_ID3DXRenderToSurface(), test_ID3DXRenderToSurface_device_state(), 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}
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
#define DefWindowProc
Definition: ros2win.h:31
LRESULT WINAPI DefScreenSaverProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: scrnsave.c:92
static LRESULT CALLBACK OnSize(HWND hWnd, WPARAM wParam, LPARAM lParam)
Definition: ssstars.c:499
static LRESULT CALLBACK OnDestroy(HWND hWnd, WPARAM wParam, LPARAM lParam)
Definition: ssstars.c:410
static LRESULT CALLBACK OnPaint(HWND hWnd, WPARAM wParam, LPARAM lParam)
Definition: ssstars.c:435
static LRESULT CALLBACK OnCreate(HWND hWnd, WPARAM wParam, LPARAM lParam)
Definition: ssstars.c:335
#define WM_PAINT
Definition: winuser.h:1623
#define WM_CREATE
Definition: winuser.h:1611
#define WM_SIZE
Definition: winuser.h:1614
#define WM_TIMER
Definition: winuser.h:1745
#define WM_DESTROY
Definition: winuser.h:1612
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

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_SUPPORT_OPENGL
Definition: wingdi.h:306
struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR
#define PFD_DRAW_TO_WINDOW
Definition: wingdi.h:303
#define PFD_MAIN_PLANE
Definition: wingdi.h:298
#define PFD_TYPE_RGBA
Definition: wingdi.h:296
#define PFD_DOUBLEBUFFER
Definition: wingdi.h:301

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(), 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().