A l'aide :

Bonjour,
J'ai un projet opengl fonctionne quand je passe wglCreateContext (mais la fonction est obsoléte et sera retirer dans le long terme),
Mais quand je veux utiliser la fonction de remplacement 'wglCreateContextAttribsARB' , aucun primitive dessiner ,seul la fonction glClearColor fonctionne.

Sur le web il n'y pas de sample utilisant la fonction wglCreateContextAttribsARB
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
 
static void
init_opengl_extensions(void)
{
	// Before we can load extensions, we need a dummy OpenGL context, created using a dummy window.
	// We use a dummy window because you can only set the pixel format for a window once. For the
	// real window, we want to use wglChoosePixelFormatARB (so we can potentially specify options
	// that aren't available in PIXELFORMATDESCRIPTOR), but we can't load and use that before we
	// have a context.
	WNDCLASSA window_class = { 0 };
	window_class.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
	window_class.lpfnWndProc = DefWindowProcA;
	window_class.hInstance = GetModuleHandle(0);
	window_class.lpszClassName = "Dummy_WGL_djuasiodwa";
 
 
	if (!RegisterClassA(&window_class)) {
		fatal_error("Failed to register dummy OpenGL window.");
	}
 
	HWND dummy_window = CreateWindowExA(
		0,
		window_class.lpszClassName,
		"Dummy OpenGL Window",
		0,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		0,
		0,
		window_class.hInstance,
		0);
 
	if (!dummy_window) {
		fatal_error("Failed to create dummy OpenGL window.");
	}
 
	HDC dummy_dc = GetDC(dummy_window);
 
	PIXELFORMATDESCRIPTOR pfd;
	pfd.nSize = sizeof(pfd);
	pfd.nVersion = 1;
	pfd.iPixelType = PFD_TYPE_RGBA;
	pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
		pfd.cColorBits = 32;
		pfd.cAlphaBits = 8;
		pfd.iLayerType = PFD_MAIN_PLANE;
		pfd.cDepthBits = 24;
		pfd.cStencilBits = 8;
 
 
	int pixel_format = ChoosePixelFormat(dummy_dc, &pfd);
	if (!pixel_format) {
		fatal_error("Failed to find a suitable pixel format.");
	}
	if (!SetPixelFormat(dummy_dc, pixel_format, &pfd)) {
		fatal_error("Failed to set the pixel format.");
	}
 
	HGLRC dummy_context = wglCreateContext(dummy_dc);
	if (!dummy_context) {
		fatal_error("Failed to create a dummy OpenGL rendering context.");
	}
 
	if (!wglMakeCurrent(dummy_dc, dummy_context)) {
		fatal_error("Failed to activate dummy OpenGL rendering context.");
	}
 
	wglCreateContextAttribsARB = (wglCreateContextAttribsARB_type*)wglGetProcAddress(
		"wglCreateContextAttribsARB");
	wglChoosePixelFormatARB = (wglChoosePixelFormatARB_type*)wglGetProcAddress(
		"wglChoosePixelFormatARB");
 
	wglMakeCurrent(dummy_dc, 0);
	wglDeleteContext(dummy_context);
	ReleaseDC(dummy_window, dummy_dc);
	DestroyWindow(dummy_window);
}
 
 
void EnableOpenGL(HWND hWnd, HDC* hDC, HGLRC* hRC)
{
 
 
	init_opengl_extensions();
	// get the device context (DC)
 
 
		/*wglCreateContextAttribsARB = (wglCreateContextAttribsARB_type*)wglGetProcAddress(
		"wglCreateContextAttribsARB");
 
		wglChoosePixelFormatARB = (wglChoosePixelFormatARB_type*)wglGetProcAddress(
			"wglChoosePixelFormatARB");*/
 
		if ((wglCreateContextAttribsARB != NULL)&&(wglChoosePixelFormatARB!=NULL))
		{
 
 
 
 
 
			*hDC = GetDC(hWnd);
 
 
 
		//	int pixel_format_attribs[] = {
		//WGL_DRAW_TO_WINDOW_ARB,     GL_TRUE,
		//WGL_SUPPORT_OPENGL_ARB,     GL_TRUE,
		//WGL_DOUBLE_BUFFER_ARB,      GL_TRUE,
		//WGL_ACCELERATION_ARB,       WGL_FULL_ACCELERATION_ARB,
		//WGL_PIXEL_TYPE_ARB,         WGL_TYPE_RGBA_ARB,
		//WGL_SAMPLE_BUFFERS_ARB,  GL_TRUE ,
		//WGL_COLOR_BITS_ARB,         32,
		//WGL_DEPTH_BITS_ARB,         24,
		//WGL_STENCIL_BITS_ARB,       8,
		//0,0
		//	};
 
			int pixel_format_attribs[] = {
		 WGL_SUPPORT_OPENGL_ARB, 1,
		WGL_DRAW_TO_WINDOW_ARB, 1,
		/*WGL_DRAW_TO_BITMAP_ARB, 1,*/
		WGL_DOUBLE_BUFFER_ARB, 1,
		//WGL_SWAP_LAYER_BUFFERS_ARB, 1,
		WGL_COLOR_BITS_ARB, 32,
		WGL_RED_BITS_ARB, 8,
		WGL_GREEN_BITS_ARB, 8,
		WGL_BLUE_BITS_ARB, 8,
		WGL_ALPHA_BITS_ARB, 8,
		WGL_DEPTH_BITS_ARB, 8,
		WGL_STENCIL_BITS_ARB, 8,
		WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
		WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
		0
			};
 
			int pixel_format;
			UINT num_formats;
			wglChoosePixelFormatARB(*hDC, pixel_format_attribs, 0, 1, &pixel_format, &num_formats);
			if (!num_formats) {
 				fatal_error("Failed to set the OpenGL 3.3 pixel format.");
			}
 
			PIXELFORMATDESCRIPTOR pfd;
			DescribePixelFormat(*hDC, pixel_format, sizeof(pfd), &pfd);
			if (!SetPixelFormat(*hDC, pixel_format, &pfd)) {
				fatal_error("Failed to set the OpenGL 3.3 pixel format.");
			}
 
 
			// Specify that we want to create an OpenGL 3.3 core profile context
			int gl33_attribs[] = {
				WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
				WGL_CONTEXT_MINOR_VERSION_ARB, 3,
				WGL_CONTEXT_PROFILE_MASK_ARB,  WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
				0,
			};
 
			*hRC = wglCreateContextAttribsARB(*hDC, 0, gl33_attribs);
 
		}
		else
		{
			*hRC = wglCreateContext(*hDC);
			wglMakeCurrent(*hDC, *hRC);
		 }
 
 
	wglMakeCurrent(*hDC, *hRC);
 
 
 
}
#endif
char checkShaderCompilation(GLuint shaderID)
{
	GLint compilationStatus = 0;
 
	// Vérification de la compilation pour le vertex shader
	glGetShaderiv(opengl.vertexID, GL_COMPILE_STATUS, &compilationStatus);
	//if (compilationStatus != GL_TRUE)
	{
		// Nous savons que la compilation a échoué, donc nous devons savoir pourquoi
		// Nous devons récupéré la taille du log
		GLint logLength = 0;
		char* log = NULL;
 
		glGetShaderiv(shaderID, GL_INFO_LOG_LENGTH, &logLength);
		if (logLength > 0)
		{
			// Maintenant que nous avons la taille, nous pouvons alloué la mémoire suffisante pour ce log
			log = (char*)malloc(logLength);
			if (log == NULL)
			{
				fprintf(stderr, "Erreur d'allocation de mémoire pour le log de la compilation du shader\n");
				return 0;
			}
 
			glGetShaderInfoLog(shaderID, logLength, &logLength, log);
 
			// On peut afficher le message
			fprintf(stderr, "Erreur de compilation:\n%s", log);
			MessageBox(NULL, log, NULL, MB_ICONHAND);
			// Et on n'oublie pas de libéré la mémoire
			free(log);
 
			return 0;
		}
		else
			return 1;
	}
 
	return 1; // Pas d'erreur
}
Ca ne marche pas , et j'y suis depuis 3 heures.
Pourtant je ne passe pas à la fonction fatal_error



Pour information je travaille sous Vmware player 17.01 : 17.0.1 build-21139696

Pour conclure ce n'est pas un problème de shader.

Merci