SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Similaire à 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
 

Similaire à 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
 

Dernier

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
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
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 

Dernier (20)

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
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
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 

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