Published : 010 – WebGL 3D in your Browser

I just published a new Episode in my OpenGL & Vulkan Podcast:

010 – WebGL 3D in your Browser
Basic Information about what WebGL is.

http://opengl-trainer.de/podscats/folgen/010_WebGL_3D_in_your_Browser.mp3

Nice collection of WebGL Demos:
https://www.chromeexperiments.com/webgl

Info on our upcoming Workshop:
http://www.opengl2go.net/workshop_3.php

webgl / html5Find it on iTunes:
https://itunes.apple.com/de/podcast/opengl-vulkan-podcast/id1047136194?l=en

Use RSS Podcast link:
http://opengl-trainer.de/podscats/OpenGL_Vulkan_Podcast.xml

Published : 007 – Shaders in more detail

I just published a new Episode in my OpenGL & Vulkan Podcast:

007 – Shaders in more detail
A closer Look at shaders and how they work.

http://www.opengl-trainer.de/podscats/folgen/007_Shaders_in_more_detail.mp3

Vertex Shader ( simple – passthrough )

  attribute  vec3 v_in_Position;
  uniform    vec3 lightPos;
  varying    vec4 ex_Color;
  void main(void)
  {
      gl_Position = v_in_Position;
  }

Fragment Shader ( simple – all green Pixel )

  precision mediump float;
  uniform    vec3 lightPos;
  varying    vec4 ex_Color; 
  void main(void)
   {
       precision highp float specialVal = 0.0000003453;
       gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
   }

Create Shader Objects

VertexShaderId = glCreateShader( GL_VERTEX_SHADER );
glShaderSource( VertexShaderId, 1, &VertexShader, NULL );
glCompileShader( VertexShaderId ) ;

// check for errors

FragmentShaderId = glCreateShader( GL_FRAGMENT_SHADER );
glShaderSource( FragmentShaderId, 1, &FragmentShader, NULL);
glCompileShader( FragmentShaderId );

Create Programm Object

ProgramId = glCreateProgram();
glAttachShader( ProgramId, VertexShaderId );
glAttachShader( ProgramId, FragmentShaderId );
glLinkProgram( ProgramId );

Get Shader variable Locations

s_vertexLoc   = glGetAttribLocation  ( ProgramId ,”v_in_Position” );
s_colorLoc     = glGetAttribLocation  ( ProgramId , “in_Color” );
s_normalLoc  = glGetAttribLocation  ( ProgramId , “in_normal” );

s_MatrixLoc = glGetUniformLocation ( ProgramId , “pers_Matrix” );
s_lightLoc     = glGetUniformLocation ( ProgramId , “lightPos” );

Prepare for drawing

 glVertexAttribPointer( s_vertexLoc , 3, GL_FLOAT, GL_FALSE, 0, Vertices );
glVertexAttribPointer( s_colorLoc , 4, GL_FLOAT, GL_FALSE, 0, Colors );
glVertexAttribPointer( s_normalLoc , 3, GL_FLOAT, GL_FALSE, 0, Normals );

glUniformMatrix4fv( s_MatrixLoc, 1, GL_FALSE, &modellMatrix );

GLfloat Light[] = { 0.0 , 0.0 , 0.8 };
glUniform3fv( s_lightLoc ,1 , (GLfloat*)&Light );

 

Find it on iTunes:
https://itunes.apple.com/de/podcast/opengl-vulkan-podcast/id1047136194?l=en

Use RSS Podcast link:
http://opengl-trainer.de/podscats/OpenGL_Vulkan_Podcast.xml

Published: 006 – Introduction to Shaders

I just published a new Episode in my OpenGL & Vulkan Podcast:

006 – Introduction to Shaders
A quick Introduction to Shaders and GLSL.

http://www.opengl-trainer.de/podscats/folgen/006_Introduction_to_Shaders.mp3

Vertex Shader ( simple – passthrough )

 1 void main(void)
 2 {
 3     gl_Position = my_in_Vertex;
 4 }

Fragment Shader ( simple – all green Pixel )

 1 void main(void)
 2 {
 3     gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
 4 }

Find it on iTunes:
https://itunes.apple.com/de/podcast/opengl-vulkan-podcast/id1047136194?l=en

Use RSS Podcast link:
http://opengl-trainer.de/podscats/OpenGL_Vulkan_Podcast.xml