m4tx  | 
» 2011-09-13 16:27:22 No nie żartuj sobie DejaVu... :P To tak jakby instalator Windowsa instalował również Linuksa ;) http://lmgtfy.com/?q=opengl+visual+c%2B%2BLol... to jest taka bibliteka jak sdl_opengl? Po co? O_o to można w czystym SDLu zrobić...  | 
 | 
programista12 Temat założony przez niniejszego użytkownika  | 
» 2011-09-13 16:35:44 Zastosowałem się do tego z linku powyżej, ale kompilator wywala błąd:  1>------ Build started: Project: OpenGL Test, Configuration: Release Win32 ------ 1>Embedding manifest... 1>mt.exe : general error c10100b1: Failed to load file ".\Release\OpenGL Test.exe". Nie mo|na odnalez okre[lonego pliku. 1>Build log was saved at "file://j:\Dokumenty\Visual Studio 2008\Projects\OpenGL Test\Release\BuildLog.htm" 1>OpenGL Test - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 
 Kod: #include <windows.h> #include <gl/gl.h> #include <gl/glu.h>
  HWND hWnd; HDC hDC; HGLRC hRC;
 
  void SetupPixelFormat() {     PIXELFORMATDESCRIPTOR pfd, * ppfd;     int pixelformat;          ppfd = & pfd;          ppfd->nSize = sizeof( PIXELFORMATDESCRIPTOR );     ppfd->nVersion = 1;     ppfd->dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;     ppfd->dwLayerMask = PFD_MAIN_PLANE;     ppfd->iPixelType = PFD_TYPE_COLORINDEX;     ppfd->cColorBits = 16;     ppfd->cDepthBits = 16;     ppfd->cAccumBits = 0;     ppfd->cStencilBits = 0;          pixelformat = ChoosePixelFormat( hDC, ppfd );     SetPixelFormat( hDC, pixelformat, ppfd ); }
 
  void InitGraphics() {     hDC = GetDC( hWnd );          SetupPixelFormat();          hRC = wglCreateContext( hDC );     wglMakeCurrent( hDC, hRC );          glClearColor( 0, 0, 0, 0.5 );     glClearDepth( 1.0 );     glEnable( GL_DEPTH_TEST ); }
 
  void ResizeGraphics() {          RECT rect;     int width, height;     GLfloat aspect;          GetClientRect( hWnd, & rect );     width = rect.right;     height = rect.bottom;     aspect =( GLfloat ) width / height;               glViewport( 0, 0, width, height );     glMatrixMode( GL_PROJECTION );     glLoadIdentity();     gluPerspective( 45.0, aspect, 1.0, 100.0 );     glMatrixMode( GL_MODELVIEW ); }
 
  void DrawGraphics() {     glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );               glLoadIdentity();     glTranslated( 0, 0, - 10 );               glBegin( GL_QUADS );     glColor3d( 1, 0, 0 );     glVertex3d( - 2, 2, 0 );     glVertex3d( 2, 2, 0 );     glVertex3d( 2, - 2, 0 );     glVertex3d( - 2, - 2, 0 );     glEnd();               SwapBuffers( hDC ); }
 
  LONG WINAPI MainWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) {     switch( uMsg )     {     case WM_SIZE:         ResizeGraphics();         break;              case WM_CLOSE:         DestroyWindow( hWnd );         break;              case WM_DESTROY:         PostQuitMessage( 0 );         break;                           default:         return DefWindowProc( hWnd, uMsg, wParam, lParam );         break;     }          return 1; }
  int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) {          const LPCWSTR appname = TEXT( "OpenGL Sample" );          WNDCLASS wndclass;     MSG msg;               wndclass.style = 0;     wndclass.lpfnWndProc =( WNDPROC ) MainWndProc;     wndclass.cbClsExtra = 0;     wndclass.cbWndExtra = 0;     wndclass.hInstance = hInstance;     wndclass.hIcon = LoadIcon( hInstance, appname );     wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );     wndclass.hbrBackground =( HBRUSH )( COLOR_WINDOW + 1 );     wndclass.lpszMenuName = appname;     wndclass.lpszClassName = appname;               if( !RegisterClass( & wndclass ) ) return FALSE;               hWnd = CreateWindow(     appname,     appname,     WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,     CW_USEDEFAULT,     CW_USEDEFAULT,     800,     600,     NULL,     NULL,     hInstance,     NULL );          if( !hWnd ) return FALSE;               InitGraphics();               ShowWindow( hWnd, nCmdShow );     UpdateWindow( hWnd );               while( 1 )     {         if( PeekMessage( & msg, NULL, 0, 0, PM_NOREMOVE ) == TRUE )         {             if( !GetMessage( & msg, NULL, 0, 0 ) ) return TRUE;                          TranslateMessage( & msg );             DispatchMessage( & msg );         }         DrawGraphics();     }          wglDeleteContext( hRC );     ReleaseDC( hWnd, hDC ); }
   | 
 | 
m4tx  | 
» 2011-09-13 16:40:39 1>mt.exe : general error c10100b1: Failed to load file ".\Release\OpenGL Test.exe". Nie mo|na odnalez okre[lonego pliku. A to już jest błąd Visuala :P  | 
 | 
programista12 Temat założony przez niniejszego użytkownika  | 
» 2011-09-13 16:46:20 Dobra. Na stronie lazyfoo.net znalazłem o używaniu OpenGL z SDL i już działa. Ale mam pytanie: Czy w ten sposób da się normalnie uczyć OpenGL?  | 
 | 
kamillo121  | 
» 2011-09-13 16:48:06 | Lol... to jest taka bibliteka jak sdl_opengl? Po co? O_o to można w czystym SDLu zrobić... |  
 Nie to nie jest biblioteka, jest to jeden nagłówek(z tego co pamiętam), który wchodzi w skład biblioteki SDL. Jeżeli ma bibliotekę SDL zainstalowaną to zapewne ma nagłówek sdl_opengl... Co to znaczy normalnie ? jak chcesz poznać samego OpenGL to się go ucz a nie kombinuj z SDL. Jak się nauczysz dobrze OpenGL'a to potem możesz sobie SDL użyć np do wczytywania obrazów z różnymi rozszerzeniami czy tam do czego będziesz chciał.  | 
 | 
m4tx  | 
» 2011-09-13 16:57:25 E tam od razu "kombinuj". Ja się uczę OpenGLa wykorzystując SFMLa do utworzenia okna, zdarzeń itd. i nie narzekam ;) Lol... to jest taka bibliteka jak sdl_opengl? Po co? O_o to można w czystym SDLu zrobić... Nie to nie jest biblioteka, jest to jeden nagłówek(z tego co pamiętam), który wchodzi w skład biblioteki SDL. Jeżeli ma bibliotekę SDL zainstalowaną to zapewne ma nagłówek sdl_opengl... |  
 A, no chyba że tak :P  | 
 | 
Gabes  | 
» 2011-09-13 17:05:53 Nauka openGL+WinAPI to droga przez męke bez dobrej znajomości WinAPI.
 Ja proponuje Allegro_5+openGL.
   | 
 | 
programista12 Temat założony przez niniejszego użytkownika  | 
» 2011-09-13 17:06:59 Spróbowałem jeszcze raz z samym OpenGL. Z internetu pobrałem glut 3.7.6 i wpakowałem pliki do odpowiednich folderów. Do linkera dałem "opengl32.lib glu32.lib glut32.lib", ale po kompilacji kodu z pierwszej lekcji wywala błędy:  Warning	2	warning C4985: 'exit': attributes not present on previous declaration.	I:\Program Files\Microsoft Visual Studio 9.0\VC\include\stdlib.h	371
  Error	3	error C3861: 'exit': identifier not found	j:\Dokumenty\Visual Studio 2008\Projects\OGL\main.cpp	65 Error	1	error C2381: 'exit' : redefinition; __declspec(noreturn) differs	I:\Program Files\Microsoft Visual Studio 9.0\VC\include\stdlib.h	371
 
 
 Kod: 
 
 
 
 
  #include <GL/glut.h> #include <stdlib.h>
 
 
  void Display() {          glClearColor( 1.0, 1.0, 1.0, 1.0 );               glClear( GL_COLOR_BUFFER_BIT );               glColor3f( 1.0, 0.0, 0.0 );               glBegin( GL_POLYGON );               glVertex3f( 0.0, 0.0, 0.0 );     glVertex3f( 0.0, 1.0, 0.0 );     glVertex3f( 1.0, 1.0, 0.0 );     glVertex3f( 1.0, 0.0, 0.0 );               glEnd();               glFlush();               glutSwapBuffers(); }
 
 
  void Reshape( int width, int height ) {          Display(); }
 
 
  enum {     EXIT  };
 
 
  void Menu( int value ) {     switch( value )     {              case EXIT:         exit( 0 );     } }
  int main( int argc, char * argv[] ) {          glutInit( & argc, argv );               glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB );               glutInitWindowSize( 400, 400 );               glutCreateWindow( "Kwadrat 1" );               glutDisplayFunc( Display );               glutReshapeFunc( Reshape );               glutCreateMenu( Menu );               #ifdef WIN32          glutAddMenuEntry( "Wyjście", EXIT );     #else          glutAddMenuEntry( "Wyjscie", EXIT );     #endif               glutAttachMenu( GLUT_RIGHT_BUTTON );               glutMainLoop();     return 0; }
 
 EDIT: Wykomentowałem #include <stdlib> i program działa.  | 
 | 
| 1 « 2 »  3 |