PDA

View Full Version : drawing a line with opengl 3.0



ignorator
06-23-2009, 08:04 AM
hi,

simple question ;)

what is the preferred way drawing a line in an OpenGL 3.0 forward compatible context.

greetings

btw. what about antialiasing

Ilian Dinev
06-23-2009, 11:04 AM
3.0: no wide lines, regular lines are there. VBOs and GL_LINES
3.1: wide lines are back.

Lines get antialiased if you render to a MSAA/CSAA framebuffer. I don't know if antialiasing tricks on non-MSAA buffer via hints is supported.

ignorator
06-23-2009, 02:14 PM
ah ok thx :)

Ilian Dinev
06-24-2009, 08:36 AM
Someone asked how to access GL3.0, then deleted his post.
I will anyway post the code, for anyone to copy:


...
hDC=GetDC(hMain);


GLuint PixelFormat;
PixelFormat=ChoosePixelFormat(hDC,&pfd);

SetPixelFormat(hDC,PixelFormat,&pfd);



hRC=wglCreateContext(hDC);
wglMakeCurrent(hDC,hRC);


PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddre ss("wglCreateContextAttribsARB");
if(!wglCreateContextAttribsARB){
MessageBoxA(0,"OpenGL3.1 not supported or enabled in NVemulate",0,0);
}else{
int attribs[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
WGL_CONTEXT_MINOR_VERSION_ARB, 0,
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB | WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, // not supported by Nvidia on older drivers
0
};

HGLRC gl3Ctx = wglCreateContextAttribsARB(hDC, 0, attribs);
if(gl3Ctx){
wglDeleteContext(hRC);
hRC =gl3Ctx;
wglMakeCurrent(hDC,hRC);
//prints("opengl3 success");
//prints((char*)glGetString(GL_VERSION));
}else{
MessageBoxA(0,"OpenGL3.0 context did not init, staying in 2.1",0,0);
}
}

InitGLExtentions(); // dynamically load gl3.0 funcs via wglGetProcAddress()