<commit_before>// This file is part of libigl, a simple c++ geometry processing library.
// 
// Copyright (C) 2013 <NAME> <<EMAIL>>
// 
// This Source Code Form is subject to the terms of the Mozilla Public License 
// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
// obtain one at http://mozilla.org/MPL/2.0/.
#include "create_shader_program.h"
#ifndef IGL_NO_OPENGL

#include "load_shader.h"
#include "print_program_info_log.h"
#include <cstdio>

IGL_INLINE bool igl::create_shader_program(
  const std::string & vert_source,
  const std::string & frag_source,
  const std::map<std::string,GLuint> & attrib,
  GLuint & id)
{
  if(vert_source == "" && frag_source == "")
  {
    fprintf(
      stderr,
      "Error: create_shader_program() could not create shader program,"
      " both .vert and .frag source given were empty\n");
    return false;
  }

  // create program
  id = glCreateProgram();
  if(id == 0)
  {
    fprintf(
      stderr,
      "Error: create_shader_program() could not create shader program.\n");
    return false;
  }

  if(vert_source != "")
  {
    // load vertex shader
    GLuint v = igl::load_shader(vert_source.c_str(),GL_VERTEX_SHADER);
    if(v == 0)
    {
      return false;
    }
    glAttachShader(id,v);
  }

  if(frag_source != "")
  {
    // load fragment shader
    GLuint f = igl::load_shader(frag_source.c_str(),GL_FRAGMENT_SHADER);
    if(f == 0)
    {
      return false;
    }
    glAttachShader(id,f);
  }

  // loop over attributes
  for(
    std::map<std::string,GLuint>::const_iterator ait = attrib.begin();<commit_msg>better err msging<commit_after>// This file is part of libigl, a simple c++ geometry processing library.
// 
// Copyright (C) 2013 <NAME> <<EMAIL>>
// 
// This Source Code Form is subject to the terms of the Mozilla Public License 
// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
// obtain one at http://mozilla.org/MPL/2.0/.
#include "create_shader_program.h"
#ifndef IGL_NO_OPENGL

#include "load_shader.h"
#include "print_program_info_log.h"
#include <iostream>
#include <cstdio>

IGL_INLINE bool igl::create_shader_program(
  const std::string & vert_source,
  const std::string & frag_source,
  const std::map<std::string,GLuint> & attrib,
  GLuint & id)
{
  using namespace std;
  if(vert_source == "" && frag_source == "")
  {
    cerr<<
      "create_shader_program() could not create shader program,"
      " both .vert and .frag source given were empty"<<endl;
    return false;
  }

  // create program
  id = glCreateProgram();
  if(id == 0)
  {
    cerr<<"create_shader_program() could not create shader program."<<endl;
    return false;
  }

  if(vert_source != "")
  {
    // load vertex shader
    GLuint v = igl::load_shader(vert_source.c_str(),GL_VERTEX_SHADER);
    if(v == 0)
    {
      cerr<<"vertex shader failed to compile."<<endl;
      return false;
    }
    glAttachShader(id,v);
  }

  if(frag_source != "")
  {
    // load fragment shader
    GLuint f = igl::load_shader(frag_source.c_str(),GL_FRAGMENT_SHADER);
    if(f == 0)
    {
      cerr<<"fragment shader failed to compile."<<endl;
      return false;
    }
    glAttachShader(id,f);
  }

  // loop over attributes
  for(
    std::map<std::string,GLuint>::const_iterator ait = attrib.begin();
{'fraction_non_alphanumeric': 0.13482466747279323, 'fraction_numerical': 0.006650544135429262, 'mean_word_length': 3.1622641509433964, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3089043', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1144, 'n_words': 301}