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

OpenGL Discussion :

Connaitre des informations sur opengl via un programme


Sujet :

OpenGL

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    574
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Avril 2004
    Messages : 574
    Points : 109
    Points
    109
    Par défaut Connaitre des informations sur opengl via un programme
    Bonjour,


    Est ce que quelqu'un parmis vous saurait comment faire pour connaitre la version d'opengl ou bien les différentes mode de rendu disponible avec en passant par un programme (C++) par exemple...?

  2. #2
    Invité
    Invité(e)
    Par défaut
    essaye glview par exemple, ça te donnera tout ce que tu désire je pense.

  3. #3
    Rédacteur
    Avatar de bafman
    Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2003
    Messages
    2 574
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Industrie

    Informations forums :
    Inscription : Novembre 2003
    Messages : 2 574
    Points : 5 323
    Points
    5 323
    Par défaut
    regarde du coté de glGet*, ça permet de recuperer toutes les informations disponibles. par contre, tu ne peut l'utiliser qu'une fois que tu a crée un context openGL.
    * Il est infiniment plus simple de faire rapidement un code qui marche que de faire un code rapide qui marche
    * pour faciliter les recherches, n'oubliez pas de voter pour les réponses pertinentes
    Mes articles

  4. #4
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    574
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Avril 2004
    Messages : 574
    Points : 109
    Points
    109
    Par défaut
    Je viens de télécharger glview. Oui, ce logiciel donne bien un grand nombre d'information. Mais ce que je voudrais, c'est savoir comment il a eu accés à certaines de ces informations via la programmation.
    En effet, je suis en train de réaliser un petit fichier au format xml qui répertorie ce genre d'information, telles que les résolutions supportées par exemple...

  5. #5
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    574
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Avril 2004
    Messages : 574
    Points : 109
    Points
    109
    Par défaut
    En ce qui concerne les glGet*... Oui, c'est apparement le genre de fonction qui sont utilisées comme glGetString (GL_VERSION) par exemple.
    Cependant, il faut d'abord créer un contexte pour pouvoir utiliser cette méthode.
    Cela veut dire quoi, initialiser une fenetre, etc...

  6. #6
    Membre éclairé
    Avatar de Happy
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2005
    Messages
    665
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : Autre

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Juin 2005
    Messages : 665
    Points : 875
    Points
    875
    Par défaut
    En même temps créer un contexte opengl c'est pas si long ...
    Maintenant cela dépends du type d'utilisation qu'on veux en faire

  7. #7
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    574
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Avril 2004
    Messages : 574
    Points : 109
    Points
    109
    Par défaut
    Justement, je n'arrete pas de regarder depuis ce matin...
    Ce que je voudrais, c'est juste créer ce contexte pour obtenir des informations. Je ne veux pas avoir de fenetre qui s'affiche. Hors, je trouve dans la documentation que à chaque fois que l'on veut un contexte, il faut créer une fenetre. Par exemple, j'ai essayé de me faire une petite fonction que j'appelerai bien dans mon code pour avoir une fenetre :
    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
    HWND createOpenGLContext (HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPSTR lpCmdLine,
                       int nCmdShow)
    {
        // the handle for the window, filled by a function
        HWND hWnd;
        // this struct holds information for the window class
        WNDCLASSEX wc;
     
        // clear out the window class for use
        ZeroMemory(&wc, sizeof(WNDCLASSEX));
     
        // fill in the struct with the needed information
        wc.cbSize = sizeof(WNDCLASSEX);
        wc.style = CS_HREDRAW | CS_VREDRAW;
        wc.lpfnWndProc = (WNDPROC)WindowProc;
        wc.hInstance = hInstance;
        wc.hCursor = LoadCursor(NULL, IDC_ARROW);
        wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
        wc.lpszClassName = "WindowClass1";
     
        // register the window class
        RegisterClassEx(&wc);
     
        // create the window and use the result as the handle
        hWnd = CreateWindowEx(NULL,
                              "WindowClass1",    // name of the window class
                              "Our First Windowed Program",    // title of the window
                              WS_OVERLAPPEDWINDOW,    // window style
                              300,    // x-position of the window
                              300,    // y-position of the window
                              500,    // width of the window
                              400,    // height of the window
                              NULL,    // we have no parent window, NULL
                              NULL,    // we aren't using menus, NULL
                              hInstance,    // application handle
                              NULL);    // used with multiple windows, NULL
     
        // display the window on the screen
        //ShowWindow(hWnd, nCmdShow);
     
        // enter the main loop:
     
    	return hWnd;
    }
    Sauf que en générale ce genre de fonction s'appelle dans un main spécial à cause des arguments (WinMain...) Et que moi je voudrais créer mon contexte juste pendant le déroulement d'un programme pour obtenir les info et aprés bye bye le context. Je ne sais pas exactement ce que doivent valoir les arguments dans ce cas là...

    En fait, ce que je veux dire, c'est que à la base je lance mon programme en console par exemple, et je ne vois pas comment remplir ses informations propres à des lancements de programme graphique...?

  8. #8
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    574
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Avril 2004
    Messages : 574
    Points : 109
    Points
    109
    Par défaut
    Bon je progresse :
    Alors apparement, mon context est bien crée !
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    HWND hWnd = createOpenGLContext(NULL,NULL,NULL,NULL);
    J'ai modifié ma fonction ci dessus qui me revoie un HWND si le context est crée grâce à getDC(hWnd) qui me renvoie pas NULL quand je l'appelle...

    Cependant, juste aprés j'appelle ma fonction glGetString (GL_VERSION) et pourtant ma valeur est toujours à NULL...

    Pourtant, j'ai bien créé le context là.... non...

  9. #9
    Rédacteur
    Avatar de Laurent Gomila
    Profil pro
    Développeur informatique
    Inscrit en
    Avril 2003
    Messages
    10 651
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Avril 2003
    Messages : 10 651
    Points : 15 920
    Points
    15 920
    Par défaut
    Montre ton nouveau code, parce que là on ne voit toujours aucun code relatif au contexte OpenGL.

  10. #10
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    574
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Avril 2004
    Messages : 574
    Points : 109
    Points
    109
    Par défaut
    Voici au final, ce que j'ai fait uniquement pour tester si je pouvais afficher au moins les info sur la version...

    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
     
    // include the basic windows header file
    #include <windows.h>
    #include <windowsx.h>
    #include <iphlpapi.h>
    //#include "juce.h"
    #include <initguid.h>
    #include <gl/gl.h>
    #include <gl/glu.h>
     
     
     
     
     
    // the WindowProc function prototype
    LRESULT CALLBACK WindowProc(HWND hWnd,
    							UINT message,
    							WPARAM wParam,
    							LPARAM lParam);
     
    // the entry point for any Windows program
    int WINAPI WinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPSTR lpCmdLine,
                       int nCmdShow)
    {
        // the handle for the window, filled by a function
        HWND hWnd;
        // this struct holds information for the window class
        WNDCLASSEX wc;
     
        // clear out the window class for use
        ZeroMemory(&wc, sizeof(WNDCLASSEX));
     
        // fill in the struct with the needed information
        wc.cbSize = sizeof(WNDCLASSEX);
        wc.style = CS_HREDRAW | CS_VREDRAW;
        wc.lpfnWndProc = (WNDPROC)WindowProc;
        wc.hInstance = hInstance;
        wc.hCursor = LoadCursor(NULL, IDC_ARROW);
        wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
        wc.lpszClassName = "WindowClass1";
     
        // register the window class
        RegisterClassEx(&wc);
     
        // create the window and use the result as the handle
        hWnd = CreateWindowEx(NULL,
    		"WindowClass1",    // name of the window class
    		"Our First Windowed Program",    // title of the window
    		WS_OVERLAPPEDWINDOW,    // window style
    		300,    // x-position of the window
    		300,    // y-position of the window
    		500,    // width of the window
    		400,    // height of the window
    		NULL,    // we have no parent window, NULL
    		NULL,    // we aren't using menus, NULL
    		hInstance,    // application handle
    		NULL);    // used with multiple windows, NULL
     
        // display the window on the screen
        ShowWindow(hWnd, nCmdShow);
     
        // enter the main loop:
     
        // this struct holds Windows event messages
        MSG msg;
     
        // Enter the infinite message loop
        while(TRUE)
        {
    		// find out the starting time of each loop
    		DWORD starting_point = GetTickCount();
     
    		// Check to see if any messages are waiting in the queue
    		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
    		{
    			// If the message is WM_QUIT, exit the while loop
    			if (msg.message == WM_QUIT)
    				break;
     
    			// translate keystroke messages into the right format
    			TranslateMessage(&msg);
     
    			// send the message to the WindowProc function
    			DispatchMessage(&msg);
    		}
     
    		// Run game code here
    		HMODULE dll = LoadLibrary ("opengl32.dll");
    		if (dll)
    		{
    			HDC hdc = GetDC(hWnd);
    			// use of glGetString function
    			typedef const GLubyte * (APIENTRY* pglGetString) (GLenum name);
    			pglGetString glGetString = (pglGetString)GetProcAddress(dll,"glGetString");
    			if (0 != glGetString)
    			{
    				const unsigned char *version = glGetString(GL_VERSION);
     
    				OutputDebugString("#");
    				OutputDebugString((const char *)version);
    				OutputDebugString("#");
    			}
    			ReleaseDC(hWnd,hdc);
    		}
     
     
    		// wait until 1/40th of a second has passed
    		while ((GetTickCount() - starting_point) < 25);
    	} 
     
    	// return this part of the WM_QUIT message to Windows
    	return msg.wParam;
    }
     
    // this is the main message handler for the program
    LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        // sort through and find what code to run for the message given
        switch(message)
        {
            // this message is read when the window is closed
    	case WM_DESTROY:
    		{
    			// close the application entirely
    			PostQuitMessage(0);
    			return 0;
    		} break;
        }
     
        // Handle any messages the switch statement didn't
        return DefWindowProc (hWnd, message, wParam, lParam);
    }
    Quand je le passe en mode debug, il y a un problème lorsque je cherche à afficher version en plus:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    #
    OutputDebugString faulted during output
    First-chance exception in DirectXStat.exe (KERNEL32.DLL): 0xC0000005: Access Violation.
    First-chance exception in DirectXStat.exe (KERNEL32.DLL): 0xC0000005: Access Violation.
    #
    J'avoue que la je stagne depuis ce matin...

  11. #11
    Rédacteur
    Avatar de Laurent Gomila
    Profil pro
    Développeur informatique
    Inscrit en
    Avril 2003
    Messages
    10 651
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Avril 2003
    Messages : 10 651
    Points : 15 920
    Points
    15 920
    Par défaut
    Là tu crées une fenêtre, mais tu n'as absolument rien pour le contexte OpenGL. Tu devrais regarder les tutos NeHe par exemple.

  12. #12
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    574
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Avril 2004
    Messages : 574
    Points : 109
    Points
    109
    Par défaut
    Merci, c'est bon, j'ai réussi à obtenir les informations que je voulais.
    Par contre, j'ai encore une petite question :
    J'ai ajouter juste mon code pour obtenir les infos...
    J'ai modifier l'entete de WinMain pour pouvoir appeller ma fonction depuis un autre programme...

    - Si possible, la fenetre pourrait ne pas s'afficher aussi , parce que là ça fait juste un flasch, le temps d'obtenir les infos et de fermer la fenetre...

  13. #13
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    574
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Avril 2004
    Messages : 574
    Points : 109
    Points
    109
    Par défaut
    Oh finalement c'est bon, vu que je ne spécifie la taille de ma fenêtre qu'à zero, on ne la voit meme plus apparaitre...

    Merci à vous pour votre aide...

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. VBA- comment extraire des données sur internet via un programme vba ?
    Par cecile_64 dans le forum Macros et VBA Excel
    Réponses: 17
    Dernier message: 17/08/2012, 15h37
  2. Réponses: 0
    Dernier message: 22/06/2010, 15h57
  3. Réponses: 2
    Dernier message: 02/10/2009, 13h20
  4. des information sur la programmation de codes barre
    Par mohammeedd1 dans le forum Windows
    Réponses: 2
    Dernier message: 16/01/2007, 15h14
  5. Récupérer des Informations sur un PC via un Réseau ?
    Par MaTHieU_ dans le forum Administration
    Réponses: 6
    Dernier message: 22/11/2005, 12h39

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