From native to Web (III), NaCl Study Notes: 3D rendering (DX9 migration to gles)

Source: Internet
Author: User

The 3D rendering API of NaCl uses gles2.0, which is well understood because it is already recognized as a cross-platform standard. Mobile phones, tablets, webpages, and PCs can all be used.

Even on windows, there are some DX9-based gles2.0 implementations, such as angle. sometimes I really want to think that upgrading an operating system version like M $ will eliminate an API. It is better to use the standard library, which also saves the cost of cross-platform porting ~ So what about dx10/dx11?

In fact, from DX9 to gles (all mentioned in this Article refer to version 2.0), most of them are just a different way of writing the API, which is not very difficult. I have previously worked on a simple gles Renderer on a mobile phone. Here are some differences (not limited to NaCl ):

  • Gles does not have a fixed pipeline. Even if you draw a line, you need to write a shader. However, I like this design very much and it is clean.
  • Currently, gles supports a minimum of sm2.0 (usually embedded devices), and most mainstream mobile phones use the sm3.0 standard. therefore, common rendering effects can be achieved, and it is feasible to create a next generation screen.
  • Gles APIs are all C functions. Unlike DX9 APIs, gles APIs are somewhat object-oriented, but they are easy to write code and do not rely on pointers.
  • Because gles is designed for mobile platforms, it has limited features supported by the standard. For example, floattexture, dxtn, bufferlock, and so on are all implemented based on extensions, which is similar to GL.
  • After gles projection, the Z range is [-1, 1]. Pay special attention to this. As for the left-right coordinate system, this is a habit.
  • The alphatest of gles is completed by using discard in the shader, and there is no corresponding rendering status
  • Gles vertexbuffer and indexbuffer have no difference in type, only in usage
  • Gles does not include DX9's annoying devicelost, which is quite good.
  • Gles does not have vertexdeclaration and needs to be managed by itself. It is acceptable, but the worst thing is that there is no semantic in the shader. For details, refer to "viewing the DT glsl".
  • Gles uses the shader glsl syntax. It is worth noting that there is no HLSL to use. Many engines use the hlsl2glsl converter.
  • The shader of gles has a link process, so it does not mean that the shader can be compiled.
  • The shader of gles can specify the precision of floating point numbers. This is more based on the function of the mobile platform.
  • Gles does not have extended libraries such as d3dx, so many libraries such as math, texture loading, and shader management need to be implemented by themselves. but think about it, these things are rarely used in commercial games, and they are all implemented by themselves. the threshold is a little higher than that for beginners. but DX9's com and other things also increase complexity. From this point of view, the two are equal.
  • Support for graphic debugging tools, I have to say that DX9/10/11 has inherent advantages in this aspect...
  • To be supplemented
In comparison, that is, the shader part requires more snacks, and the rest is good. It is even better than dx9. so, I have the impulse to replace DX9 with angle...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.