OpenGL Learning notes-shader creation

Source: Internet
Author: User

1. Create shader Object Gluint glcreateshader (glenum type)

Creates a blank shader object and returns its handle, type Gl_vertex_shader or Gl_fragment_shader

2. Define shader Source code string

void Glshadersource (gluint shader,gluint nstrings,const glchar** source,glint *lenghs)

For example Glshadersource (*shader, sizeof (sources)/sizeof (*sources), sources, nullptr);

If lenghs is nullptr, the individual strings are assumed to end with NULL, and if lengths is not nullptr, it will point to an array containing the string lengths of each corresponding element of strings

3. Compile shader object void Glcompileshader (gluint shader)

4. Create a Program object Gluint Glcreateprogram (), returns a blank program object and returns its handle to which the program object can attach a shader object

5. Attaching Shader objects

void Glattachshader (gluint program,gluint shader)

You can attach a shader object to multiple program objects

6. linker void Gllinkprogram (gluintprogram)

The link operation assigns the position of the consistent variable and resolves the reference between the independently compiled shader objects. If you include Gl_vertex_shader, you create an executable program that will run on a programmable vertex processor, and if you include Gl_fragment_shader, you will create an executable that will run on the chip processor. To keep clean, a useful programming technique is to remove shader objects once they are attached to a program object and then delete them when they are successfully connected, but they are marked as no longer referenced as deleted.

7. Installer object as part of the current render state void Gluseprogram (gluintprogram)


This article from "Progress a little every day" blog, reproduced please contact the author!

OpenGL Learning notes-shader creation

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.