IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

wxWidgets Discussion :

Programme de base OpenGL avec wxGLCanvas et Code::Blocks


Sujet :

wxWidgets

  1. #1
    Membre à l'essai
    Inscrit en
    Mars 2003
    Messages
    29
    Détails du profil
    Informations forums :
    Inscription : Mars 2003
    Messages : 29
    Points : 24
    Points
    24
    Par défaut Programme de base OpenGL avec wxGLCanvas et Code::Blocks
    Salut,

    Il existe des quantités de tutoriels (trop !) pour OpenGL. Et je n'arrive pas à en extraire la base. Les exemples sont tous différents et je suis perdu entre gl, glu, glew, glee, glm, gltrucmuche, ...
    Comme j'utilise wxWidgets, j'aimerais trouver un exemple récent présentant la base du programme.
    De ce que j'ai compris, on doit avoir :
    - le wxGLCanvas
    - un wxGLContext
    Ensuite pourquoi je n'arrive pas à trouver des primitives pour des objets simples comme un cube, une sphère, une flèche. Un cube, c'est juste la longueur d'un coté. Une sphère, juste un centre et un rayon.

    Dans les démos, y a un exemple de cube. Super mais j'ai l'impression qu'il n'est pas récent vu qu'il utilise des glBegin/glEnd qui d'après ce que j'ai cru comprendre est obsolète ...

    Bref, je suis un peu perdu !

    Note : l'exemple "pyramid" semble utiliser des objets plus récents, mais je suis pas sûr ...

  2. #2
    Membre à l'essai
    Inscrit en
    Mars 2003
    Messages
    29
    Détails du profil
    Informations forums :
    Inscription : Mars 2003
    Messages : 29
    Points : 24
    Points
    24
    Par défaut
    Ok sur la base de l'exemple"pyramid", j'ai extrait la base nécessaire.
    On a donc :
    - création de l'application
    - création d'une frame
    - création d'un GLCanvas
    Jusque là, ça fonctionne.
    Maintenant j'aimerais dessiner des objets simple : axe, cube, sphère et là ça bloque un peu !!
    Voici mon code qui compile avec Code::Blocks : créer un projet vide et juste rajouter wxmsw31u_gl et opengl32 dans "Linker settings"
    Simple.h
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
     
     
    #ifndef _SIMPLE_H
    #define _SIMPLE_H
     
    typedef enum {
        draw_None = 0,
        draw_Axe,
        draw_Cube,
        draw_Sphere
    } Simple_Draw;
     
    // ******************************************************************* //
    // Définition de l'application, hériter de wxApp
    // ******************************************************************* //
    class MyApp: public wxApp
    {
    public:
        MyApp(){}
        bool OnInit() wxOVERRIDE;
    };
     
    // ******************************************************************* //
    // Définition de la frame principale, hériter de wxFrame
    // ******************************************************************* //
     
    // Forward déclaration du mon GLCanvas
    class MyGLCanvas;
     
    class MyFrame : public wxFrame
    {
    public:
        MyFrame(const wxString& title);
        ~MyFrame();
        wxString     OGLString;
     
        void OnQuit(wxCommandEvent& event);
        void SetOGLString(const wxString& ogls)
            { OGLString = ogls; }
        bool OGLAvailable();
     
    private:
        MyGLCanvas*  Fra_Canvas = NULL;
     
        wxDECLARE_EVENT_TABLE();
    };
     
    // Event for MyFrame
    wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
        EVT_MENU(wxID_EXIT,  MyFrame::OnQuit)
    wxEND_EVENT_TABLE()
     
    // ******************************************************************* //
    // Définition de mon GLCanvas hérité de wxGLCanvas
    // ******************************************************************* //
    class MyGLCanvas : public wxGLCanvas
    {
    public:
        MyGLCanvas(MyFrame* parent, const wxGLAttributes& canvasAttrs);
        ~MyGLCanvas();
     
        Simple_Draw draw = draw_None;
     
        // Used just to know if we must end now because OGL 3.2 isn't available
        bool OglCtxAvailable()
            {return Can_OglContext != NULL;}
     
        // Event
        void OnPaint(wxPaintEvent& event);
        void OnSize(wxSizeEvent& event);
        void OnMouse(wxMouseEvent& event);
        void OnKeyDown(wxKeyEvent& event);
     
    private:
        // Members
        MyFrame*      Can_Parent = NULL;
        wxGLContext*  Can_OglContext = NULL;
        int           Can_WinHeight = 0; // We use this var to know if we have been sized
     
        // Init the OpenGL stuff
        bool oglInit();
        void prepare3DViewport(int topleft_x, int topleft_y, int bottomrigth_x, int bottomrigth_y);
     
        // Draw simple figure
        void DoAxe(void);
        void DoCube(GLfloat cote);
        void DoSphere(GLfloat radius);
     
        wxDECLARE_EVENT_TABLE();
    };
     
    // Event for MyGLCanvas
    wxBEGIN_EVENT_TABLE(MyGLCanvas, wxGLCanvas)
        EVT_PAINT(MyGLCanvas::OnPaint)
        EVT_SIZE(MyGLCanvas::OnSize)
        EVT_MOUSE_EVENTS(MyGLCanvas::OnMouse)
        EVT_KEY_DOWN(MyGLCanvas::OnKeyDown)
    wxEND_EVENT_TABLE()
     
    #endif // _SIMPLE_H
    Simple.cpp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
     
     
    // ============================================================================
    // declarations
    // ============================================================================
     
    // ----------------------------------------------------------------------------
    // headers
    // ----------------------------------------------------------------------------
     
    // For compilers that support precompilation, includes "wx/wx.h".
    #include "wx/wxprec.h"
     
    #ifndef WX_PRECOMP
        #include "wx/wx.h"
    #endif
     
    #if !wxUSE_GLCANVAS
        #error "OpenGL required: set wxUSE_GLCANVAS to 1 and rebuild the library"
    #endif
     
    #include "wx/glcanvas.h"
    #include "simple.h"
    #include <GL/glu.h>
     
    // the application icon (under Windows and OS/2 it is in resources and even
    // though we could still include the XPM here it would be unused)
    #ifndef wxHAS_IMAGES_IN_RESOURCES
        #include "sample.xpm"
    #endif
     
    // ============================================================================
    // implementation
    // ============================================================================
     
    // ----------------------------------------------------------------------------
    // the application class
    // ----------------------------------------------------------------------------
     
    // Création de l'application
    wxIMPLEMENT_APP(MyApp);
     
    // 'Main program' equivalent: the program execution "starts" here
    bool MyApp::OnInit()
    {
        if ( !wxApp::OnInit() )
            return false;
     
        // create the main application window
        MyFrame* CurrentFrame = new MyFrame("wxWidgets Simple OpenGL");
     
        //Exit if the required visual attributes or OGL context couldn't be created
        if ( ! CurrentFrame->OGLAvailable() )
            return false;
     
        // As of October 2015 GTK+ needs the frame to be shown before we call SetCurrent()
        CurrentFrame->Show(true);
     
        return true;
    }
     
    // ----------------------------------------------------------------------------
    // main frame
    // ----------------------------------------------------------------------------
     
    // frame constructor
    MyFrame::MyFrame(const wxString& title)
           : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(500, 400))
    {
        // set the frame icon
     //   SetIcon(wxICON(sample));
        SetIcon(wxICON(aaaa)); // To Set App Icon
     
        // Test des attributs d'OpenGL
        wxGLAttributes vAttrs;
        // Defaults should be accepted
        vAttrs.PlatformDefaults().Defaults().EndList();
        bool accepted = wxGLCanvas::IsDisplaySupported(vAttrs) ;
     
        if ( ! accepted )
        {
            // Try again without sample buffers
            vAttrs.Reset();
            vAttrs.PlatformDefaults().RGBA().DoubleBuffer().Depth(16).EndList();
            accepted = wxGLCanvas::IsDisplaySupported(vAttrs) ;
     
            if ( !accepted )
            {
                wxMessageBox("Visual attributes for OpenGL are not accepted.\nThe app will exit now.",
                             "Error with OpenGL", wxOK | wxICON_ERROR);
            }
        }
     
        // Les attributs sont bons, on peut créer le canvas
        if ( accepted )
            Fra_Canvas = new MyGLCanvas(this, vAttrs);
     
        // On défini une taille minimale pour la fenêtre
        // (y se passe des trucs bizarres sinon quand on réduit totalement la fenêtre !)
        SetMinSize(wxSize(250, 200));
    }
     
    MyFrame::~MyFrame()
    {
        if ( Fra_Canvas )
            delete Fra_Canvas;
    }
     
    // event handlers
    void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
    {
        // true is to force the frame to close
        Close(true);
    }
     
    bool MyFrame::OGLAvailable()
    {
        if ( ! Fra_Canvas )
            return false;
     
        //Test if OGL context could be created.
        return Fra_Canvas->OglCtxAvailable();
    }
     
    // ----------------------------------------------------------------------------
    // The canvas inside the frame. Our OpenGL connection
    // ----------------------------------------------------------------------------
     
    //We create a wxGLContext in this constructor.
    //We do OGL initialization at OnSize().
    MyGLCanvas::MyGLCanvas(MyFrame* parent, const wxGLAttributes& canvasAttrs)
                           : wxGLCanvas(parent, canvasAttrs)
    {
        // Le parent (frame) du canvas
        Can_Parent = parent;
     
        // Explicitly create a new rendering context instance for this canvas.
        wxGLContextAttrs ctxAttrs;
        ctxAttrs.PlatformDefaults().CoreProfile().OGLVersion(3, 2).EndList();
        Can_OglContext = new wxGLContext(this, NULL, &ctxAttrs);
     
        // La création du contexte a foiré
        if ( !Can_OglContext->IsOK() )
        {
            wxMessageBox("This sample needs an OpenGL 3.2 capable driver.\nThe app will end now.",
                         "OpenGL version error", wxOK | wxICON_INFORMATION, this);
            delete Can_OglContext;
            Can_OglContext = NULL;
        }
    }
     
    MyGLCanvas::~MyGLCanvas()
    {
        if ( Can_OglContext )
        {
            SetCurrent(*Can_OglContext);
            delete Can_OglContext;
            Can_OglContext = NULL;
        }
    }
     
    bool MyGLCanvas::oglInit()
    {
        if ( !Can_OglContext )
            return false;
     
        // The current context must be set before we get OGL pointers
        SetCurrent(*Can_OglContext);
     
        // Non nécessaire, juste récupérer les infos sur le hardware
        // Get the GL version for the current OGL context
        wxString sglVer = "\nUsing OpenGL version: ";
        sglVer += wxString::FromUTF8(
                    reinterpret_cast<const char *>(glGetString(GL_VERSION)) );
        // Also Vendor and Renderer
        sglVer += "\nVendor: ";
        sglVer += wxString::FromUTF8(
                    reinterpret_cast<const char *>(glGetString(GL_VENDOR)) );
        sglVer += "\nRenderer: ";
        sglVer += wxString::FromUTF8(
                    reinterpret_cast<const char *>(glGetString(GL_RENDERER)) );
        Can_Parent->SetOGLString(sglVer);
     
        return true;
    }
     
    void MyGLCanvas::prepare3DViewport(int topleft_x, int topleft_y, int bottomrigth_x, int bottomrigth_y)
    {
        glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Black Background
        glClearDepth(1.0f);	// Depth Buffer Setup
        glEnable(GL_DEPTH_TEST); // Enables Depth Testing
        glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
        glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
     
        glEnable(GL_COLOR_MATERIAL);
     
        glViewport(topleft_x, topleft_y, bottomrigth_x-topleft_x, bottomrigth_y-topleft_y);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
     
        float ratio_w_h = (float)(bottomrigth_x-topleft_x)/(float)(bottomrigth_y-topleft_y);
        gluPerspective(45 /*view angle*/, ratio_w_h, 0.1 /*clip close*/, 200 /*clip far*/);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
    }
     
    void MyGLCanvas::OnPaint( wxPaintEvent& WXUNUSED(event) )
    {
        // This is a dummy, to avoid an endless succession of paint messages.
        // OnPaint handlers must always create a wxPaintDC.
        wxPaintDC dc(this);  //wxClientDC
     
        // Avoid painting when we have not yet a size
        if ( Can_WinHeight < 1)
            return;
     
        // This should not be needed, while we have only one canvas
        SetCurrent(*Can_OglContext);
     
        // Do the paint of a simple figure
        switch (draw)
        {
            case draw_None: break;
            case draw_Axe: DoAxe(); break;
            case draw_Cube: DoCube(1.0); break;
            case draw_Sphere: DoSphere(2.0); break;
        }
     
        SwapBuffers();
    }
     
    //Note:
    // You may wonder why OpenGL initialization was not done at wxGLCanvas ctor.
    // The reason is due to GTK+/X11 working asynchronously, we can't call
    // SetCurrent() before the window is shown on screen (GTK+ doc's say that the
    // window must be realized first).
    // In wxGTK, window creation and sizing requires several size-events. At least
    // one of them happens after GTK+ has notified the realization. We use this
    // circumstance and do initialization then.
     
    void MyGLCanvas::OnSize(wxSizeEvent& event)
    {
        event.Skip();
     
        // If this window is not fully initialized, dismiss this event
        if ( !IsShownOnScreen() )
            return;
     
        // On termine l'initialisation du GLCanvas
        if (Can_WinHeight == 0)
        {
            if ( !oglInit() )
                return;
            //Some GPUs need an additional forced paint event
            PostSizeEvent();
        }
     
        // This is normally only necessary if there is more than one wxGLCanvas
        // or more than one wxGLContext in the application.
        SetCurrent(*Can_OglContext);
     
        // It's up to the application code to update the OpenGL viewport settings.
      //  const wxSize size = event.GetSize() * GetContentScaleFactor();
    //    Can_WinHeight = size.y;
    //    m_oglManager->SetViewport(0, 0, size.x, Can_WinHeight);
    //glViewport(0, 0, size.x, Can_WinHeight);
     
    //    const wxSize ClientSize = GetClientSize() * GetContentScaleFactor();
     
     //   TestGLContext& canvas = wxGetApp().GetContext(this, m_useStereo);
     //   glViewport(0, 0, ClientSize.x, ClientSize.y);
     
         const wxSize size = event.GetSize() * GetContentScaleFactor();
      //  glViewport(0, 0, size.x, size.y);
        Can_WinHeight = size.y;
     
        prepare3DViewport(0, 0, size.x, size.y);
     
        // Generate paint event without erasing the background.
        Refresh(false);
    }
     
    void MyGLCanvas::OnMouse(wxMouseEvent& event)
    {
        event.Skip();
     
        // GL 0 Y-coordinate is at bottom of the window
        int oglwinY = Can_WinHeight - event.GetY();
     
        if ( event.LeftIsDown() )
        {
            if ( ! event.Dragging() )
            {
                // Store positions
     //           m_oglManager->OnMouseButDown(event.GetX(), oglwinY);
            }
            else
            {
                // Rotation
    //            m_oglManager->OnMouseRotDragging( event.GetX(), oglwinY );
     
                // Generate paint event without erasing the background.
                Refresh(false);
            }
        }
    }
     
    // Effectuer des dessins simples : Axe, Carré, Sphère
    void MyGLCanvas::OnKeyDown(wxKeyEvent& event)
    {
        int k = event.GetKeyCode();
        // caractère en minuscule
        if ( k>=97 ) k -= 32;
     
        switch ( k )
        {
            case 65: // A
                // dessiner un axe 3D
                draw = draw_Axe;
                Refresh();
                break;
            case 67: // C
                // dessiner un carré
                draw = draw_Cube;
                Refresh();
                break;
            case 83: // S
                // dessiner une sphère
                draw = draw_Sphere;
                Refresh();
                break;
            case 73: // I
                // Information sur OpenGL
                wxMessageBox(Can_Parent->OGLString, "Info OpenGL", wxOK | wxICON_INFORMATION);
                break;
     
            default:
                wxMessageBox(_T("Demande inconnue"), "OpenGL Canvas", wxOK | wxICON_ERROR);
                event.Skip();
                return;
        }
    }
     
    void MyGLCanvas::DoAxe(void)
    {
     
    }
     
    void MyGLCanvas::DoCube(GLfloat cote)
    {
        SetCurrent(*Can_OglContext);
     
     
        glEnable(GL_DEPTH_TEST);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glMatrixMode(GL_MODELVIEW);
        glEnable(GL_LIGHTING);
        glEnable(GL_LIGHT0);
     
    //    // add slightly more light, the default lighting is rather dark
        GLfloat ambient[] = { 0.5, 0.5, 0.5, 1.0 };
        glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
     
        glLoadIdentity();
     
        glTranslatef(1.5f, 0.0f, -7.0f);  // Move right and into the screen
     
        glBegin(GL_QUADS);                // Begin drawing the color cube with 6 quads
                                          // Top face (y = 1.0f)
                                          // Define vertices in counter-clockwise (CCW) order with normal pointing out
        glColor3f(0.0f, 1.0f, 0.0f);     // Green
        glVertex3f(cote, cote, -cote);
        glVertex3f(-cote, cote, -cote);
        glVertex3f(-cote, cote, cote);
        glVertex3f(cote, cote, cote);
     
        // Bottom face (y = -1.0f)
        glColor3f(1.0f, 0.5f, 0.0f);     // Orange
        glVertex3f(cote, -cote, cote);
        glVertex3f(-cote, -cote, cote);
        glVertex3f(-cote, -cote, -cote);
        glVertex3f(cote, -cote, -cote);
     
        // Front face  (z = 1.0f)
        glColor3f(1.0f, 0.0f, 0.0f);     // Red
        glVertex3f(cote, cote, cote);
        glVertex3f(-cote, cote, cote);
        glVertex3f(-cote, -cote, cote);
        glVertex3f(cote, -cote, cote);
     
        // Back face (z = -1.0f)
        glColor3f(1.0f, 1.0f, 0.0f);     // Yellow
        glVertex3f(cote, -cote, -cote);
        glVertex3f(-cote, -cote, -cote);
        glVertex3f(-cote, cote, -cote);
        glVertex3f(cote, cote, -cote);
     
        // Left face (x = -1.0f)
        glColor3f(0.0f, 0.0f, 1.0f);     // Blue
        glVertex3f(-cote, cote, cote);
        glVertex3f(-cote, cote, -cote);
        glVertex3f(-cote, -cote, -cote);
        glVertex3f(-cote, -cote, cote);
     
        // Right face (x = 1.0f)
        glColor3f(1.0f, 0.0f, 1.0f);     // Magenta
        glVertex3f(cote, cote, -cote);
        glVertex3f(cote, cote, cote);
        glVertex3f(cote, -cote, cote);
        glVertex3f(cote, -cote, -cote);
        glEnd();  // End of drawing color-cube
     
        glFlush();
     
     //   SwapBuffers();
    }
     
    void MyGLCanvas::DoSphere(GLfloat radius)
    {
     
     
    }
    Une idée ? un bout de code ?

  3. #3
    Membre à l'essai
    Inscrit en
    Mars 2003
    Messages
    29
    Détails du profil
    Informations forums :
    Inscription : Mars 2003
    Messages : 29
    Points : 24
    Points
    24
    Par défaut
    supprimé

  4. #4
    Expert éminent sénior

    Avatar de dragonjoker59
    Homme Profil pro
    Software Developer
    Inscrit en
    Juin 2005
    Messages
    2 031
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Software Developer
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2005
    Messages : 2 031
    Points : 11 474
    Points
    11 474
    Billets dans le blog
    11
    Par défaut
    Salut !

    Ca ne marche pas, mais qu'est-ce qui ne marche pas ?

    OpenGL ne fournit pas de primitives de base, effectivement, du coup tu dois les faire toi même.
    Je pourrais bien te montrer comment j'ai fait, mais j'ai tellement encapsulé le truc que je ne suis pas sûr que ça t'aide.

    Ensuite, pour bosser correctement avec des versions modernes d'OpenGL, je te conseille la bibliothèque GLM (header only) pour les maths (matrices, vecteurs...), et GLAD pour le chargement des fonctions modernes d'OpenGL

    Vu que c'est de l'OpenGL (la liaison avec wxWidgets n'a pas l'air de poser de problème), il faudrait peut-être déplacer la discussion dans la section appropriée ?

  5. #5
    Membre à l'essai
    Inscrit en
    Mars 2003
    Messages
    29
    Détails du profil
    Informations forums :
    Inscription : Mars 2003
    Messages : 29
    Points : 24
    Points
    24
    Par défaut
    Salut,

    Bon, après 1536 essais, ça marche toujours pas
    Normalement en appuyant sur "C", je devrais avoir un cube mais l'écran reste désespérément noir

    Quand je pense qu'avec GLScene et Delphi, y a déjà plus de 15 ans de ça, je pouvais afficher tout un tas de trucs sans aucune ligne de code. Et là même pas fichu d'afficher le moindre point après 1000 lignes de code. J'ai l'impression d'être revenu à l'age de pierre de la programmation

    Note : j'ai vu glm, glad mais j'ai vu qui avait également glew, glut, freeglut ..... Franchement, c'est la jungle ! Tu peux expliquer ?

  6. #6
    Membre à l'essai
    Inscrit en
    Mars 2003
    Messages
    29
    Détails du profil
    Informations forums :
    Inscription : Mars 2003
    Messages : 29
    Points : 24
    Points
    24
    Par défaut
    Salut,

    Bon, j'ai compris, je laisse tomber wxGLCanvas franchement inutilisable
    J'ai testé freeGlut, glfw et franchement freeGlut a l'air pas mal. En particulier, y a la plupart des shapes et c'est cool
    C'est sûr que par rapport à GLScene on est loin du compte mais pour ce que je veux faire, ça devrait aller

  7. #7
    Expert éminent sénior

    Avatar de dragonjoker59
    Homme Profil pro
    Software Developer
    Inscrit en
    Juin 2005
    Messages
    2 031
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Software Developer
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2005
    Messages : 2 031
    Points : 11 474
    Points
    11 474
    Billets dans le blog
    11
    Par défaut
    Alors surtout pas freeglut.
    C'est vieux et déprécié depuis bien 15 ans (je sais que c'est une reprise de glut, en plus récente, mais ça n'enlève rien à son obsolescence).
    Du coup, GLFW pour le fenêtrage est la solution minimale que je préfère (notamment parce que ça supporte Vulkan aussi ).
    GLAD et GLEW servent plus ou moins à la même chose : le chargement des fonctions d'OpenGL depuis la dll. Je préfère GLAD car elle permet de sélectionner les extensions dont tu as besoin, sans tout mettre (ce que fait GLEW).

    Pour les modèles, franchement passe par un modeleur pour faire tes formes, exporte les en OBJ, et importe les (un parser obj basique, c'est rapide à écrire).

  8. #8
    Membre à l'essai
    Inscrit en
    Mars 2003
    Messages
    29
    Détails du profil
    Informations forums :
    Inscription : Mars 2003
    Messages : 29
    Points : 24
    Points
    24
    Par défaut
    Salut,

    De tout ce que j'ai pu testé, Freeglut est le seul qui possède les shapes de base en accès direct : glutSolidSphere(5, 20, 20) et hop on a une sphère. J'ai pas besoin de truc compliqué, j'ai juste besoin de pouvoir dessiner des assemblées de sphères, de flèches, de cube et de pouvoir déplacer tout ça avec la souris.
    Dans un monde idéal, j'aurais une classe GLSphere, une classe GLArrow, une classe GLCube et une classe GLWindow. Je ferais ma classe dérivée de GLWindow dans laquelle je construirais ma scène avec des tableaux de GLSphere, GLArrow, GLCube.
    L'important est dans la construction et l'interaction entre les objets, pas de comprendre comment faire une sphère avec des vertex !

Discussions similaires

  1. Problème avec glew et code::blocks
    Par f56bre dans le forum OpenGL
    Réponses: 14
    Dernier message: 26/10/2017, 11h46
  2. Réponses: 5
    Dernier message: 23/07/2014, 03h19
  3. Problème avec code::blocks et opengl
    Par Dietzer dans le forum Code::Blocks
    Réponses: 4
    Dernier message: 19/06/2009, 19h24
  4. compiler un programme TC avec code::blocks ou un autre compilateur
    Par acacia dans le forum Autres éditeurs
    Réponses: 6
    Dernier message: 24/01/2008, 18h07
  5. Réponses: 5
    Dernier message: 09/04/2006, 19h02

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo