Results 1 to 4 of 4

Thread: drawing a line with opengl 3.0

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    2

    drawing a line with opengl 3.0

    hi,

    simple question

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

    greetings

    btw. what about antialiasing

  2. #2
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,294

    Re: drawing a line with opengl 3.0

    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.

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    2

    Re: drawing a line with opengl 3.0

    ah ok thx

  4. #4
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,294

    Re: drawing a line with opengl 3.0

    Someone asked how to access GL3.0, then deleted his post.
    I will anyway post the code, for anyone to copy:
    Code :
    	...	
    	hDC=GetDC(hMain);
     
     
    	GLuint		PixelFormat;
    	PixelFormat=ChoosePixelFormat(hDC,&pfd);
     
    	SetPixelFormat(hDC,PixelFormat,&pfd);
     
     
     
    	hRC=wglCreateContext(hDC);
    	wglMakeCurrent(hDC,hRC);
     
     
    	PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("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()

Similar Threads

  1. Issues drawing a line in openGL
    By redalwaysmafia in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 09-06-2015, 05:20 PM
  2. drawing antialiased line on OpenGL ES 2
    By guihazan in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-25-2012, 05:00 AM
  3. Drawing Progressive line in OpenGL
    By SandeepK in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-17-2009, 12:29 AM
  4. Drawing 2D and 3D line graphs using OPENGL and C++
    By SheOracle in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-07-2005, 10:34 PM
  5. OpenGL Raster line drawing
    By jgrashow in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-05-2001, 10:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean