• 大小: 1.9MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-08-11
  • 语言: 其他
  • 标签: OpenGL  VS2017  

资源简介

OpenGL环境配置全文件,与博客教程:OpenGL红宝书第九版环境配置(VS2017)相配套

资源截图

代码片段和文件信息

#include 

#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN 1
#include 

static HMODULE libgl;

static void open_libgl(void)
{
libgl = LoadLibraryA(“opengl32.dll“);
}

static void close_libgl(void)
{
FreeLibrary(libgl);
}

static GL3WglProc get_proc(const char *proc)
{
GL3WglProc res;

res = (GL3WglProc) wglGetProcAddress(proc);
if (!res)
res = (GL3WglProc) GetProcAddress(libgl proc);
return res;
}
#elif defined(__APPLE__) || defined(__APPLE_CC__)
#include 

CFBundleRef bundle;
CFURLRef bundleURL;

static void open_libgl(void)
{
bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault
CFSTR(“/System/Library/frameworks/OpenGL.framework“)
kCFURLPOSIXPathstyle true);

bundle = CFBundleCreate(kCFAllocatorDefault bundleURL);
assert(bundle != NULL);
}

static void close_libgl(void)
{
CFRelease(bundle);
CFRelease(bundleURL);
}

static GL3WglProc get_proc(const char *proc)
{
GL3WglProc res;

CFStringRef procname = CFStringCreateWithCString(kCFAllocatorDefault proc
kCFStringEncodingASCII);
res = (GL3WglProc) CFBundleGetFunctionPointerForName(bundle procname);
CFRelease(procname);
return res;
}
#else
#include 
#include 

static void *libgl;

static void open_libgl(void)
{
libgl = dlopen(“libGL.so.1“ RTLD_LAZY | RTLD_GLOBAL);
}

static void close_libgl(void)
{
dlclose(libgl);
}

static GL3WglProc get_proc(const char *proc)
{
GL3WglProc res;

res = (GL3WglProc) glXGetProcAddress((const GLubyte *) proc);
if (!res)
res = (GL3WglProc) dlsym(libgl proc);
return res;
}
#endif

static struct {
int major minor;
} version;

static int parse_version(void)
{
if (!glGetIntegerv)
return -1;

glGetIntegerv(GL_MAJOR_VERSION &version.major);
glGetIntegerv(GL_MINOR_VERSION &version.minor);

if (version.major < 3)
return -1;
return 0;
}

static void load_procs(void);

int gl3wInit(void)
{
open_libgl();
load_procs();
close_libgl();
return parse_version();
}

int gl3wIsSupported(int major int minor)
{
if (major < 3)
return 0;
if (version.major == major)
return version.minor >= minor;
return version.major >= major;
}

GL3WglProc gl3wGetProcAddress(const char *proc)
{
return get_proc(proc);
}

PFNGLCULLFACEPROC gl3wCullFace;
PFNGLFRONTFACEPROC gl3wFrontFace;
PFNGLHINTPROC gl3wHint;
PFNGLLINEWIDTHPROC gl3wLineWidth;
PFNGLPOINTSIZEPROC gl3wPointSize;
PFNGLPOLYGONMODEPROC gl3wPolygonMode;
PFNGLSCISSORPROC gl3wScissor;
PFNGLTEXPARAMETERFPROC gl3wTexParameterf;
PFNGLTEXPARAMETERFVPROC gl3wTexParameterfv;
PFNGLTEXPARAMETERIPROC gl3wTexParameteri;
PFNGLTEXPARAMETERIVPROC gl3wTexParameteriv;
PFNGLTEXIMAGE1DPROC gl3wTexImage1D;
PFNGLTEXIMAGE2DPROC gl3wTexImage2D;
PFNGLDRAWBUFFERPROC gl3wDrawBuffer;
PFNGLCLEARPROC gl3wClear;
PFNGLCLEARCOLORPROC gl3wClearColor;
PFNGLCLEARSTENCILPROC gl3wClearStencil;
PFNGLCLEARDEPTHPROC gl3wClearDepth;
PFNGLSTENCILMASKPROC gl3wStencilMask;
PFNGLCOLORMASKPROC gl3wColorMask;
PFNGLDEPTHMASKPROC gl3wDepthMask;
PFNGLDISABLEPROC gl3wDisabl

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-12-02 22:05  OGLPG-9th-Edition\
     目录           0  2018-12-02 22:05  OGLPG-9th-Edition\OGLPG-9th-Edition\
     文件          16  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\.gitignore
     文件        2941  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\CMakeLists.txt
     文件        2076  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\README.md
     目录           0  2018-12-02 22:05  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\
     目录           0  2018-12-02 22:05  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\
     目录           0  2018-12-02 22:05  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\
     目录           0  2018-12-02 22:05  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\doublewrite\
     文件         346  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\doublewrite\blit.fs.glsl
     文件          86  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\doublewrite\blit.vs.glsl
     文件         742  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\doublewrite\double_write.fs.glsl
     文件         956  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\doublewrite\double_write.vs.glsl
     目录           0  2018-12-02 22:05  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\gouraud\
     文件          91  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\gouraud\gouraud.frag
     文件         185  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\gouraud\gouraud.vert
     目录           0  2018-12-02 22:05  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\keypress\
     文件          95  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\keypress\keypress.frag
     文件         108  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\keypress\keypress.vert
     目录           0  2018-12-02 22:05  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\oit\
     文件        1335  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\oit\build_lists.fs.glsl
     文件         951  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\oit\build_lists.vs.glsl
     文件        2053  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\oit\resolve_lists.fs.glsl
     文件          86  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\oit\resolve_lists.vs.glsl
     目录           0  2018-12-02 22:05  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\overdrawcount\
     文件         344  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\overdrawcount\blit.fs.glsl
     文件          86  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\overdrawcount\blit.vs.glsl
     文件         531  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\overdrawcount\overdraw_count.fs.glsl
     文件         956  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\overdrawcount\overdraw_count.vs.glsl
     目录           0  2018-12-02 22:05  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\pointsprites\
     文件         169  2016-09-09 01:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\pointsprites\pointsprites.fs.glsl
............此处省略1162个文件信息

评论

共有 条评论