Jump to content
  • Advertisement
Sign in to follow this  
trancemokes

OpenGL Screensaver String (text

This topic is 3850 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible to set text in a screensaver? I'm wondering how then :) ^^ /code glTranslatef(-1.0f,1.0f,-4.0f); glColor3f(0.0f,1.0f,1.0f); glRasterPos2f(-0.25f, -0.52f); glprint("wwHHAAAszzzAAAAA"); /code Glprint doesn't work, More code :) #include <windows.h> #include <scrnsave.h> #include <GL/gl.h> #include <GL/glu.h> #include "resource.h" #include <stdio.h> // Header File For Standard Input/Output #include <iostream> #include <string> #include <time.h> #include <math.h> // Header File For Windows Math Library #include <stdio.h> // Header File For Standard Input/Output #include <stdarg.h> // Header File For Variable Argument Routines //get rid of these warnings: //truncation from const double to float //conversion from double to float #pragma warning(disable: 4305 4244) #define TIMER 1 void InitGL(HWND hWnd, HDC & hDC, HGLRC & hRC); void CloseGL(HWND hWnd, HDC hDC, HGLRC hRC); void SetupAnimation(int Width, int Height); void CleanupAnimation(); void OnTimer(HDC hDC); int Width, Height; GLfloat xrot; GLfloat yrot; GLfloat xspeed=0.25f; GLfloat yspeed=0.25f; GLfloat x=0.0f; GLfloat y=0.0f; GLfloat z=-15.0f; GLfloat LightAmbient[]= { 0.5f, 0.5f, 0.5f, 1.0f }; GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f }; GLfloat LightPosition[]= { 0.0f, 0.0f, 2.0f, 1.0f }; GLuint filter=1; GLuint texture[3]; GLuint PixelFormat; GLfloat rot; // Roteren v/d Tekst GLfloat rtri; LRESULT WINAPI ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { static HDC hDC; static HGLRC hRC; static RECT rect; switch ( message ) { case WM_CREATE: GetClientRect( hWnd, &rect ); Width = rect.right; Height = rect.bottom; InitGL( hWnd, hDC, hRC ); SetupAnimation(Width, Height); SetTimer( hWnd, TIMER, 10, NULL ); return 0; case WM_DESTROY: KillTimer( hWnd, TIMER ); CleanupAnimation(); CloseGL( hWnd, hDC, hRC ); return 0; case WM_TIMER: OnTimer(hDC); return 0; } return DefScreenSaverProc( hWnd, message, wParam, lParam ); } BOOL WINAPI ScreenSaverConfigureDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch ( message ) { case WM_INITDIALOG: LoadString(hMainInstance, IDS_DESCRIPTION, szAppName, 40); return TRUE; case WM_COMMAND: switch( LOWORD( wParam ) ) { case IDOK: EndDialog( hDlg, LOWORD( wParam ) == IDOK ); return TRUE; case IDCANCEL: EndDialog( hDlg, LOWORD( wParam ) == IDOK ); return TRUE; } } return FALSE; } BOOL WINAPI RegisterDialogClasses(HANDLE hInst) { return TRUE; } static void InitGL(HWND hWnd, HDC & hDC, HGLRC & hRC) { static PIXELFORMATDESCRIPTOR pfd= { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 }; hDC=GetDC(hWnd); PixelFormat=ChoosePixelFormat(hDC,&pfd); SetPixelFormat(hDC,PixelFormat,&pfd);; hRC=wglCreateContext(hDC); wglMakeCurrent(hDC,hRC); } void SetupAnimation(int Width, int Height) { glViewport(0, 0, (GLsizei) Width, (GLsizei) Height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.5f); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); glEnable(GL_LIGHT1); glColor4f(1.0f, 0.0f, 1.0f, 0.5f); glBlendFunc(GL_SRC_ALPHA,GL_ONE); } void OnTimer(HDC hDC) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(x,y,z); if (x < 10.0f) { x+=0.025f; } else { x=-10.0f; } if (y > -7.5f) { y-=0.05f; } else { y=7.5f; } glRotatef(xrot,1.0f,0.0f,0.0f); glRotatef(yrot,0.0f,1.0f,0.0f); glBindTexture(GL_TEXTURE_2D, texture[filter]); glBegin(GL_QUADS); glNormal3f( 0.0f, 0.0f, 1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glNormal3f( 0.0f, 0.0f,-1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); glNormal3f( 0.0f, 1.0f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); glNormal3f( 0.0f,-1.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glNormal3f( 1.0f, 0.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); glNormal3f(-1.0f, 0.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); glEnd(); glLoadIdentity(); glTranslatef(0.0f,0.0f,-6.0f); glRotatef(rtri,0.0f,1.0f,0.0f); // Roteren om de Y-as glBegin(GL_TRIANGLES); // Tekenen v/d Driehoek glColor3f(1.0f,0.0f,0.0f); // Rood glVertex3f( 0.0f, 1.0f, 0.0f);// Top v/d Driehoek (Front) glColor3f(0.0f,1.0f,0.0f); // Groen glVertex3f(-1.0f,-1.0f, 1.0f);// Links v/d Driehoek (Front) glColor3f(0.0f,0.0f,1.0f); // Blauw glVertex3f( 1.0f,-1.0f, 1.0f);// Rechts v/d Driehoek (Front) glColor3f(1.0f,0.0f,0.0f); glVertex3f( 0.0f, 1.0f, 0.0f);// Top Of Triangle (Right) glColor3f(0.0f,0.0f,1.0f); glVertex3f( 1.0f,-1.0f, 1.0f);// Links v/d Driehoek (Right) glColor3f(0.0f,1.0f,0.0f); glVertex3f( 1.0f,-1.0f, -1.0f);// Rechts v/d Driehoek (Right) glColor3f(1.0f,0.0f,0.0f); glVertex3f( 0.0f, 1.0f, 0.0f);// Top v/d Driehoek (Back) glColor3f(0.0f,1.0f,0.0f); glVertex3f( 1.0f,-1.0f, -1.0f);// Links v/d Driehoek (Back) glColor3f(0.0f,0.0f,1.0f); glVertex3f(-1.0f,-1.0f, -1.0f);// Rechts v/d Driehoek (Back) glColor3f(1.0f,0.0f,0.0f); glVertex3f( 0.0f, 1.0f, 0.0f);// Top v/d Driehoek (Left) glColor3f(0.0f,0.0f,1.0f); glVertex3f(-1.0f,-1.0f,-1.0f);// Links v/d Driehoek (Left) glColor3f(0.0f,1.0f,0.0f); glVertex3f(-1.0f,-1.0f, 1.0f);// Rechts v/d Driehoek (Left) glEnd(); rot+=0.08f; rtri+=0.08f; glTranslatef(-1.0f,1.0f,-4.0f); glColor3f(0.0f,1.0f,1.0f); glRasterPos2f(-0.25f, -0.52f); glprint("wwHHAAAszzzAAAAA"); // glEnable(GL_LIGHTING); SwapBuffers(hDC); xrot+=xspeed; yrot+=yspeed; } static void CloseGL(HWND hWnd, HDC hDC, HGLRC hRC) { wglMakeCurrent( NULL, NULL ); wglDeleteContext( hRC ); ReleaseDC( hWnd, hDC ); } void CleanupAnimation() { } If i miss something plz say it :) Srry for my poor english

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!