wglCreateContextAttribsARB ne fonctionne pas
Répondre à la discussion
Affichage des résultats 1 à 2 sur 2

wglCreateContextAttribsARB ne fonctionne pas



  1. #1
    sizy458

    wglCreateContextAttribsARB ne fonctionne pas


    ------

    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:
    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.



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

    Ce n'est pas un probléme de shader.

    Merci

    -----

  2. #2
    umfred

    Re : wglCreateContextAttribsARB ne fonctionne pas

    l'exemple dont tu t'es fortement inspiré (https://gist.github.com/nickrolfe/11...b614a721b3ee9c) fonctionne ?
    rajoute des messages pour savoir ce qui ne marche pas, en fonction des retours des fonctions

Discussions similaires

  1. cpl ne fonctionne pas avec câble mais fonctionne en wireless
    Par Alhec dans le forum Internet - Réseau - Sécurité générale
    Réponses: 1
    Dernier message: 13/03/2019, 20h00
  2. Alimentation PC portable : fonctionne ? fonctionne pas ?
    Par invitef57a974b dans le forum Matériel - Hardware
    Réponses: 9
    Dernier message: 26/07/2012, 06h54
  3. lcd fonctionne // printf ne fonctionne pas
    Par invite60546543 dans le forum Électronique
    Réponses: 12
    Dernier message: 04/07/2011, 22h37
  4. Grand Servomoteur fonctionne pas, alors que petit fonctionne
    Par victorjung dans le forum Électronique
    Réponses: 3
    Dernier message: 04/02/2011, 21h45
  5. mes javascript:popupimage ne fonctionne pas sur mon site web mais fonctionne en local
    Par invite4ff499e4 dans le forum Internet - Réseau - Sécurité générale
    Réponses: 6
    Dernier message: 28/01/2006, 17h31