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

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Dernier (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

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