Mrusio Temat założony przez niniejszego użytkownika |
[OpenGL] Problem z wyświetlaniem sześcianów w zależności od kąta patrzenia » 2012-03-16 14:18:28 |
|
wojownik266 |
» 2012-03-16 14:43:33 No to wklej cały! |
|
ison |
» 2012-03-16 14:49:45 gdzieś wyłączasz depth test |
|
Mrusio Temat założony przez niniejszego użytkownika |
» 2012-03-16 15:09:04 nie wyłączam nigdzie. Mam w funkcji inicjalizującej: void init( char * title, int width, int height, int argc, char * argv[] ) { glutInit( & argc, argv ); glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB ); glutInitWindowSize( width, height ); glutCreateWindow( title ); glutDisplayFunc( Display ); glutIdleFunc( Display ); glutReshapeFunc( Reshape ); glutKeyboardFunc( pressKey ); glutIgnoreKeyRepeat( 1 ); glutKeyboardUpFunc( releaseKey ); glutSpecialFunc( pressSpecKey ); glutIgnoreKeyRepeat( 1 ); glutSpecialUpFunc( releaseSpecKey ); glutEntryFunc( mouseDetect ); glutMouseFunc( mouseButton ); glutPassiveMotionFunc( mouseMove ); glEnable( GL_TEXTURE_2D ); glutWarpPointer( glutGet( GLUT_WINDOW_WIDTH ) / 2, glutGet( GLUT_WINDOW_HEIGHT ) / 2 ); glutSetCursor( GLUT_CURSOR_NONE ); glEnable( GL_DEPTH_TEST ); glDepthFunc( GL_LEQUAL ); glEnable( GL_CULL_FACE ); glCullFace( GL_BACK ); glFrontFace( GL_CCW ); glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); glutMainLoop(); }
A skrzynie robię tak: void teksturowana_skrzynia() { static bool tekstura_wczytana = false; static GLuint texture; if( !tekstura_wczytana ) { LoadGLTextures( & texture, "C:\\Users\\Mariusz\\Desktop\\c++\\projects\\crate.bmp" ); tekstura_wczytana = true; } glBindTexture( GL_TEXTURE_2D, texture ); glBegin( GL_QUADS ); 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 ); 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 ); 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 ); 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 ); 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 ); 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(); }
|
|
ison |
» 2012-03-16 15:15:03 przecież ta skrzynia (czy gracz czy co to tam jest ;)) z uśmieszkiem ma inną teksturę to jak ją renderujesz za pomocą tej funkcji? pokaż miejsce gdzie wywołujesz teksturowana_skrzynia() |
|
Mrusio Temat założony przez niniejszego użytkownika |
» 2012-03-16 15:23:29 ale zauważ że problem nie dotyczy tylko tej jednej. Pozostałe też nachodzą na siebie, a ta skrzynia z uśmieszkiem jest tak samo jak ta funkcja wklejona tylko inną ścieżkę ma po prostu. Tutaj kod o który prosiłeś void Rysuj() { line_ground(); uklad_wspolrzednych(); glColor3f( 0, 1, 0.8 ); teksturowana_skrzynia(); glTranslatef( 2.0, 0.0, 0.0 ); teksturowana_skrzynia(); glTranslatef( 2.0, 0.0, 0.0 ); teksturowana_skrzynia2(); glTranslatef( 2.0, 0.0, 0.0 ); teksturowana_skrzynia(); }
Natomiast funkcja Rysuj jest tutaj: void Display() { int w = glutGet( GLUT_WINDOW_WIDTH ), h = glutGet( GLUT_WINDOW_HEIGHT ); float ratio = 1.0 * w / h; glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 45, ratio, 0, 1000 ); Kamera.Move(); gluLookAt( Kamera.x, Kamera.y, Kamera.z, Kamera.LookAtX(), Kamera.LookAtY(), Kamera.LookAtZ(), Kamera.stompx, Kamera.stompy, Kamera.stompz ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); Rysuj(); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrtho( 0, w, 0, h, - 2.0, 2.0 ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); obiektyw_kamery( w, h ); glutSwapBuffers(); }
|
|
ison |
» 2012-03-16 15:35:01 ale zauważ że problem nie dotyczy tylko tej jednej.
|
ano prawda, teraz dopiero zauważyłem. Dziwne trochę, nie wiem czemu tak się dzieje. w teksturowana_skrzynia2() nie wyłączasz nigdzie depth testu? |
|
Mrusio Temat założony przez niniejszego użytkownika |
» 2012-03-16 15:42:51 |
|
« 1 » 2 |