【Cherno的OpenGL视频】Welcome to OpenGL

Let’s talk about OpenGL, in this video we’re basically just going to cover what OpenGL actual is? How we can use it? What it can do for us? And what it isn’t?

1、What OpenGL actual is?

First of all, if you’re not sure what OpenGL is, you’re probably relating it to graphics, and that’s exactly what OpenGL is. OpenGL is a graphics API, API stands for application program interface, basically it is a bunch of functions that we can call to do certain things, in this case, since OpenGL is a graphics API, it allows us to do things with graphics and specifically OpenGL allows us to actually access our GPU, our graphics processing unit which is our graphics card, and of course being called the graphics card, it’s pretty good at drawing graphics and so in order to actually utilize this massively powerful graphics processor that we have in either a computer or a device like a phone, we need to actually use some kind of API to get access to that actual hardware, and OpenGL is just one of many apis that actually allows us to access the graphics card and tell it what to do, we have other ones as well such as: Direct3D(Windows专用)、Vulkan(最新一代的)、Metal(苹果专用) and there are a few others as well, so in summary OpenGL allows us to control our graphics card to a certain extent.

2、What OpenGL isn’t?

Let’s clear up some common misconceptions that people seem to have about OpenGL, first of all a lot of people call OpenGL a library or an engine or a framework, it’s none of those things. OpenGL by itself at it’s core is just a specification, it’s kind of like a C++ specification in that regard, it doesn’t actually define any code or anything, it is a specification that lists “hey this function should exist, it should take these parameters and should return this value”, it’s just a specification of what you can do with API, there’s no implementation there whatsoever which means that it’s definitely not a library, bc OpenGL itself there’s no code for it.

3、Where do I download OpenGL?

That’s another really common question and the answer is you don’t really download it, OpenGL itself is again just a specification, so who actually implements it? Who actually writes the code that gets called when you call an OpenGL function and the answer to that is your GPU manufacturer, so if you’re using an NVDIA GPU then your NVDIA drivers are what actually contained the implementation of OpenGL and videos implementation of OpenGL, and every graphics card manufacturer AMD Intel whatever, they’re gonna have their own implementations, and of course NVDIA don’t really have a meeting with AMD and decided “yeah this is how we’re gonna write our code”, that doesn’t happen, so everyone’s implementation of OpenGL is gonna be slightly different which is why in a lot of cases some things may work on NVDIA GPU but the same game might look a little bit different on an AMD GPU or maybe there are bugs stuff like that, but anyway the point is that OpenGL is written by your GPU manufacturer, which probably will lead to the next common misconception about OpenGL, it’s open source, where do people get this stuff? I(Cherno) get that it has a “open” in the name, but OpenGL is not open source at all, you can’t see the code for OpenGL bc first of all it is implemented by the GPU manufacturers, they certainly don’t release their driver source code, there are of course open source implementations of OpenGL, if I create a graphics card and I wanted to support OpenGL I have to write a driver for it, and I may choose to put that on github or whatever and have it be open source, but the implementation that you computer is running probably if you’re using like an NVDIA graphics card or AMD or an Intel card you’re not gonna see the source code behind that implementation. So OpenGL can’t really be open source, first of all bc it’s a specification and no actual source code, second of all, the implementation of OpenGL you’re using is most probably not open source.

4、What it can do for us?

What OpenGL does offer which excites a lot of people and causes a lot of people unfortunately to say “oh OpenGL is so much better than anything else” is bc it’s kind of cross-platform, so what you can do is you can write OpenGL code and that same code will run on Windows Mac Linux IOS Android that kind of stuff, and so people immediately start to think “oh OpenGL is superior to Direct3D bc it runs on all platforms”. No, no, stop saying that please, I just realized that last statement of mine I should probably say since this is the welcome video, this series is kind of gonna be based on my opinion, I’m making these vides so I’m gonna give my opinion and you can choose not to follow, I’m not in any way implying my opinion is fact I’m just saying that from my experience in the industry :working on central technology for EA, specifically game engine technology for EA, and having dealt with many different graphics apis, I’m not the biggest fan of OpenGL and the concept of bc this API is cross-platform it’s kind of the best that doesn’t make sense, Game Engines do not implement a single graphics API that’s not how they work, if game engine’s a cross-platform that is they’re not just made for an XBox or sth, they’re not just made for Windows, they will implement and they have to implement multiple graphics apis bc the fact of the matter is usually the graphics API that is made for that platform, for example Direct3D made for Window by Microsoft it’s gonna be superior to an API this kind of cross-platform, now remember the people actually implementing the code are not Microsoft, Microsoft specifically with Direct3D they actually tend to work with GPU manufacturer to get better code done and stuff like that, but at the end of the day sth like OpenGL is invidious responsibility to implement OpenGL for their drivers, and they screw up it’s kind of on them, but the fact that OpenGL is cross-platform therefore it’s better than Direct3D or better than Metal, that argument really doesn’t make any sense bc usually the thing that’s native to the platform is going to be more powerful and better, that is to say that OpenGL as an actual specification is actually really simple especially when you compare it to sth more low-level like DirectX12 or Vulkan, so in terms of the complexity of OpenGL I think OpenGL is probably (Metal is a little bit lower level than in OpenGL but not quite in Vulkan) the easiest API that you can learn right now, so OpenGL is really definitely worth learning, Valkan which is another one of those cross-platform API is still kind of fresh and raw and the drivers still need to do a bit more work, just last week for example I’ve seen Vulkan restart Android devices bc you pulled sth and it crash, and Valkan is kind of difficult to get into and I would only really advise you get into Valkan if you want to just have fun, play with it or you have to implement it for some reason but overall is I wouldn’t really ship a game on Vulkan just yet if I can avoid it bc sth like OpenGL is gonna be way more stable, anyway my point is that this series is gonna cover OpenGL.

I still think OpenGL is the best graphics API you can use for learning bc it’s just so simple compared to the other ones, it’s a really easy kind of simple one to learn and of course it is also cross-platform, so if you’re not a game studio if you don’t have a team of people making a game engine and you can afford the resourcing for actually implementing, if you don’t have those resources available which most people watching this video probably don’t, then OpenGL is fantastic bc it is simple and cross-platform and it is going to be by far the easiest if you want to ship a game on multiple platforms, so that’s why we’re learning OpenGL bc I do like OpenGL for kind of small personal projects, but obviously if I was a triple ace to Europe working on game engine, this probably be my last choice for an actual graphics API, bc the API first of all isn’t that good, Direct11 is my favourite graphics API in terms of API design, and what ends up happening with OpenGL for a lot of people especially if they’re writing a game engine and a proper graphics rendering engine is they’ll actually tend to basically write a Direct3D kind of wrapper over OpenGL, so in other words, they’ll kind of end up writing a framework which calls OpenGL under the hood but on the actual API for that framework will be very similar to Direct3D bc Direct3D11 specifically, it’s a really good way of creating a graphics API, again my opinion but most people that I’ve talked to in the industry with this 100% agree. So with that aside you now have some answers to some frequently asked, OpenGL is implemented in your graphics drivers and it’s just a specification for allowing us to control the graphics card, now in this series specifically we are going to be dealing with modern OpenGL.

5、Modern OpenGL? Legacy OpenGL?

Now modern OpenGL is sth that you might have heard a lot about as well, this kind of distinction between legacy OpenGL and modern OpenGL, the reason that exists is bc OpenGL was released in the 90s, and back then it was different toward before to what it was now.

Back then GPUs weren’t programmable and flexible I guess, you couldn’t control them anywhere near as much as you can now, especially with these lower-level apis now, people are ultimately giving us so much control, or I should say manufacturera are giving so much control to the programmers and developers which of course is really good, bc we can optimize further for that, but OpenGL right now is a lot more kind of like a circus a low-level law, it gives you a lot more control than it did back then, back then it was like a set of presets so in other words, you basically draw a trangle and then you say “I want lighting”, so how do you add lighting to the trangle? you basically say lighting = true, you enable OpenGL lighting and then you tell OpenGL I want lighting to be here, it’s really is like a set of presets to how do I get my graphics to work, and bc of that legacy OpenGL was really simple to use, the code is quite short but unfortunately with that of course it doesn’t give you as much control and we do want control bc we want to implement some pretty crazy graphics things in this series.

So the biggest distinction between legacy OpenGL and modern OpenGL is shaders, this term “shader” is sth that you might have heard if you were at all interested in graphics, and it might kind of resemble the word “shadow” or “light” like some people can compare it to lighting or sth, forget that, **a shader is a program which runs on the GPU, that’s what a shader is. So if we write code in C++ or Java or C# or whatever language it runs on our CPU, since we’re specifically dealing with graphics for a lot of the time we want to control exactly what the GPU does, and probably move a lot of our code from the CPU to the GPU bc it’s gonna run faster on the GPU, so that’s what shaders come in, shaders just allow us to write code on the GPU, and we definitely want to be doing that in this series, bc if you want to work out some complex lighting algorithms for example you definitely want to be doing that on the GPU instead of on the CPU which you had to do in the past, so programmable shader is the biggest difference between the legacy OpenGL and modern OpenGL, but there are also many other differences as we’ll cover in this series, if you’re looking for modern OpenGL we’re going to conver modern OpenGL, we’re gonna go as modern as we can.

6、

The other improtant thing that I want to mention about this series is that we’re not gonna be making a game engine, we’re not going to be making a graphics engine or a framework or a library or anything like that, we’re gonna be learning OpenGL, I’m actually going to have another series which I hope to start in a few weeks which is going to be how to make a game engine, and in that series we are going to make a full-on game engine the graphics engine and all of that which will implement OpenGL as one of its rendering api, so if you want to see OpenGL in an actual game engine and how that works, then that series is gonna be for you.

But this series we’re actually gonna learn how OpenGL works so that we can write that rendering engine, and that game engine mentioned with OpenGL, and so bc of that in this series we’re not going to be wasting time writing a material system, for example we’re just going to focus on the raw OpenGL code so that I can show you how OpenGL actually works and how you can achieve what you want, and then it’s going to be up to you to actually implement that in your engine or if you don’t know how to do that, and of course my game engine series which will come shortly in the future will cover all that stuff, but this series we’re going to write some raw OpenGL code, we’re probably are gonna write some utility classes like for mass and also like loading shaders or textures and stuff like that, bc it’s a little boilerplate code that can kind of get repeated a lot but when it actually comes time to “let’s render sth on the screen”, that’s going to just be raw OpenGL code, we’re not going to abstract that away at all, we are going to be writing OpenGL in C++, bc in my opinion that’s the best language for the job, it is going to be cross-platform I’m going to try my best to ensure that it is cross-platform, so that anyone can follow along on Mac or Linux as well as Windows, we’re going to be using Windows and Visual Studio bc that is what pretty much everyone in the industry uses, that’s what I’m used to and that’s what I personally believe is the best tool set the best tool chain that you can actually use.

In terms of actual topics that we’re going to be covering for OpenGL we’re going to do 2D graphics and we’re going to do really fast 2D graphics and batching and all that stuff to actually write a very very fast 2D renderer, we’re also going to talk about 3D of course and everything to do with that, and includes some cool things we’re gonna implement lighting of course and shadows and deferred rendering and physically based rendering and any old post-processing stuff like Bloom and sprays based effects, great space ambient occlusion(SAO), and screen space reflections, we’re going to basically do everything that you guys can think of, it should be really exciting to get a set of examples together which you guys can explore and hopefully implement in your own engine or in your own games or anything like that.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值