OpenGL Insights 一本不错的新书

OpenGL Insights 是一本汇集了OpenGL、OpenGL ES和WebGL领域经验的书籍,适合中高级开发者。书中通过实际案例展示了OpenGL家族API的当前和新兴技术,涵盖了性能优化、渲染技巧、剖析工具设计等多个方面,帮助读者解决实际问题。随书附带的海报详细描绘了OpenGL管线流程。源码可在GitHub上找到。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

OpenGL Insights

OpenGL, OpenGL ES, and WebGL community experiences


 
Assembling contributions from experienced developers, hardware vendors, researchers, and educators, OpenGL Insights present real-world techniques for intermediate and advanced OpenGL, OpenGL ES, and WebGL developers. Focusing on current and emerging techniques for the OpenGL family of APIs, the book demonstrates the breadth and depth of OpenGL. Readers will gain practical skills to solve problems related to performance, rendering, profiling, framework design, and more. The text is complemented by an enclosed poster detailing the OpenGL pipeline. 





OpenGL
glCreateShaderProgram may provide faster build performance than a sequence of glCompilerShader and glLinkProgram. However, it only creates a single shader stage program.
OpenGL
WebGL
OpenGL ES
Not all shader objects need a main() function. Multiple shader objects can be linked together in the same program to allow sharing the same code between different programs.
OpenGL
WebGL
OpenGL ES
Build all GLSL shaders and programs first, and then query the results to hide build and query latency.
OpenGL
WebGL
OpenGL ES
Call glDeleteShader after attaching a shader to a program to simplify cleanup later.
OpenGLFive OpenGL 4.2 functions generate info logs:
  • glCompileShader
  • glCreateShaderProgram
  • glLinkProgram
  • glValidateProgram
  • glValidateProgramPipeline
OpenGL
OpenGL ES
Functions like glGenTextures do not create an object, they return a name for use with a new object. Objects are typically created with glBind* unless they are based on direct state access, in which case any other function may actually create the object.
OpenGL
WebGL
OpenGL ES
glGenerateMipmap may execute on the CPU, and therefore may be especially slow. Generate mipmaps offline or profile this function.
OpenGL
WebGL
OpenGL ES
When using the default texture scanline alignment, GL_PACK_ALIGNMENT, of four bytes, with glTexImage2D or glTexSubImage2D, the end of each row of pixel data may need to be padded to the next multiple of the alignment.
OpenGLInteger textures, GL_EXT_texture_integer, do not support filtering.
OpenGLA buffer texture is a 1D texture with a buffer object as storage which can only be fetched, not sampled.
OpenGL
WebGL
OpenGL ES
Unmap buffers as soon as possible to allow the driver to start the transfer or to schedule the transfer.
OpenGL
WebGL
OpenGL ES
Use buffer usage flags appropriately: COPY, GL to GL; DRAW, APP to GL; READ, GL to APP; STREAM, update always, DYNAMIC, update often, STATIC, update rarely.
OpenGL
WebGL
OpenGL ES
Set a GLSL sampler uniform to the texture unit number, not the OpenGL texture ID.
OpenGL
WebGL
OpenGL ES
glGetUniformLocation returns −1 but doesn’t generate an error if the uniform name does not correspond to an active uniform. All declared uniforms are not active; uniforms that do not contribute to the shader's output can be optimized out by the compiler.
OpenGLAn OpenGL context must always be current for the duration of OpenGL/compute interoperability.
OpenGLAn OpenGL object should not be accessed by OpenGL while it is mapped for usage within the compute portion.
OpenGL
WebGL
OpenGL ES
Avoid extraneous glBindFramebuffer calls. Use multiple attachments to a FBO rather than managing multiple FBOs.
OpenGL
WebGL
OpenGL ES
FBOs must always be validated before use to ensure that the selected format is renderable.
OpenGLOnly one OpenGL query per query type, e.g., timer or occlusion, can be active at a time.
OpenGLFor occlusion queries, using GL_ANY_SAMPLES_PASSED may be more effective than GL_SAMPLES_PASSED, as a rendering doesn't have to continue as soon as one fragment passed.
OpenGL
WebGL
OpenGL ES
For image-space rendering on GPUs with a large clipping guard band clipping, e.g., GeForce, Radeon, and PowerVR series 6 use a large clipped triangle instead of a quad. Measure both if in doubt.
OpenGL
WebGL
OpenGL ES
To test vertex throughput, do not render to a 1×1 viewport because parallelism is lost; instead, render outside of the view frustum.
OpenGL
WebGL
OpenGL ES
glGetError is particularly slow, especially in multi-process WebGL architectures. Only use it in debug builds or instead use GL_ARB_debug output when available.
OpenGLGeometry shaders are usually output bound so spending ALU time to reduce the amount of data output is a performance win.
WebGLIn addition to #defining GL_OES_standard_derivatives before usingdFdxdFdy, and fwidth, also remember to callcontext.getExtension("OES standard derivatives") in JavaScript.
OpenGL
WebGL
OpenGL ES
To accurately compute the length of a gradient, avoid fwidth(v); instead usesqrt(dFdx(v) * dFdx(v) + dFdy(v) * dFdy(v)).
WebGL
OpenGL ES
highp is only available in fragment shaders ifGL_FRAGMENT_PRECISION_HIGH is #defined. Beware of the performance implications of using highp in vertex or fragment shaders.
OpenGLIn OpenGL, precision qualifiers were reserved in GLSL 1.20 and OpenGL 2.1 but actually introduced with GLSL 1.30 and OpenGL 3.0. From GLSL 1.40 and OpenGL 3.1, and for the purpose of convergence with OpenGL ES 2.0,GL_FRAGMENT_PRECISION_HIGH is defined as 1 in a fragment shader.
OpenGLBy default, precision for vertex, tessellation, and geometry shader stages ishighp for int types, and mediump for the fragment shader stage int types. This may lead to warnings on some implementations. float is always highp by default.
WebGLGiven a WebGL context glgl.TRUE is undefined. When porting OpenGL or OpenGL ES code, do not change GL_TRUE to gl.TRUE because it will silently evaluate to false.
OpenGL
WebGL
OpenGL ES
Depth writes only occur if GL_DEPTH_TEST is enabled.
OpenGL
WebGL
OpenGL ES
The noise functions are still unimplemented in GLSL. Chapter 7 fixes this.
OpenGLgl_VertexID gets values in [first, first+count-1] when generated from a DrawArray* command, and not in [0, count-1]. Especially useful when using a zero input attributes vertex shader.
OpenGLThere are two ways to work with point size: glPointSize in the client-side code or gl_PointSize in the GLSL code if PROGRAM_POINT_SIZE is enabled.


源码地址:https://github.com/OpenGLInsights/OpenGLInsightsCode


---

准备上Amazon买本,不知道要多久才会到

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值