#include <windows.h>
#include <gl\\gl.h>
#include <gl\\glu.h>
#include <gl\\glaux.h>
#include <stdio.h>
#include <math.h>
HDC hDC=NULL;
HGLRC hRC=NULL;
HWND hWnd=NULL;
HINSTANCE hInstance;
bool keys[256];
bool active=TRUE;
bool fullscreen=TRUE;
GLint base,loop;
GLuint texture[14];
GLUquadricObj *Obiekt1;
GLfloat roll,roll2;
GLfloat step=0.01f;
GLfloat step2=0.3f;
GLfloat rotate, rotateobiekt1,rotateobiekt2;
GLfloat angle,rotsat;
GLfloat RotateWenus;
GLfloat x,y;
GLfloat LightAmbient[]= { 0.05f, 0.05f, 0.05f, 1.0f };
GLfloat LightDiffuse[]= { 0.8f, 0.8f, 0.8f, 1.0f };
GLfloat LightPosition[]= { 10.0f, -10.0f, 10.0f, 1.0f };
GLfloat LightAmbient2[]= { 0.9f, 0.9f, 0.9f, 1.0f };
GLfloat roo;
GLfloat ro;
GLfloat ro2;
GLfloat alpha;
GLfloat alphaplus=0.0003f;
char *text_display[7] =
{
" Ekran koruyucu
tansalic@walla.com",
" Hepiniz hos geldiniz...",
" Bu proje benim ilk ekran koruyucu calismamdir",
" umarim begenir dostlarinizada hediye edersiniz",
" SAYGILARIMLA !!!",
"
tansalic@walla.com",
""
};
int Tekst = 0;
int TextSync = 0;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
void Build_font(void)
{
int i;
float cx;
float cy;
base = glGenLists(256);
glBindTexture(GL_TEXTURE_2D, texture[4]);
for (i=0 ; i<256 ; i++) {
cx = float(i%16)/16.0f;
cy = float(i/16)/16.0f;
glNewList(base+i,GL_COMPILE);
glBegin(GL_QUADS);
glTexCoord2f(cx,1-cy-0.0625f);
glVertex2i(0,0);
glTexCoord2f(cx+0.0625f,1-cy-0.0625f);
glVertex2i(16,0);
glTexCoord2f(cx+0.0625f,1-cy);
glVertex2i(16,16);
glTexCoord2f(cx,1-cy);
glVertex2i(0,16);
glEnd();
glTranslated(10,0,0);
glEndList();
}
}
void KillFont(void)
{
glDeleteLists(base, 256);
}
void glPrint(GLint x, GLint y, char* string, int set)
{
if (set > 1) set = 1;
glBindTexture(GL_TEXTURE_2D, texture[4]);
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,640,0,480,-100,100);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glTranslated(x,y,0);
glListBase(base-32+(128*set));
glCallLists(strlen(string),GL_BYTE,string);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glEnable(GL_DEPTH_TEST);
}
void Swiatlo(void)
{
glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient2);
glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
glEnable(GL_LIGHT2);
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
}
AUX_RGBImageRec *LoadBMP(char *Filename)
{
FILE *File=NULL;
if (!Filename)
{
return NULL;
}
File=fopen(Filename,"r");
if (File)
{
fclose(File);
return auxDIBImageLoad(Filename);
}
return NULL;
}
int LoadTextures()
{
int Status = FALSE;
AUX_RGBImageRec *TextureImage[14];
memset(TextureImage, 0, sizeof(void *)*14);
if ( (TextureImage[0]=LoadBMP("kosmos.bmp")) &&
(TextureImage[1]=LoadBMP("belka.bmp")) &&
(TextureImage[2]=LoadBMP("ziemia.bmp"))&&
(TextureImage[3]=LoadBMP("ksiezyc.bmp"))&&
(TextureImage[4]=LoadBMP("fonty.bmp")) &&
(TextureImage[5]=LoadBMP("mars.bmp")) &&
(TextureImage[6]=LoadBMP("wenus.bmp")) &&
(TextureImage[7]=LoadBMP("merkury.bmp")) &&
(TextureImage[8]=LoadBMP("satelitemaska.bmp")) &&
(TextureImage[9]=LoadBMP("satelite.bmp")) &&
(TextureImage[10]=LoadBMP("saturnmaska.bmp")) &&
(TextureImage[11]=LoadBMP("saturn.bmp")) &&
(TextureImage[12]=LoadBMP("space.bmp")) &&
(TextureImage[13]=LoadBMP("sun.bmp")))
{
Status=TRUE;
glGenTextures(14, &texture[0]);
for(loop=0;loop<14;loop++)
{
glBindTexture(GL_TEXTURE_2D, texture[loop]);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3,TextureImage[loop]->sizeX, TextureImage[loop]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[loop]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
}
for(loop=0;loop<14;loop++)
{
if (TextureImage[loop])
{
if (TextureImage[loop]->data)
free(TextureImage[loop]->data);
free(TextureImage[loop]);
}
}
}
return Status;
}
GLvoid ReSizeGLScene(GLsizei width, GLsizei height)
{
if (height==0)
{
height=1;
}
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
int InitGL(GLvoid)
{
if(!LoadTextures())
return FALSE;
Swiatlo();
Build_font();
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glEnable(GL_TEXTURE_2D);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
Obiekt1=gluNewQuadric();
gluQuadricTexture(Obiekt1, GLU_TRUE);
gluQuadricDrawStyle(Obiekt1, GLU_FILL);
return TRUE;
}
GLint DrawGLScene(GLvoid)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(0,0,10, 0,0,0, 0,1,0);
glDisable(GL_LIGHTING);
glTranslatef(0,0,-1);
glRotatef(20,-1,0,0);
glRotatef(rotate,0,0,1);
glRotatef(rotate, 0,1,0);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glBegin(GL_QUADS);
glTexCoord2f(0.0f , roll + 0.0f); glVertex3f(-10.1f, -10.1f, 0.0);
glTexCoord2f(6.0f , roll + 0.0f); glVertex3f(10.1f, -10.1f, 0.0);
glTexCoord2f(6.0f, roll + 6.0f); glVertex3f(10.1f, 10.1f, 0.0);
glTexCoord2f(0.0f, roll + 6.0f); glVertex3f(-10.1f, 10.1f, 0.0);
glEnd();