|
dev.gamez.lv Latvian Game Developers Community
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
Posted: Wed Aug 24, 2005 11:52 am Post subject: - |
|
Last edited by Guest on Mon Sep 12, 2005 12:58 pm; edited 1 time in total |
|
Back to top |
|
|
bubu Indago Uzvarētājs
Joined: 23 Mar 2004 Posts: 3223 Location: Riga
|
Posted: Wed Aug 24, 2005 12:41 pm Post subject: |
|
Tas saucās Multisample antialiasing:
http://developer.nvidia.com/object/gdc_ogl_multisample.html
Un īsti nesaprotu, kas tev no NeHe koda nepatika. Manuprāt diezgan skaidra procedūra tur gatava ir (ja domā Lesson 46):
(komentārus padzēsu, lai mazāk vietas te kods aizņem)
Code: | #define WGL_SAMPLE_BUFFERS_ARB 0x2041
#define WGL_SAMPLES_ARB 0x2042
bool arbMultisampleSupported = false;
int arbMultisampleFormat = 0;
bool WGLisExtensionSupported(const char *extension) {
const size_t extlen = strlen(extension);
const char *supported = NULL;
PROC wglGetExtString = wglGetProcAddress("wglGetExtensionsStringARB");
if (wglGetExtString) supported = ((char*(__stdcall*)(HDC))wglGetExtString)(wglGetCurrentDC());
if (supported == NULL) supported = (char*)glGetString(GL_EXTENSIONS);
if (supported == NULL) return false;
for (const char* p = supported; ; p++) {
p = strstr(p, extension);
if (p == NULL) return false;
if ((p==supported || p[-1]==' ') && (p[extlen]=='\0' || p[extlen]==' ')) return true;
}
}
bool InitMultisample(HINSTANCE hInstance, HWND hWnd, PIXELFORMATDESCRIPTOR pfd) {
if (!WGLisExtensionSupported("WGL_ARB_multisample")) {
arbMultisampleSupported=false;
return false;
}
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
if (!wglChoosePixelFormatARB) {
arbMultisampleSupported=false;
return false;
}
HDC hDC = GetDC(hWnd);
int pixelFormat;
bool valid;
UINT numFormats;
float fAttributes[] = {0,0};
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, 2, // TE IR TAVS 2x ALIASINGS
0,0};
valid = wglChoosePixelFormatARB(hDC,iAttributes,fAttributes,1,&pixelFormat,&numFormats);
if (valid && numFormats >= 1) {
arbMultisampleSupported = true;
arbMultisampleFormat = pixelFormat;
return arbMultisampleSupported;
}
return arbMultisampleSupported;
} |
Un pie loga veidošanas, kad jau esi uztaisījis savu PIXELFORMATDESCRIPTOR pārbaudi vai mutlisamplošana tiek supportēta, un ja jā tad uztaisi logu par jaunu izmantojot arbMultisampleFormat formātu:
Code: | if (InitMultisample(hInstance, hWnd, pfd)) {
// iznīcini GL logu
// uztaisi jaunu ar arbMultisampleFormat formātu
} |
Pēc tam, renderējot scēnu, jāeneiblo GL_MULTISAMPLE_ARB, kur gribi redzēt to antialiasingu:
Code: | glEnable(GL_MULTISAMPLE_ARB);
// renderēšana
glDisable(GL_MULTISAMPLE_ARB); |
|
|
Back to top |
|
|
Guest
|
Posted: Wed Aug 24, 2005 12:58 pm Post subject: |
|
Last edited by Guest on Mon Sep 12, 2005 12:58 pm; edited 1 time in total |
|
Back to top |
|
|
bubu Indago Uzvarētājs
Joined: 23 Mar 2004 Posts: 3223 Location: Riga
|
Posted: Wed Aug 24, 2005 1:10 pm Post subject: |
|
Tas WGL_SAMPLES_ARB atribūts arī norāda cik tev vajag 2/4/8.
Vien tai spēlei ko mēģināji, varbūt vēl citi parametri ieslēdzās/izslēdzās, tāpēc arī tas vairāk patika. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|