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

MFC Discussion :

probleme de reaffichage avec openGL [MFC]


Sujet :

MFC

  1. #1
    Membre régulier
    Inscrit en
    Octobre 2004
    Messages
    114
    Détails du profil
    Informations forums :
    Inscription : Octobre 2004
    Messages : 114
    Points : 79
    Points
    79
    Par défaut probleme de reaffichage avec openGL [MFC]
    bonjour
    j'aimerai afficher une serie de cartes assez grosse. pour eviter que cela rame j'utilise openGL. j'arrive à afficher une image de base des l'ouverture de ma fenetre mais je ne comprend pas pourquoi quand j'effectue des commandes qui marchent avec une fenetre openGL "pure" ca ne marche pas chez moi
    voici le code
    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
     
    #include "stdafx.h"
    #include "NeptuneV003.h"
    #include "ZoneCarte.h"
    #include "Texture.h"
    #include <math.h>
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif
     
     
    ///////////////////////////////////////////////////////////////////////////////
    // Call-back : gestion des touches speciales du clavier.
    //-----------------------------------------------------------------------------
    // Paramètres :
    //    key (in) : code ascii de la touche utilisée.
    //    x,y (in) : coordonnées de la souris.
    // Retour :
    //    _
    ///////////////////////////////////////////////////////////////////////////////
    GLvoid ZoneCarte::callback_special(int key, int x, int y)
    {
    	float speed = 1.0f;						// Vitesse de déplacement de la caméra
     
    	switch (key)
    	{
    		case GLUT_KEY_UP:					// Flèche vers le haut : 
    			//zpos -= speed;					// on déplace la caméra selon z-
    			//glTranslatef(-1.5f,0.0f,-6.0f);
    			x++;
    			break;
     
    		case GLUT_KEY_DOWN:					// Flèche vers le bas :
    			//zpos += speed;					// on déplace la caméra selon z+
    			x--;
    			break;
     
    		case GLUT_KEY_LEFT:					// Flèche vers la gauche :
    			//xpos -= speed;					// on déplace la caméra selon x-
    			y++;
    			break;
     
    		case GLUT_KEY_RIGHT:				// Flèche vers la droite :
    			//xpos += speed;					// on déplace la caméra selon x+
    			y--;
    			break;
    	}
     
     
    }
     
    ///////////////////////////////////////////////////////////////////////////////
    // Call-back : déclenche l'affichage même en l'absence d'évènements souris ou
    //             clavier
    //-----------------------------------------------------------------------------
    // Paramètres :
    //    _
    // Retour :
    //    _
    ///////////////////////////////////////////////////////////////////////////////
    GLvoid ZoneCarte::callback_idle()
    {
    	glutPostRedisplay();
    }
     
    int ZoneCarte::InitGL()
    {
    	//carte1.charger("S077_047.tga",false);
    	carte1.definit_filtrage(GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    	carte1.definit_filtrage(GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    	carte1.definit_bouclage(GL_TEXTURE_WRAP_S,GL_REPEAT);
    	carte1.definit_bouclage(GL_TEXTURE_WRAP_T,GL_REPEAT);
    	//carte1.definit_melange(GL_MODULATE);
     
     
     
    	glShadeModel(GL_SMOOTH);
    	glClearColor(0.0f, 0.0f, 0.0f, 0.5f); 
    	glClearDepth(1.0f);
    	glEnable(GL_DEPTH_TEST); 
    	glDepthFunc(GL_LEQUAL); 
    	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    	xpos = 0;
    	ypos = 0;
    	zpos = 0;
    	return TRUE; 
     
     
    }
     
     
    void ZoneCarte::OnDraw(CDC* pDC)
    {
    	CDocument* pDoc = GetDocument();
     
     
    	pDC->TextOut(10,10,"ZoneCarte") ;
    	ASSERT_VALID(pDoc);
    	// TODO: add draw code for native data here CPaintDC dc(this); // Obligatoire 
    	// Utile dans les MDI 
    	HWND hWnd = GetSafeHwnd();
    	HDC hDC = ::GetDC(hWnd);
    	wglMakeCurrent(hDC,m_hglrc);
     
     
    	// je dessine
    	glLoadIdentity();
    	glTranslatef(-1.5f,0.0f,-6.0f);
     
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     
     
    	//glTranslatef(xpos,ypos,zpos);
     
    	glEnable(GL_TEXTURE_2D);
    	carte1.utilise();
     
    	glNormal3f( 0.0f, 0.0f, 1.0f);
    	glBegin(GL_QUADS);
    		glTexCoord2f(0,0);	
    		glVertex3d(0+x, 0+y, 0);
     
    		glTexCoord2f(1,0);	
    		glVertex3d(1+x, 0+y, 0);
     
    		glTexCoord2f(1,1);	
    		glVertex3d( 1+x,1+y, 0);
     
    		glTexCoord2f(0,1);
    		glVertex3d( 0+x,1+y, 0);
    	glEnd();
     
     
     
    	glDisable(GL_TEXTURE_2D);
     
    	// On utilise le double buffer donc après avoir dessiné on échange le back-buffer et le front-buffer pour voir le résultat du back buffer à l'écran 
    	SwapBuffers(m_hgldc);
    }
    Je pense avoir mis les fonctions fonctions qui pourait intervenir dans ce probleme mais si je me susi trompe n'hesitez pas a me demander les autres fonctions.
    en fait il y a une difference avec le code openGL c'est que que dans ma fonctioon main ( en openGL) je declare certaines fonctions de callback
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    // Déclaration des fonctions de call-back.
    	glutDisplayFunc(&callback_display);
    	glutReshapeFunc(&callback_reshape);
    	glutKeyboardFunc(&callback_keyboard);
    	glutSpecialFunc(&callback_special);
    	glutMouseFunc(&callback_mouse);
    	glutMotionFunc(&callback_motion);
    	glutIdleFunc(&callback_idle);
    mais si je recopie ce code il me dit qu'il n'aime pas le "&callback" et si j'enleve le "&" il dit k'il faut e convertir en reference.....
    si quelqu'un sait d'ou cela vient...
    merci

  2. #2
    Membre habitué Avatar de ken_le_videur
    Profil pro
    Inscrit en
    Juillet 2002
    Messages
    129
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2002
    Messages : 129
    Points : 145
    Points
    145
    Par défaut
    Tes callbacks sont déclarées en static ?

  3. #3
    Membre régulier
    Inscrit en
    Octobre 2004
    Messages
    114
    Détails du profil
    Informations forums :
    Inscription : Octobre 2004
    Messages : 114
    Points : 79
    Points
    79
    Par défaut
    non ils sont declarés comme des fonctions normales

  4. #4
    Membre habitué Avatar de ken_le_videur
    Profil pro
    Inscrit en
    Juillet 2002
    Messages
    129
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2002
    Messages : 129
    Points : 145
    Points
    145
    Par défaut
    Déclare les en static

  5. #5
    Membre régulier
    Inscrit en
    Octobre 2004
    Messages
    114
    Détails du profil
    Informations forums :
    Inscription : Octobre 2004
    Messages : 114
    Points : 79
    Points
    79
    Par défaut
    ben la ca accepte les "&" mais les fonctions ne prennent plus les variables d'angle, en plus ca ne fait rien de special, j'essaie de faire une simple translation qui ne depend de rien mais ca ne bouge pas.
    merci

  6. #6
    Membre habitué Avatar de ken_le_videur
    Profil pro
    Inscrit en
    Juillet 2002
    Messages
    129
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2002
    Messages : 129
    Points : 145
    Points
    145
    Par défaut
    Pour les variables d'angle, il faut te débrouiller pour récupérer l'instance de la classe pour pouvoir l'utiliser dans les fonctions static.
    Fait nous voir un peu ton code d'affichage pour le reste

  7. #7
    Membre régulier
    Inscrit en
    Octobre 2004
    Messages
    114
    Détails du profil
    Informations forums :
    Inscription : Octobre 2004
    Messages : 114
    Points : 79
    Points
    79
    Par défaut voila le code
    comme vous le demandez voila le code de mon appli (en ce qui concerne l'affichage du moins)
    ZoneCarte.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
     
    #if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
    // ZoneCarte.h : header file
    //
     
    /////////////////////////////////////////////////////////////////////////////
    // ZoneCarte view
    #include "glut.h"
    #include "gl.h"
    #include "glu.h"
    #include "tga.h"
    #include "Texture.h"
    #include "NeptuneV003Doc.h"
     
    class ZoneCarte : public CView
    {
    #define KEY_ESC 27										// Code ASCII de la touche Echap
    protected:
    	ZoneCarte();           // protected constructor used by dynamic creation
    	DECLARE_DYNCREATE(ZoneCarte)
     
    // Attributes
    public:
     
    // Operations
    public:
     
    	CNeptuneV003Doc* GetDocument();
     
    	int InitGL(void);
    	BOOL SetPixelformat(HDC hdc);
    	static GLvoid callback_motion(int x, int y);
    	static GLvoid callback_idle();
    	static GLvoid callback_mouse(int button, int state, int x, int y);
    	static GLvoid callback_special(int key, int x, int y);
    	static GLvoid callback_keyboard(unsigned char key, int x, int y);
     
     
    // Overrides
    	// ClassWizard generated virtual function overrides
    	//{{AFX_VIRTUAL(ZoneCarte)
    	protected:
    	virtual void OnDraw(CDC* pDC);      // overridden to draw this view
    	//}}AFX_VIRTUAL
     
    // Implementation
    protected:
    	virtual ~ZoneCarte();
    #ifdef _DEBUG
    	virtual void AssertValid() const;
    	virtual void Dump(CDumpContext& dc) const;
    #endif
     
    	// Generated message map functions
    protected:
    	//{{AFX_MSG(ZoneCarte)
    	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
    	afx_msg void OnSize(UINT nType, int cx, int cy);
    	afx_msg void OnDestroy();
    	//}}AFX_MSG
    	DECLARE_MESSAGE_MAP()
    private:
    	HGLRC m_hglrc;
    	HDC m_hgldc;
    	Texture carte1;
    	float	xpos , ypos , zpos ;				// Position de la caméra
    	int		angle_x , angle_y;					// Orientation de la caméra
    	int		mouse_x , mouse_y;					// Position de la souris
    };
     
     
     
    /////////////////////////////////////////////////////////////////////////////
     
    #ifndef _DEBUG  // debug version in ZoneCarte.cpp
    inline CNeptuneV003Doc* ZoneCarte::GetDocument()
       { return (CNeptuneV003Doc*)m_pDocument; }
    #endif
     
    //{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
     
    #endif // !defined(AFX_ZONECARTE_H__9288C8E3_E0BA_469C_A72C_77CB1F4EBBC3__INCLUDED_)
    ZoneCarte.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
     
    // ZoneCarte.cpp : implementation file
    //
     
    #include "stdafx.h"
    #include "NeptuneV003.h"
    #include "ZoneCarte.h"
    #include "Texture.h"
     
    #include <windows.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    #include <mmsystem.h>	
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif
     
    /////////////////////////////////////////////////////////////////////////////
    // ZoneCarte
     
    IMPLEMENT_DYNCREATE(ZoneCarte, CView)
     
    float x = 0, y = 0;
    ZoneCarte::ZoneCarte()
    {
    }
     
    ZoneCarte::~ZoneCarte()
    {
    }
     
     
    BEGIN_MESSAGE_MAP(ZoneCarte, CView)
    	//{{AFX_MSG_MAP(ZoneCarte)
    	ON_WM_CREATE()
    	ON_WM_SIZE()
    	ON_WM_DESTROY()
    	//}}AFX_MSG_MAP
    END_MESSAGE_MAP()
     
    ///////////////////////////////////////////////////////////////////////////////
    // Call-back : gestion des événements clavier.
    //-----------------------------------------------------------------------------
    // Paramètres :
    //    key (in) : code ascii de la touche utilisée.
    //    x,y (in) : coordonnées de la souris.
    // Retour :
    //    _
    ///////////////////////////////////////////////////////////////////////////////
    GLvoid ZoneCarte::callback_keyboard(unsigned char key, int x, int y)
    {
    	switch (key)
    	{
    		case KEY_ESC:						// 'ECHAP' :
    			exit(1);						// on quitte le programme
    			break;
    	}
    }
     
     
     
    ///////////////////////////////////////////////////////////////////////////////
    // Call-back : gestion des touches speciales du clavier.
    //-----------------------------------------------------------------------------
    // Paramètres :
    //    key (in) : code ascii de la touche utilisée.
    //    x,y (in) : coordonnées de la souris.
    // Retour :
    //    _
    ///////////////////////////////////////////////////////////////////////////////
    GLvoid ZoneCarte::callback_special(int key, int x, int y)
    {
    	float speed = 1.0f;						// Vitesse de déplacement de la caméra
     
    	switch (key)
    	{
    		case GLUT_KEY_UP:					// Flèche vers le haut : 
    			//zpos -= speed;					// on déplace la caméra selon z-
    			//glTranslatef(-1.5f,0.0f,-6.0f);
    			glTranslatef(-1.5f,0.0f,-6.0f);
     
     
    			break;
     
    		case GLUT_KEY_DOWN:					// Flèche vers le bas :
    			//zpos += speed;					// on déplace la caméra selon z+
    			x--;
    			break;
     
    		case GLUT_KEY_LEFT:					// Flèche vers la gauche :
    			//xpos -= speed;					// on déplace la caméra selon x-
    			y++;
    			break;
     
    		case GLUT_KEY_RIGHT:				// Flèche vers la droite :
    			//xpos += speed;					// on déplace la caméra selon x+
    			y--;
    			break;
     
    		case GLUT_KEY_PAGE_UP:				// Page Up :
    			//ypos += speed;
    			break;
     
    		case GLUT_KEY_PAGE_DOWN:			// Page Down :
    //			ypos -= speed;
    //			if( ypos <= 0.1 )
    		//		ypos = 0.1;
    			break;
    	}
     
     
    }
     
     
     
     
    ///////////////////////////////////////////////////////////////////////////////
    // Call-back : gestion de clics souris.
    //-----------------------------------------------------------------------------
    // Paramètres :
    //    button (in) : code du bouton utilisé.
    //    state  (in) : état du bouton.
    //    x,y    (in) : coordonnées de la souris.
    // Retour :
    //    _
    ///////////////////////////////////////////////////////////////////////////////
    GLvoid ZoneCarte::callback_mouse(int button, int state, int x, int y)
    {
    	if (state == GLUT_DOWN && button == GLUT_LEFT_BUTTON)
    	{
    //		mouse_x = x;
    	//	mouse_y = y;
    	}
    }
     
     
     
    ///////////////////////////////////////////////////////////////////////////////
    // Call-back : gestion des déplacements de la souris.
    //-----------------------------------------------------------------------------
    // Paramètres :
    //    x,y    (in) : coordonnées de la souris.
    // Retour :
    //    _
    ///////////////////////////////////////////////////////////////////////////////
    GLvoid ZoneCarte::callback_motion(int x, int y)
    {
    //	angle_x += y - mouse_y;						// Modifie la direction de vue de la caméra
    //	angle_y += x - mouse_x;						// en fonction de la position de la souris
    //	mouse_x = x;
    //	mouse_y = y;
     
    	glutPostRedisplay();						// Demande le réaffichage
    }
     
     
     
    ///////////////////////////////////////////////////////////////////////////////
    // Call-back : déclenche l'affichage même en l'absence d'évènements souris ou
    //             clavier
    //-----------------------------------------------------------------------------
    // Paramètres :
    //    _
    // Retour :
    //    _
    ///////////////////////////////////////////////////////////////////////////////
    GLvoid ZoneCarte::callback_idle()
    {
    	glutPostRedisplay();
    }
     
     
     
    /////////////////////////////////////////////////////////////////////////////
    // ZoneCarte drawing
     
    void ZoneCarte::OnDraw(CDC* pDC)
    {
    	CDocument* pDoc = GetDocument();
     
     
    	pDC->TextOut(10,10,"ZoneCarte") ;
    	ASSERT_VALID(pDoc);
    	// TODO: add draw code for native data here CPaintDC dc(this); // Obligatoire 
    	// Utile dans les MDI 
    	HWND hWnd = GetSafeHwnd();
    	HDC hDC = ::GetDC(hWnd);
    	wglMakeCurrent(hDC,m_hglrc);
     
     
    	// je dessine
    	glLoadIdentity();
    	glTranslatef(-1.5f,0.0f,-6.0f);
     
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     
     
    	//glTranslatef(xpos,ypos,zpos);
     
    	glEnable(GL_TEXTURE_2D);
    	carte1.utilise();
     
    	glNormal3f( 0.0f, 0.0f, 1.0f);
    	glBegin(GL_QUADS);
    		glTexCoord2f(0,0);	
    		glVertex3d(0+x, 0+y, 0);
     
    		glTexCoord2f(1,0);	
    		glVertex3d(1+x, 0+y, 0);
     
    		glTexCoord2f(1,1);	
    		glVertex3d( 1+x,1+y, 0);
     
    		glTexCoord2f(0,1);
    		glVertex3d( 0+x,1+y, 0);
    	glEnd();
     
     
     
    	glDisable(GL_TEXTURE_2D);
     
    	// On utilise le double buffer donc après avoir dessiné on échange le back-buffer et le front-buffer pour voir le résultat du back buffer à l'écran 
    	SwapBuffers(m_hgldc);
    }
     
     
     
     
     
    /////////////////////////////////////////////////////////////////////////////
    // ZoneCarte diagnostics
     
    #ifdef _DEBUG
    void ZoneCarte::AssertValid() const
    {
    	CView::AssertValid();
    }
     
    void ZoneCarte::Dump(CDumpContext& dc) const
    {
    	CView::Dump(dc);
    }
    #endif //_DEBUG
     
    /////////////////////////////////////////////////////////////////////////////
    // ZoneCarte message handlers
     
    BOOL ZoneCarte::SetPixelformat(HDC hdc)
    {
     
    	PIXELFORMATDESCRIPTOR *ppfd; 
    	int pixelformat; 
     
    	PIXELFORMATDESCRIPTOR pfd = 
    	{ 
    		sizeof(PIXELFORMATDESCRIPTOR), 
    		1, // version
    		PFD_DRAW_TO_WINDOW | // mode fenêtré 
    		PFD_SUPPORT_OPENGL | // on utilise OpenGL 
    		PFD_GENERIC_FORMAT |
    		PFD_DOUBLEBUFFER, // double buffer
    		PFD_TYPE_RGBA, // RGBA
    		32, // 32-bit
    		0, 0, 0, 0, 0, 0, // bits de couleur ignorés 
    		8, // pas de buffer alpha 
    		0, // shift bit ignoré
    		8, // Pas de buffer d'accumulation 
    		0, 0, 0, 0, // bits d'accumulation ignorés 
    		64, // z-buffer (32 ou 64 bits ?) 
    		8, // pas de stencil buffer 
    		8, // pas de buffer auxiliaire 
    		PFD_MAIN_PLANE, // couche principale 
    		0, // réservé 
    		0, 0, 0 // ignoré
    	}; 
    	ppfd = &pfd; 
    	if ( (pixelformat = ChoosePixelFormat(hdc, ppfd)) == 0 ) 
    	{ 
    		::MessageBox(NULL, "ChoosePixelFormat échoué ! ", "Erreur", MB_OK); 
    		return FALSE; 
    	} 
     
    	if (SetPixelFormat(hdc, pixelformat, ppfd) == FALSE) 
    	{ 
    		::MessageBox(NULL, "SetPixelFormat échoué ! ", "Erreur", MB_OK); 
    		return FALSE; 
    	} 
     
    	return TRUE;
     
     
     
    }
     
    int ZoneCarte::InitGL()
    {
    	//carte1.charger("S077_047.tga",false);
    	carte1.definit_filtrage(GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    	carte1.definit_filtrage(GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    	carte1.definit_bouclage(GL_TEXTURE_WRAP_S,GL_REPEAT);
    	carte1.definit_bouclage(GL_TEXTURE_WRAP_T,GL_REPEAT);
    	//carte1.definit_melange(GL_MODULATE);
     
    	// Déclaration des fonctions de call-back.
    //	glutDisplayFunc(&callback_display);
    //	glutReshapeFunc(&callback_reshape);
    	glutKeyboardFunc(&callback_keyboard);
    	glutSpecialFunc(&callback_special);
    	glutMouseFunc(&callback_mouse);
    	glutMotionFunc(&callback_motion);
    	glutIdleFunc(&callback_idle);
     
    	glShadeModel(GL_SMOOTH);
    	glClearColor(0.0f, 0.0f, 0.0f, 0.5f); 
    	glClearDepth(1.0f);
    	glEnable(GL_DEPTH_TEST); 
    	glDepthFunc(GL_LEQUAL); 
    	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    	xpos = 0;
    	ypos = 0;
    	zpos = 0;
    	return TRUE; 
     
     
    }
     
     
    int ZoneCarte::OnCreate(LPCREATESTRUCT lpCreateStruct) 
    {	
    	if (CView::OnCreate(lpCreateStruct) == -1)
    	return -1;
     
    	// TODO: Add your specialized creation code here
    	m_hgldc = ::GetDC(m_hWnd); 
    	if(!SetPixelformat(m_hgldc))
    	{
    		::MessageBox(::GetFocus(),"SetPixelformat échoué ! ","Erreur",MB_OK);
    		return -1;
    	}
     
    	m_hglrc = wglCreateContext(m_hgldc);
    	int i= wglMakeCurrent(m_hgldc,m_hglrc); 
    	InitGL();
    	return 0;
    }
     
    void ZoneCarte::OnSize(UINT nType, int cx, int cy) 
    {
    	CView::OnSize(nType, cx, cy);
     
    	int width;
    	int height; width = cx;
    	height = cy; // Evite une division par zéro 
    	if (height==0) 
    	{
    	height=1; 
    	} glViewport(0,0,width,height); 
    	glMatrixMode(GL_PROJECTION);
    	glLoadIdentity(); 
    	gluPerspective(45.0f,(float)width/(float)height,0.1f,100.0f);
    	glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
    	glLoadIdentity(); // Reset The Modelview Matrix 
     
    }
     
    void ZoneCarte::OnDestroy() 
    {
    	CView::OnDestroy();
     
    		if(wglGetCurrentContext() != NULL)
    	wglMakeCurrent(NULL,NULL);
     
    	if(m_hglrc != NULL)
    	{
    	wglDeleteContext(m_hglrc);
    	m_hglrc = NULL;
    	}
     
    }
    comme je savai pas quelle partie du code mettre j'ai tous mis
    merci beaucoup pour l'aide

  8. #8
    Membre régulier
    Inscrit en
    Octobre 2004
    Messages
    114
    Détails du profil
    Informations forums :
    Inscription : Octobre 2004
    Messages : 114
    Points : 79
    Points
    79
    Par défaut petite erreur
    en fait le programme compile mais il y a une erreur d'allocation memoire depuis que les fonctions sont en static lors de l'execution

  9. #9
    Membre habitué Avatar de ken_le_videur
    Profil pro
    Inscrit en
    Juillet 2002
    Messages
    129
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2002
    Messages : 129
    Points : 145
    Points
    145
    Par défaut
    Hum en fait je suis pas certain que l'on puisse mélanger glut et mfc. En effet glut doit créer sa propre fenêtre (pas sur).

    De plus tu apelle glutPostRedisplay mais tu a commenté ta fonction d'affichage glutDisplayFunc(&callback_display);

  10. #10
    Membre régulier
    Inscrit en
    Octobre 2004
    Messages
    114
    Détails du profil
    Informations forums :
    Inscription : Octobre 2004
    Messages : 114
    Points : 79
    Points
    79
    Par défaut
    si c'est pas possible alors tans pis merci quand meme

Discussions similaires

  1. Réponses: 0
    Dernier message: 30/11/2010, 16h46
  2. Réponses: 1
    Dernier message: 30/11/2010, 09h58
  3. Problem d'affichage avec OpenGl
    Par moulzo dans le forum OpenGL
    Réponses: 12
    Dernier message: 24/01/2010, 15h46
  4. Réponses: 2
    Dernier message: 18/03/2005, 08h32
  5. Probleme avec OpenGL
    Par Sh. dans le forum OpenGL
    Réponses: 3
    Dernier message: 04/11/2004, 12h48

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