title: I am having a problem displaying a image in OpenGL
body: <p>I do not fully understand the concept of binding textures in OpenGL, I can't get this to render a jpg image for my project, any insight to what I may be doing wrong?</p>
  
  <pre class="lang-cpp prettyprint-override"><code>// Shader sources
  const GLchar* vertexShaderSource = R"glsl(
  #version 150 core
  in vec2 position;
  in vec3 color;
  in vec2 texcoord;
  out vec3 Color;
  out vec2 Texcoord;
  void main()
  {
      Color = color;
      Texcoord = texcoord;
      gl_Position = vec4(position, 0.0, 1.0);
  }
  )glsl";
  
  const GLchar* fragmentShaderSource = R"glsl(
  #version 150 core
  in vec3 Color;
  in vec2 Texcoord;
  out vec4 outColor;
  uniform sampler2D tex;
  void main()
  {
      outColor = texture(tex, Texcoord) * vec4(Color, 1.0);
  }
  )glsl";
  </code></pre>
  
  <pre class="lang-cpp prettyprint-override"><code>    //creating the window
      GLFWwindow *window= glfwCreateWindow(1200, 700, "NEX_Tests", NULL, NULL);
  
      if(nullptr== window){
          std::cout&lt;&lt;"ERROR HAS OCCURED WHILE LOADING THE WINDOW\n"&lt;&lt;"\n";
          glfwTerminate();
          return -1;
      }
  
      else{
           int screenWidth,screenHeight;
             glfwGetFramebufferSize(window, &amp;screenWidth, &amp;screenHeight);
  
             glfwMakeContextCurrent(window);
  
          glewExperimental=true;
          if(GLEW_OK==!glewInit()){
              std::cout&lt;&lt;"ERROR HAS OCCURED WHILE INITILIZING THE GLEW LIBRARY\n"&lt;&lt;"\n";
              return EXIT_FAILURE;
          }
  
          //set the viewing port
          glViewport(0, 0, screenWidth, screenHeight);
  
          //creating the vetex array object;
          GLuint vao,vbo;
          glGenVertexArrays(1,&amp;vao);
          glGenBuffers(1,&amp;vbo);
  
          glBindVertexArray(vao);
          glBindBuffer(GL_ARRAY_BUFFER,vbo);
          glBufferData(GL_ARRAY_BUFFER,sizeof(vertices),vertices,GL_STATIC_DRAW);
  
          //creating the element buffer
          GLuint ebo;
          glGenBuffers(1,&amp;ebo);
          GLuint elements[]={
              0,1,2,
              2,3,0
          };
  
          glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,ebo);
          glBufferData(GL_ELEMENT_ARRAY_BUFFER,sizeof(elements),elements,GL_STATIC_DRAW);
          std::cout&lt;&lt;vbo&lt;&lt;"\n";
  
          //   glVertexAttribPointer(0,3,GL_FLOAT,GL_FALSE,(3* sizeof(GLfloat)),(GLvoid*)0);
          // glEnableVertexAttribArray(0);
          //glBindBuffer(GL_VERTEX_ARRAY,0);
          // glBindVertexArray(0);
  
  
  
          //creating and linking the shaders
          GLuint vertexShader= glCreateShader(GL_VERTEX_SHADER);
  
          glShaderSource(vertexShader,1,&amp;vertexShaderSource,NULL );
          glCompileShader(vertexShader);
          GLint success;
          GLchar infoLog[512];
  
          glGetShaderiv(vertexShader,GL_COMPILE_STATUS,&amp;success);
          if(!success){
              glGetShaderInfoLog(vertexShader, 512,NULL,infoLog);
              std::cout&lt;&lt;"ERROR HAS OCCURED WHILE COMPILING THE SHADERS\n"&lt;&lt;infoLog&lt;&lt;std::endl;
          }
          GLuint fragmentShader= glCreateShader(GL_FRAGMENT_SHADER);
          glShaderSource(fragmentShader,1,&amp;fragmentShaderSource,NULL);
          glCompileShader(fragmentShader);
  
          glGetShaderiv(fragmentShader,GL_COMPILE_STATUS,&amp;success);
          if(!success){
              glGetShaderInfoLog(fragmentShader,512,NULL,infoLog);
              std::cout&lt;&lt;"ERROR HAS OCCURED WHILE COMPILING THE SHADERS\n"&lt;&lt;infoLog&lt;&lt;std::endl;
          }
          GLuint shaderProgram= glCreateProgram();
          glAttachShader(shaderProgram,vertexShader);
          glAttachShader(shaderProgram,fragmentShader);
          glLinkProgram(shaderProgram);
          glUseProgram(shaderProgram);
  
          glGetProgramiv(shaderProgram,GL_LINK_STATUS,&amp;success);
          if(!success){
              glGetProgramInfoLog(shaderProgram,512,NULL,infoLog);
              std::cout&lt;&lt;"ERROR HAS OCCURED WHILE LINKING THE SHADERS\n"&lt;&lt;infoLog&lt;&lt;std::endl;
          }
           //delete the shaders
          glDeleteShader(vertexShader);
          glDeleteShader(fragmentShader);
  
          //layout of the vertex shader
          GLint posAttrib = glGetAttribLocation(shaderProgram,"position");
          glEnableVertexAttribArray(posAttrib);
          glVertexAttribPointer(posAttrib,0,GL_FLOAT,GL_FALSE,7* sizeof(GLfloat),0);
  
          GLint colAttrib = glGetAttribLocation(shaderProgram,"color");
          glEnableVertexAttribArray(colAttrib);
          glVertexAttribPointer(colAttrib,2,GL_FLOAT,GL_FALSE,7* sizeof(GLfloat),((void*)(2*sizeof(GLfloat))));
  
          GLint TexAttrib= glGetAttribLocation(shaderProgram,"texcoord");
          glEnableVertexAttribArray(TexAttrib);
          glVertexAttribPointer(TexAttrib,2,GL_FLOAT,GL_FALSE,7*sizeof(GLfloat),((void*)(5*sizeof(GLfloat))));
  
          //loading the textures
          GLuint tex;
          glGenTextures(2, &amp;tex);
          glBindTexture(GL_TEXTURE_2D, tex);
          std::cout&lt;&lt;tex&lt;&lt;"\n";
          glActiveTexture(GL_TEXTURE0+ 1);
  
          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);
          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  
  
          //loading the image
          int me=200,me2=300;
          int *width=&amp;me,*height=&amp;me2;
  
          unsigned char* Image= SOIL_load_image("IceKarl.png", width, height, 0, SOIL_LOAD_RGB);
          glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, *width, *height, 0, GL_RGB, GL_UNSIGNED_BYTE, Image);
  
          SOIL_free_image_data(Image);
  
  
          if(!Image){
  
              std::cout&lt;&lt;"ERROR HAS OCCURED WHILE LOADING IN IMAGE\n";
          }
  
          //running loop
          while(!glfwWindowShouldClose(window)){
              glfwPollEvents();
  
              glClearColor(0.0f, 0.00f, 0.00f, 1.0f);
              glClear(GL_COLOR_BUFFER_BIT);
  
              glBindTexture(GL_TEXTURE_2D, 0);
  
              //glDrawArrays(GL_TRIANGLES, 0, 6);
              // glDrawElements(GL_TRIANGLES,6,GL_UNSIGNED_INT,0);
              // glBindTexture(GL_TEXTURE_2D,0);
              glfwSwapBuffers(window);
          }
          glDeleteTextures(1,&amp;tex);
          glDeleteProgram(shaderProgram);
          glDeleteShader(vertexShader);
          glDeleteShader(fragmentShader);
  
          glDeleteBuffers(1,&amp;vbo);
          glDeleteBuffers(1,&amp;ebo);
          glDeleteVertexArrays(1,&amp;vao);
      }
  
      glfwTerminate();
  
      return 0;
  }
  </code></pre>