SlideShare a Scribd company logo
1 of 24
SHADERS:
Releasing the power of the GPU
     (and your creativity)
PART I:
THE SHADER CONCEPT
3D Programming
Rasterization
THE BIRTH OF GPU SHADERS

        1. No special hardware
      2. Hardware acceleration
     3. Programmable Hardware
4. Programmable Hardware Interface
Rasterization (GPU)
PART II:
THE OPENGL SHADER API
How do we make a program?
    1. Enter some text in a file
        2. Compile the file
  3. Check for compilation errors
   4. Link some compiled code
    5. Check for linking errors
      6. Run your program!
How do we make a program?
    1. Enter somewin.cin a file
           1. vim text
      2.2.gcc –Wall thewin.c
           Compile –c file
  3. Check 3. echo $?
            for compilation errors
   4. gcc –Wall win.o iexplore.o
   4. Link some compiled code
    5. Check for linking errors
            5. echo $?
      6. Run your program!
             6. ./a.out
How do we make a program?
      1. Enter somewin.cin a file
          1. 1. vim text
             ShaderSource()
        2.2.gcc –Wall thewin.c
         2. CompileShader()
             Compile –c file
   3. Check 3. echo $?
        3. COMPILE_STATUS
              for compilation errors
  4. 4. gcc –Wall win.o iexplore.o
     4. Link some compiled code
     AttachShader(); LinkProgram()
      5. Check for linking errors
          5. 5. echo $?
              LINK_STATUS
        6. 6. UseProgram()
            Run your program!
               6. ./a.out
• SHADER OBJECT        • PROGRAM OBJECT

• glCreateShader       • glCreateProgram
• glDeleteShader       • glDeleteProgram

• glShaderSource       •   glAttachShader
• glCompileShader      •   glDetachShader
                       •   glLinkProgram
• glIsShader           •   glUseProgram
• glGetShaderiv        •   glValidateProgram
• glGetShaderInfoLog
                       • glIsProgram
                       • glGetProgramiv
                       • glGetProgramInfoLog
#define BUFSZ 1024
#define SHADER_SOURCE = quot;void main (void) { gl_Position = ftransform (); }quot;


GLuint vert;
GLint stat;
char buf[BUFSZ];


vert = glCreateShader (GL_VERTEX_SHADER);
glShaderSource (vert, 1, SHADER_SOURCE, NULL);
glCompileShader (vert);
glGetShaderInfoLog (vert, BUFSZ, NULL, buf);
printf (quot;log: %snquot;, buf);
glGetShaderiv (vert, GL_COMPILE_STATUS, &stat);
printf (quot;compile %snquot;, (stat == GL_TRUE)? quot;okquot;: quot;failedquot;);
glDeleteShader (vert);
#define BUFSZ 1024
GLuint vert, frag, prog;
GLint stat;
char buf[BUFSZ];


vert = my_load_shader (quot;vertex.glslquot;);
frag = my_load_shader (quot;fragment.glslquot;);


prog = glCreateProgram ();
glAttachShader (prog, vert);
glAttachShader (prog, frag);
glLinkProgram (prog);
glGetProgramInfoLog (prog, BUFSZ, NULL, buf);
printf (quot;log: %snquot;, buf);
glGetProgramiv (program, GL_LINK_STATUS, &stat);
printf (quot;link %snquot;, (stat == GL_TRUE)? quot;okquot;: quot;failedquot;);
PART III:
GLSL PROGRAMMING
Vertex Attributes      Uniforms

glVertexAttrib*        glGetUniformLocation
glBindAttribLocation   glUniform*
GLuint prog; GLint texLoc, timeLoc; GLfloat time;
#define WEIGHT_INDEX 1
prog = my_load_prog ();


texLoc = glGetUniformLocation (prog, quot;texquot;); if (texLoc == -1) my_panic ();
timeLoc = glGetUniformLocation (prog, quot;timequot;); if (timeLoc == -1) my_panic ();
glBindAttribLocation (prog, WEIGHT_INDEX, quot;weightquot;);


glUseProgram (prog);
          glUniform1i (texLoc, 0); // USE TEXTURE UNIT 0
          while (not_stop) {
                    time = my_time_update ();
                    glUniform1f (timeLoc, time);
                    my_render_func ();
          }
glUseProgram (0);
LET'S WRITE SHADERS!
THANK YOU!
and enjoy your CG practical

   tom@mimicmedia.nl

More Related Content

Similar to GLSL: Releasing the power of the GPU

Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)Massimo Oliviero
 
Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Tugdual Grall
 
Keyword Driven Testing
Keyword Driven TestingKeyword Driven Testing
Keyword Driven Testinganandarajta
 
Bs webgl소모임004
Bs webgl소모임004Bs webgl소모임004
Bs webgl소모임004Seonki Paik
 
LISA Qooxdoo Tutorial Handouts
LISA Qooxdoo Tutorial HandoutsLISA Qooxdoo Tutorial Handouts
LISA Qooxdoo Tutorial HandoutsTobias Oetiker
 
Even Faster Web Sites at jQuery Conference '09
Even Faster Web Sites at jQuery Conference '09Even Faster Web Sites at jQuery Conference '09
Even Faster Web Sites at jQuery Conference '09Steve Souders
 
Session 40 : SAGA Overview and Introduction
Session 40 : SAGA Overview and Introduction Session 40 : SAGA Overview and Introduction
Session 40 : SAGA Overview and Introduction ISSGC Summer School
 
.gradle 파일 정독해보기
.gradle 파일 정독해보기.gradle 파일 정독해보기
.gradle 파일 정독해보기경주 전
 
Analyzing FreeCAD's Source Code and Its "Sick" Dependencies
Analyzing FreeCAD's Source Code and Its "Sick" DependenciesAnalyzing FreeCAD's Source Code and Its "Sick" Dependencies
Analyzing FreeCAD's Source Code and Its "Sick" DependenciesPVS-Studio
 
Compatibility Detector Tool of Chrome extensions
Compatibility Detector Tool of Chrome extensionsCompatibility Detector Tool of Chrome extensions
Compatibility Detector Tool of Chrome extensionsKai Cui
 
PHP Backdoor: The rise of the vuln
PHP Backdoor: The rise of the vulnPHP Backdoor: The rise of the vuln
PHP Backdoor: The rise of the vulnSandro Zaccarini
 
Adventures in infrastructure as code
Adventures in infrastructure as codeAdventures in infrastructure as code
Adventures in infrastructure as codeJulian Simpson
 
The Dojo Build System
The Dojo Build SystemThe Dojo Build System
The Dojo Build Systemklipstein
 
Developing Web Graphics with WebGL
Developing Web Graphics with WebGLDeveloping Web Graphics with WebGL
Developing Web Graphics with WebGLTony Parisi
 
Grunt & Front-end Workflow
Grunt & Front-end WorkflowGrunt & Front-end Workflow
Grunt & Front-end WorkflowPagepro
 
Mozilla Web Apps - Super-VanJS
Mozilla Web Apps - Super-VanJSMozilla Web Apps - Super-VanJS
Mozilla Web Apps - Super-VanJSRobert Nyman
 
Getting started with open mobile development on the Openmoko platform
Getting started with open mobile development on the Openmoko platformGetting started with open mobile development on the Openmoko platform
Getting started with open mobile development on the Openmoko platformJean-Michel Bouffard
 
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源KAI CHU CHUNG
 

Similar to GLSL: Releasing the power of the GPU (20)

Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)
 
Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Scripting Oracle Develop 2007
Scripting Oracle Develop 2007
 
Keyword Driven Testing
Keyword Driven TestingKeyword Driven Testing
Keyword Driven Testing
 
Bs webgl소모임004
Bs webgl소모임004Bs webgl소모임004
Bs webgl소모임004
 
LISA Qooxdoo Tutorial Handouts
LISA Qooxdoo Tutorial HandoutsLISA Qooxdoo Tutorial Handouts
LISA Qooxdoo Tutorial Handouts
 
Even Faster Web Sites at jQuery Conference '09
Even Faster Web Sites at jQuery Conference '09Even Faster Web Sites at jQuery Conference '09
Even Faster Web Sites at jQuery Conference '09
 
Session 40 : SAGA Overview and Introduction
Session 40 : SAGA Overview and Introduction Session 40 : SAGA Overview and Introduction
Session 40 : SAGA Overview and Introduction
 
.gradle 파일 정독해보기
.gradle 파일 정독해보기.gradle 파일 정독해보기
.gradle 파일 정독해보기
 
Analyzing FreeCAD's Source Code and Its "Sick" Dependencies
Analyzing FreeCAD's Source Code and Its "Sick" DependenciesAnalyzing FreeCAD's Source Code and Its "Sick" Dependencies
Analyzing FreeCAD's Source Code and Its "Sick" Dependencies
 
Compatibility Detector Tool of Chrome extensions
Compatibility Detector Tool of Chrome extensionsCompatibility Detector Tool of Chrome extensions
Compatibility Detector Tool of Chrome extensions
 
PHP Backdoor: The rise of the vuln
PHP Backdoor: The rise of the vulnPHP Backdoor: The rise of the vuln
PHP Backdoor: The rise of the vuln
 
Adventures in infrastructure as code
Adventures in infrastructure as codeAdventures in infrastructure as code
Adventures in infrastructure as code
 
GWT
GWTGWT
GWT
 
The Dojo Build System
The Dojo Build SystemThe Dojo Build System
The Dojo Build System
 
Developing Web Graphics with WebGL
Developing Web Graphics with WebGLDeveloping Web Graphics with WebGL
Developing Web Graphics with WebGL
 
Grunt & Front-end Workflow
Grunt & Front-end WorkflowGrunt & Front-end Workflow
Grunt & Front-end Workflow
 
Mozilla Web Apps - Super-VanJS
Mozilla Web Apps - Super-VanJSMozilla Web Apps - Super-VanJS
Mozilla Web Apps - Super-VanJS
 
Getting started with open mobile development on the Openmoko platform
Getting started with open mobile development on the Openmoko platformGetting started with open mobile development on the Openmoko platform
Getting started with open mobile development on the Openmoko platform
 
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
 
All things that are not code
All things that are not codeAll things that are not code
All things that are not code
 

Recently uploaded

Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 

Recently uploaded (20)

Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 

GLSL: Releasing the power of the GPU

  • 1. SHADERS: Releasing the power of the GPU (and your creativity)
  • 5. THE BIRTH OF GPU SHADERS 1. No special hardware 2. Hardware acceleration 3. Programmable Hardware 4. Programmable Hardware Interface
  • 7. PART II: THE OPENGL SHADER API
  • 8. How do we make a program? 1. Enter some text in a file 2. Compile the file 3. Check for compilation errors 4. Link some compiled code 5. Check for linking errors 6. Run your program!
  • 9. How do we make a program? 1. Enter somewin.cin a file 1. vim text 2.2.gcc –Wall thewin.c Compile –c file 3. Check 3. echo $? for compilation errors 4. gcc –Wall win.o iexplore.o 4. Link some compiled code 5. Check for linking errors 5. echo $? 6. Run your program! 6. ./a.out
  • 10. How do we make a program? 1. Enter somewin.cin a file 1. 1. vim text ShaderSource() 2.2.gcc –Wall thewin.c 2. CompileShader() Compile –c file 3. Check 3. echo $? 3. COMPILE_STATUS for compilation errors 4. 4. gcc –Wall win.o iexplore.o 4. Link some compiled code AttachShader(); LinkProgram() 5. Check for linking errors 5. 5. echo $? LINK_STATUS 6. 6. UseProgram() Run your program! 6. ./a.out
  • 11. • SHADER OBJECT • PROGRAM OBJECT • glCreateShader • glCreateProgram • glDeleteShader • glDeleteProgram • glShaderSource • glAttachShader • glCompileShader • glDetachShader • glLinkProgram • glIsShader • glUseProgram • glGetShaderiv • glValidateProgram • glGetShaderInfoLog • glIsProgram • glGetProgramiv • glGetProgramInfoLog
  • 12. #define BUFSZ 1024 #define SHADER_SOURCE = quot;void main (void) { gl_Position = ftransform (); }quot; GLuint vert; GLint stat; char buf[BUFSZ]; vert = glCreateShader (GL_VERTEX_SHADER); glShaderSource (vert, 1, SHADER_SOURCE, NULL); glCompileShader (vert); glGetShaderInfoLog (vert, BUFSZ, NULL, buf); printf (quot;log: %snquot;, buf); glGetShaderiv (vert, GL_COMPILE_STATUS, &stat); printf (quot;compile %snquot;, (stat == GL_TRUE)? quot;okquot;: quot;failedquot;); glDeleteShader (vert);
  • 13. #define BUFSZ 1024 GLuint vert, frag, prog; GLint stat; char buf[BUFSZ]; vert = my_load_shader (quot;vertex.glslquot;); frag = my_load_shader (quot;fragment.glslquot;); prog = glCreateProgram (); glAttachShader (prog, vert); glAttachShader (prog, frag); glLinkProgram (prog); glGetProgramInfoLog (prog, BUFSZ, NULL, buf); printf (quot;log: %snquot;, buf); glGetProgramiv (program, GL_LINK_STATUS, &stat); printf (quot;link %snquot;, (stat == GL_TRUE)? quot;okquot;: quot;failedquot;);
  • 15.
  • 16.
  • 17. Vertex Attributes Uniforms glVertexAttrib* glGetUniformLocation glBindAttribLocation glUniform*
  • 18. GLuint prog; GLint texLoc, timeLoc; GLfloat time; #define WEIGHT_INDEX 1 prog = my_load_prog (); texLoc = glGetUniformLocation (prog, quot;texquot;); if (texLoc == -1) my_panic (); timeLoc = glGetUniformLocation (prog, quot;timequot;); if (timeLoc == -1) my_panic (); glBindAttribLocation (prog, WEIGHT_INDEX, quot;weightquot;); glUseProgram (prog); glUniform1i (texLoc, 0); // USE TEXTURE UNIT 0 while (not_stop) { time = my_time_update (); glUniform1f (timeLoc, time); my_render_func (); } glUseProgram (0);
  • 20.
  • 21.
  • 22.
  • 23.
  • 24. THANK YOU! and enjoy your CG practical tom@mimicmedia.nl