RECHERCHER :
COMMUNAUTE MP
Identifiez vous ...
Devenir Membre
J'ai oublié mon MDP
DOMAINE MP
Bavardages
Langages Généraux
Langages Web
Langages DotNet
Autres langages
Dev. Jeux Video
Sécurité
Sys. Exploitation
Graphismes
Logiciels
Réseaux
Bases de données
Méthodologies
Emplois High-tech
Aide juridique
Articles juridiques
FORUM
Index des forums
Ajouter un sujet
Rechercher sujet
Contact Responsable
Devenir modérateur
CHAT MP IRC
Votre pseudo ...
Srv: irc.moteurprog.com
Chan: #MoteurProg
PARTICIPER
Plus de 3500 emplois.
Rechercher un job
Déposez votre CV
Emplois High-tech

Visiteur MP

 help multisampling

Forum : OPENGL
Sous Catégorie : Aucune
Type du sujet : Sujet Normale
FAQ : FAQ OPENGL

SUIVI DES SUJETS PAR MAIL

SUIVI PAR MAIL INACTIF

RESOLUTION DU SUJET SUJET NON RESOLU
BLOQUAGE DU SUJET SUJET ACTIF
APPARTENANCE A LA FAQ N'APPARTIENT PAS A LA FAQ


POSTER UN NOUVEAU SUJET REPONDRE A CE SUJET

FORUM OPENGL

PREMIERE PAGE

PAGE PRECEDENTE

Page précedente

Page suivante

PAGE SUIVANTE

DERNIERE PAGE
Mehdithe
Nouveau membre
Inscrit : 11/05/2007
Messages : 1
Message
#133199
Posté le 11/05/07 à 08:17
Bonjour à tous,

Voilà je travaille actuellement sur un moteur 3D et j'ai un soucis pour implémenter le multisampling sur le rendu.
Dans ce moteur je créer un contexte bidon au démarrage de la dll du moteur afin de déterminer si le multisampling est ou non supporté par la carte :
//////////////////////////////////////////////////////////////////////////////////////////////
/// CreateWinInfoTest
//////////////////////////////////////////////////////////////////////////////////////////////
void CreateWinInfoTest(int w, int h)
{
MMechostr(1,"---------Fonction Test----------------------\n") ;
ZDetector detect ;
int pf;
HDC hdc;
HWND hwnd;
WNDCLASS wc;

static HINSTANCE hInstance = 0;

/* only register the window class once - use hInstance as a flag. */
if (!hInstance)
{
hInstance = GetModuleHandle(NULL);
wc.style = CS_OWNDC;
wc.lpfnWndProc = (WNDPROC)WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = "OpenGL";

if (!RegisterClass(&wc)) { MMechostr (1,"---Impossible d'enregistrer la classe de fenêtre------\n") ;}

}
//// Création de la fenêtre !!

hwnd = CreateWindow("OpenGL", "OpenGL", WS_OVERLAPPEDWINDOW |
WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
0, 0, w, h, NULL, NULL, hInstance, NULL);

if (hwnd == NULL) { MMechostr(1,"---Impossible de créer la fenêtre---\n") ;}
// Récupération du contexte

hdc = GetDC(hwnd);

if (hdc == NULL) { MMechostr(1,"---Impossible de créer le context---\n") ;}

// Format de pixel


PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
{
sizeof (PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
32, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
1, // Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
16, // 16Bit Z-Buffer (Depth Buffer)
0, // No Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};

pf = ChoosePixelFormat(hdc, &pfd);
if (pf == 0) { MMechostr(1,"---Impossible de choisir le format de pixel----\n") ;}

if (SetPixelFormat(hdc, pf, &pfd) == FALSE) {MMechostr(1,"---Impossible de setter le format de pixel----\n") ;}
hdc = GetDC(hwnd);
HGLRC hglrc = wglCreateContext(hdc);
wglMakeCurrent(hdc, hglrc);

if ( hglrc == NULL ) { MMechostr (1," --------Impossible de définir le redering context-------------\n" ) ;}

MMechostr(1,"--------Création du contexte----------------------\n") ;
// Déclaration du process et vérification multisampling

wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");

// Le multisampling

if (detect.WGLisExtensionSupported("GL_ARB_multisample") == false )
{
arbMultisampleSupported = false ;
MMechostr(1,"---------Le multisampling n'est pas supporté----------------------\n") ;
}
if (detect.WGLisExtensionSupported("GL_ARB_multisample") == true )
{
arbMultisampleSupported = true ;
MMechostr(1,"---------Le multisampling est supporté----------------------\n") ;
}

// Suppression du contexte

if(hglrc)
{
if(wglMakeCurrent(NULL,NULL)==FALSE) MMechostr(1, "------ Can't set the current rendering context to NULL ! ------\n" );

if(wglDeleteContext(hglrc)==FALSE) MMechostr(1, "------ Can't delete the MAIN rendering context ! ------\n" );
else MMechostr(1, "--> mainglrc released : OK\n" );
}

if(hdc)
{
if(ReleaseDC(hwnd, hdc)==0) MMechostr(1, "------ Can't release the MAIN device context ! ------\n" );
else MMechostr(1, "--> mainhdc released : OK\n" );
}

if(hwnd)
{
if(DestroyWindow(hwnd)==0) MMechostr(1, "------ Can't destroy the MAIN window ! ------\n" );
else MMechostr(1, "--> mainhwnd released : OK\n" );
}

hglrc = NULL;
hdc = NULL;
hwnd = NULL;

if(!UnregisterClass("OpenGL", hInstance))
{
MMechostr(1, "----> Could Not Unregister Class !\n");
hInstance=NULL; // Set hInstance To NULL
}
else
MMechostr(1, "--> class scolGL unregistred : OK\n" );

}

///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////


Ensuite, je créer le contexte principal en fonction de l'info renvoyée :

HGLRC CreateMainContext()
{
if (arbMultisampleSupported == false )
{
MMechostr (1,"--------------Le multisampling n'est pas supporté par ta carte--------------\n") ;

HWND hwnd = CreateWindow("scolGL", "scolGL", WS_CHILD, 0, 0, 1, 1, HScol, NULL, NULL, 0);
if ( hwnd == NULL ) { MMechostr(1,"-----Impossible de créer la fenêtre openGL-----\n") ; }
HDC hdc = GetDC(hwnd);
if ( hdc == NULL ) { MMechostr(1,"-------Impossible de créer le handle DC--------\n" ) ; }

// Choix du format de pixel

int pf = 0;

PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
{
sizeof (PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
32, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
1, // Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
16, // 16Bit Z-Buffer (Depth Buffer)
0, // No Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};

pf = ChoosePixelFormat(hdc, &pfd);

SetPixelFormat(hdc, pf, &pfd);

mainglrc = wglCreateContext(hdc);

wglMakeCurrent(hdc,mainglrc);

// Attribution des résultats globaux

mainBPP = 1;
mainDEPTH = pfd.cColorBits;
mainDBLBUF = 1;
mainPIXELFORMAT = pf;
mainhwnd = hwnd ;
mainhdc = hdc;

return mainglrc ;
}

if (arbMultisampleSupported == true )
{
MMechostr (1,"--------------Le multisampling est supporté par ta carte--------------\n") ;

HWND hwnd = CreateWindow("scolGL", "scolGL", WS_CHILD, 0, 0, 1, 1, HScol, NULL, NULL, 0);
if ( hwnd == NULL ) { MMechostr(1,"-----Impossible de créer la fenêtre openGL-----\n") ; }
HDC hdc = GetDC(hwnd);
if ( hdc == NULL ) { MMechostr(1,"-------Impossible de créer le handle DC--------\n" ) ; }

// Choix du format de pixel

MMechostr(1,"-------Debut du choix de pixel pour le multisampling--------\n" ) ;

int pf = 0;
int valid;
UINT numFormats;
float fAttributes[] = {0,0};

// These Attributes Are The Bits We Want To Test For In Our Sample
// Everything Is Pretty Standard, The Only One We Want To
// Really Focus On Is The SAMPLE BUFFERS ARB And WGL SAMPLES
// These Two Are Going To Do The Main Testing For Whether Or Not
// We Support Multisampling On This Hardware.
PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
{
sizeof (PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
32, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
1, // Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
16, // 16Bit Z-Buffer (Depth Buffer)
0, // No Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
// pfd Tells Windows How We Want Things To Be

int iAttributes[] =
{
WGL_DRAW_TO_WINDOW_ARB,GL_TRUE,
WGL_SUPPORT_OPENGL_ARB,GL_TRUE,
WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB,
WGL_COLOR_BITS_ARB,24,
WGL_ALPHA_BITS_ARB,8,
WGL_DEPTH_BITS_ARB,16,
WGL_STENCIL_BITS_ARB,0,
WGL_DOUBLE_BUFFER_ARB,GL_TRUE,
WGL_SAMPLE_BUFFERS_ARB,GL_TRUE,
WGL_SAMPLES_ARB,4,
0,0
};

// First We Check To See If We Can Get A Pixel Format For 4 Samples
valid = wglChoosePixelFormatARB(hdc,iAttributes,fAttributes,1,&pf,&numFormats);
if (valid && numFormats >= 1){ MMechostr(1," ----Le format de pixel pour le multisampling a bien été choisit!!\n") ;}
DescribePixelFormat(hdc, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);

if (SetPixelFormat(hdc, pf, &pfd) ==FALSE) { MMechostr(1," ------Imposible de placer le bon format de pixel-----\n") ;}


mainglrc = wglCreateContext(hdc);
wglMakeCurrent(hdc,mainglrc);

// Attribution des résultats globaux
mainBPP = 1;
mainDEPTH = 16;
mainDBLBUF = 1;
mainPIXELFORMAT = pf;
mainhwnd = hwnd ;
mainhdc = hdc ;

glEnable(GL_MULTISAMPLE_ARB);
glHint(GL_MULTISAMPLE_FILTER_HINT_NV,GL_NICEST);
return mainglrc ;
}

}



Et finalement, j'appelle glEnable(GL_MULTISAMPLE_ARB) à l'initialisation d'OpenGL!

Je me suis inspiré du code NeHe lesson46..
Mon moteur prend bien le bon format de pixel mais le multisampling ne fonctionne pas!!
Si quelqu'un à la moindre idée de ce qui se passe je le remercie d'avance de me répondre au plus vite..

N.B : ma fenêtre openGL de rendu est une fenêtre fille est ce que ça pourrais venir de la?
Bref, je ne sais plus trop quoi faire

HAUT DE PAGE

PROFIL MEMBRE LUI ECRIRE 

Publicité
Inscrit : X
Messages : X
Message
#Aucun

HAUT DE PAGE

  

vortex666
Modérateur :
- C & C++
- OpenGL
- Delphi
Chef de projet(s) :
- Vortez3DEngine

Avatar de vortex666
Inscrit : 20/09/2004
Messages : 490
Message
#134140
Posté le 20/05/07 à 21:19
Voici une fonction pour tester si une extension est supporter:
(dans ton cas -> "GL_ARB_multisample")


//----------------------------------------------------------------------------- // Name : CheckExtension(char *extensionName) // Desc : Check if the extension is supported //----------------------------------------------------------------------------- bool CheckExtension(char *extName) { //Get the list of supported extensions char *extList = (char*) glGetString(GL_EXTENSIONS); //Check if everything's fine... if(!extName || !extList) return false; //Loop throught all extensions while(*extList){ //find the length of the current extension UINT ExtLen = strcspn(extList, " "); //If we've found the extension, return true if(strlen(extName) == ExtLen && strncmp(extName, extList, ExtLen) == 0) return true; //move to the next extension extList += ExtLen + 1; } return false; }


Et voici le code pour verifier si la version est superieur ou egal a celle donner:


//----------------------------------------------------------------------------- // Name : CheckVersion(int MajorVerson, int MinorVersion) // Desc : Check if the version is supported //----------------------------------------------------------------------------- bool CheckVersion(int MajorVerson, int MinorVersion) { //get the list of supported extensions char *Ver = (char*) glGetString(GL_VERSION); //Tell if the given version number is supported return (Ver[0]-48 > MajorVerson || (Ver[0]-48 == MajorVerson && Ver[2]-48 >= MinorVersion)); }


Cela devrais te donner un coup de main.

HAUT DE PAGE

PROFIL MEMBRE LUI ECRIRE 


    PAGE : [1]



.: Site Web développé par Julien Pichot et l'équipe MPWG avec www.evolvia-web.com :.