开发者

OpenGL Extensions in Qt 4

开发者 https://www.devze.com 2023-04-09 14:27 出处:网络
it\'s possible enable/us开发者_开发知识库e OpenGL (specific version) in Qt 4 (on Desktop) or I have to use glew, etc?Rather than Glew you can include gl3.h, it\'s probably the simplest and most pain f

it's possible enable/us开发者_开发知识库e OpenGL (specific version) in Qt 4 (on Desktop) or I have to use glew, etc?


Rather than Glew you can include gl3.h, it's probably the simplest and most pain free way and works with compatibility mode as well as core. It's also well worth checking out GLXX it's a newer lib written in C++ so its more object orientated and provides handy functions for querying capabilities and so on.

You could look at manually binding just the extensions you need, possibly making your own Qt classes.

Other alternatives are Glee (A bit out of date now, only up to OpenGL 3.0) and gl3w (a script to generate header files for you, but only seems to support OpenGL 3/4 core).

Also if you want a object orientated library for OpenGL itself OGLplus looks good, doesn't do extensions though.


Qt has wrappers for some extentions like QPixelBuffers otherwise you can just use glew to enable the extentions


My way to do that (Windows)... You need www.opengl.org/registry/api/glext.h

I'm using this python script to generate glex.h (p_glext.h) and glex.cpp from glext.h

p_glext.h is copy of glext.h without prototypes.

//glex.h
#ifndef GLEX_H
#define GLEX_H

#include "p_glext.h"

extern void glexInit();
extern PFNGLBLENDCOLORPROC glBlendColor;
extern PFNGLBLENDEQUATIONPROC glBlendEquation;
extern PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements;
...

//glex.cpp
...
void glexInit() {
    glBlendColor = (PFNGLBLENDCOLORPROC)wglGetProcAddress("glBlendColor");
    glBlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquation");
    glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)wglGetProcAddress("glDrawRangeElements");
...
}

that's simple enough to me

0

精彩评论

暂无评论...
验证码 换一张
取 消