TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

PortableGL: An implementation of OpenGL 3.x-ish in clean C

185 点作者 kk6mrp超过 3 年前

9 条评论

mnurzia超过 3 年前
Not entirely related to the subject of OpenGL, but I really like how the author has decided to lay out this project. It&#x27;s pretty hard to beat the convenience of a single header (or single header&#x2F;single source) distribution for C libraries, but library development gets progressively harder as the project gets bigger as more code is added to the (usually hard to navigate) header file. Here, the author does their development with multiple files as one normally would, but when a new version is released they run the generate_gl_h[1] script that concatenates everything into a .h file for distribution. Simple yet flexible! This is also how SQLite[2] distributes its builds. It&#x27;s a pattern that I&#x27;m using myself in some unreleased projects.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;rswinkle&#x2F;PortableGL&#x2F;blob&#x2F;master&#x2F;src&#x2F;generate_gl_h.py" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rswinkle&#x2F;PortableGL&#x2F;blob&#x2F;master&#x2F;src&#x2F;gener...</a> [2] <a href="https:&#x2F;&#x2F;www.sqlite.org&#x2F;amalgamation.html" rel="nofollow">https:&#x2F;&#x2F;www.sqlite.org&#x2F;amalgamation.html</a>
评论 #29746101 未加载
评论 #29745376 未加载
wk_end超过 3 年前
So reading this:<p>&gt; [Vulkan] really is overkill for learning 3D graphics...using modern OpenGL to introduce all the standard concepts, vertices, triangles, textures, shaders, fragments&#x2F;pixels, the transformation pipeline etc. first is much better than trying to teach them Vulkan and graphics at the same time...<p>...got me wondering. I haven&#x27;t really kept up with modern graphics programming, but my - possibly incorrect - understanding was that not only is Vulkan lower-level than OpenGL, it was also motivated by lots of questionable design decisions that OpenGL was kind of stuck with. So, with the above quote in mind, is it the case that:<p>* Vulkan is good (?) but too low-level for most users.<p>* OpenGL is a good environment to learn or do nuts &amp; bolts 3D programming in - i.e. it&#x27;s the right level of abstraction for that - but is kind of a mess.<p>Is that correct? Is there anything that splits the difference? How&#x27;s Direct3D these days? Metal? Has anyone built a library on top of Vulkan, targeted roughly around the abstraction level of OpenGL, but with a better design?
评论 #29745670 未加载
评论 #29745493 未加载
评论 #29745612 未加载
评论 #29745411 未加载
评论 #29749058 未加载
oso2k超过 3 年前
Fabrice Bellard released an OpenGL 1.x&#x2F;2.x software renderer 20 years ago [0]. There seems to others who have taken to updating it more recently [1][2]. It is direct mode or immediate mode but this is how we used to do graphics more than 15 years ago. Might help others to read this if you&#x27;re interested.<p>[0] <a href="https:&#x2F;&#x2F;bellard.org&#x2F;TinyGL&#x2F;" rel="nofollow">https:&#x2F;&#x2F;bellard.org&#x2F;TinyGL&#x2F;</a><p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;C-Chads&#x2F;tinygl" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;C-Chads&#x2F;tinygl</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;ska80&#x2F;tinygl" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ska80&#x2F;tinygl</a>
samwisehamgee超过 3 年前
&gt; I took a 400 level 3D Graphics course in college in fall 2010 months after OpenGL 3.3&#x2F;4.0 was released. It was taught based on the original Red Book using OpenGL 1.1. Fortunately, the professor let me use OpenGL 3.3 as long as I met the assignment requirements. Sadly, college graphics professors still teach 1.x and 2.x OpenGL today in 2020<p>This one hits home. I did my first (and only) graphics programming in college in 2019 and it was indeed OpenGL 1.1 to make matters even more stupid, it was a course where the opengl part was only half the course, the other half was about image processing using matlab...<p>I dont know what it is about graphics programming, I&#x27;ve tried many times to learn it but its so different to any of the other programming I&#x27;ve done that it feels totally impenetrable.
评论 #29747509 未加载
ReactiveJelly超过 3 年前
&gt; Using modern OpenGL to introduce all the standard concepts ... is much better than trying to teach them Vulkan ... and obviously better than teaching OpenGL API&#x27;s that are decades old.<p>I disagree on teaching old APIs. This is a pet peeve of mine, and I thought the author of a software rasterizer would agree with me.<p>GPU APIs are some of the only APIs where you have to pay to upgrade. Sure, Vulkan has been &quot;out&quot; for 4 years. But I haven&#x27;t bought any hardware that supports Vulkan. My last purchase was a used laptop with an iGPU. I buy hardware as a last resort when I absolutely need it, I especially don&#x27;t buy hardware for the APIs when my old hardware has enough GFLOPS.<p>I like that programming is a cheap hobby. I don&#x27;t see the point in anteing up every few years. Per-core CPU power has plateaued, and I can add more storage to old systems easily. I just don&#x27;t want to buy new hardware until I see the GPU space settle down for a few years. And when will that happen? Vulkan 2? Vulkan 3?<p>How many more perfectly functional TFLOPS of GPU chips will be branded e-waste before the APIs are stable? I don&#x27;t like the implication among some gamedevs that your programming skill depends on how much tribute you&#x27;ve paid to NVidia. I don&#x27;t make bad games because I use GLES 2, I make bad games because I&#x27;m a bad gamedev.<p>GLES 2 is a sweet spot in the tradeoff between compatibility and features. It dates to about 2007, so even a kid with a cheap used Android phone could theoretically write GLES 2 code for it. It doesn&#x27;t have geometry shaders, but with vertex and fragment shaders you can still learn things like environment mapping, gamma-correct per-pixel lighting, hardware skinning, post-processing effects, etc.<p>It just works, almost everywhere, and I don&#x27;t see the point in writing off old hardware as trash before the end of its natural life.
评论 #29751378 未加载
评论 #29750231 未加载
dimatura超过 3 年前
This is pretty cool, I&#x27;ve looked for libraries like this myself in the past. Sometimes I&#x27;ve needed to render a bunch of simple 3D graphics off-screen, without any real-time or high-throughput requirements (mostly for visualizing 3D stuff in robotics&#x2F;computer vision). Setting up GPU-based pipelines for this is possible, but can be kind of kludgy and annoying. Mesa3D can do opengl software rasterization, but it&#x27;s also a nontrivial dependency. I&#x27;ve ended up writing crappy rasterizers in the past just to avoid all that hassle. A single-header solution for this that&#x27;s more up-to-date than TinyGL is welcome.
dlsa超过 3 年前
Aside about that README file: its laid out better than plenty of research papers I&#x27;ve been reading lately and the professors who ostensibly wrote those papers should know better. Kudos just for that.
评论 #29756331 未加载
Shadonototra超过 3 年前
that&#x27;s pretty nice!<p>any plan for GLES 3.0? something that would allow to target WASM too
评论 #29751600 未加载
blondin超过 3 年前
isn&#x27;t opengl3 not recommended anymore?
评论 #29747552 未加载