000
21.05.2008, 11:20 Uhr
WindDancer1
|
Hallo Leute ,
ich habe einen kleinen Code geschrieben mit OpenGl + SDL + M$VC++ 6. Es wird eine Textur auf ein Rechteck gelegt welches dann um die Y - Achse gedreht wir. Unter Linux wird der Source "normal" schnell, also wie erwartet ausgefüht aber unter Windows extrem langsam
Hier mal mein Code:
C++: |
#include <windows.h> // Header File For Windows #include <stdio.h> #include <GL\gl.h> #include <GL\glu.h> #include <GL\glaux.h> #include <SDL\SDL.h>
// #ifdef _WIN32 // #undef main // #endif
GLuint texture[1];
int LoadGLTextures( ) { /* Status indicator */ int Status = 0;
/* Create storage space for the texture */ SDL_Surface *TextureImage[1];
/* Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit */ if ( ( TextureImage[0] = SDL_LoadBMP( "data/nehe.bmp" ) ) ) {
/* Set the status to true */ Status = 1;
/* Create The Texture */ glGenTextures( 1, &texture[0] );
/* Typical Texture Generation Using Data From The Bitmap */ glBindTexture( GL_TEXTURE_2D, texture[0] );
/* Generate The Texture */ glTexImage2D( GL_TEXTURE_2D, 0, 3, TextureImage[0]->w, TextureImage[0]->h, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->pixels );
/* Linear Filtering */ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); }
/* Free up any memory we may have used */ if ( TextureImage[0] ) SDL_FreeSurface( TextureImage[0] );
return Status; }
int main() { float angle=0; int i; if (SDL_Init (SDL_INIT_VIDEO)!=0) { printf ("Error: %s\n", SDL_GetError ()); return 1; } atexit (SDL_Quit); SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 5); SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 6); SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 5); if (SDL_SetVideoMode (640, 480, 16, SDL_OPENGL)==NULL) { printf ("Error: %s\n", SDL_GetError ()); return 1; } SDL_WM_SetCaption ("OpenGL with SDL!", "OpenGL"); glViewport (80, 0, 480, 480); glMatrixMode (GL_PROJECTION); glLoadIdentity (); glFrustum (-1.0, 1.0, -1.0, 1.0, 1.0, 100.0); glClearColor (0, 0, 0, 0); glMatrixMode (GL_MODELVIEW);
LoadGLTextures (); glEnable (GL_TEXTURE_2D); /* glShadeModel (GL_SMOOTH); */
for (i=0;i<360*10*3;i++) { angle=(i/10)%360; glLoadIdentity (); glClear (GL_COLOR_BUFFER_BIT); glTranslatef (0, 0, -2); glRotatef (angle, 0, 1, 0); glBegin (GL_QUADS);
// glColor3f (1, 0, 0); glTexCoord2f (0, 0); glVertex3f (-1, -1, 0); // glColor3f (0, 1, 0); glTexCoord2f (1, 0); glVertex3f (1, -1, 0); // glColor3f (1, 1, 0); glTexCoord2f (1, 1); glVertex3f (1, 1, 0); // glColor3f (0, 0, 1); glTexCoord2f (0, 1); glVertex3f (-1, 1, 0);
glEnd (); SDL_GL_SwapBuffers (); } glFlush (); SDL_Delay (1000); return 0; }
|
...ich steh set Tagen vor einem Rätsel
Könnt Ihr mir weiterhelfen??? Vielen Dank für eure Mühe vorab WindDancer |