• 大小:
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-29
  • 语言: 其他
  • 标签: OpenGL  

资源简介

OpenGL编程指南(原书第9版)内附随书源代码

资源截图

代码片段和文件信息

#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

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件   52659062  2018-02-16 15:50  OpenGL编程指南(第九版英文).pdf

     文件         16  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\.gitignore

     文件        346  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\doublewrite\blit.fs.glsl

     文件         86  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\doublewrite\blit.vs.glsl

     文件        742  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\doublewrite\double_write.fs.glsl

     文件        956  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\doublewrite\double_write.vs.glsl

     文件         91  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\gouraud\gouraud.frag

     文件        185  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\gouraud\gouraud.vert

     文件         95  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\keypress\keypress.frag

     文件        108  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\keypress\keypress.vert

     文件       1335  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\oit\build_lists.fs.glsl

     文件        951  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\oit\build_lists.vs.glsl

     文件       2053  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\oit\resolve_lists.fs.glsl

     文件         86  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\oit\resolve_lists.vs.glsl

     文件        344  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\overdrawcount\blit.fs.glsl

     文件         86  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\overdrawcount\blit.vs.glsl

     文件        531  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\overdrawcount\overdraw_count.fs.glsl

     文件        956  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\overdrawcount\overdraw_count.vs.glsl

     文件        169  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\pointsprites\pointsprites.fs.glsl

     文件        269  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\pointsprites\pointsprites.vs.glsl

     文件        357  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\pointsprites\pointsprites2.fs.glsl

     文件        120  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\primitive_restart\primitive_restart.fs.glsl

     文件        401  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\primitive_restart\primitive_restart.vs.glsl

     文件        856  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\shadowmap\shadowmap_scene.fs.glsl

     文件        704  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\shadowmap\shadowmap_scene.vs.glsl

     文件         96  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\shadowmap\shadowmap_shadow.fs.glsl

     文件        178  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\shadowmap\shadowmap_shadow.vs.glsl

     文件        334  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\simpletess\simple.cont

     文件        715  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\simpletess\simple.eval

     文件        118  2016-09-08 10:19  OGLPG-9th-Edition\OGLPG-9th-Edition\bin\media\shaders\simpletess\simple.frag

............此处省略1156个文件信息

评论

共有 条评论