class_docstr: Generator for the gl2 (desktop) backend.
class_docstr_tok: ["Generator","for","the","gl2","(","desktop",")","backend","."]
code: def _add_function(self, des):
      lines = self.lines
      es2func = des.es2
  
      # Write arg types
      if self.define_argtypes_in_module:
          self._write_argtypes(es2func)
  
      # Get names and types of C-API
      ce_arg_types = [arg.ctype for arg in es2func.args[1:]]
      ce_arg_names = [arg.name for arg in es2func.args[1:]]
      ct_arg_types = [
          KNOWN_TYPES.get(arg.ctype, None) for arg in es2func.args
      ]
      ct_arg_types_easy = [
          EASY_TYPES.get(arg.ctype, None) for arg in es2func.args
      ]
  
      # Write C function signature, for debugging and development
      if self.write_c_sig:
          argnamesstr = ", ".join(
              [
                  c_type + " " + c_name
                  for c_type, c_name in zip(ce_arg_types, ce_arg_names)
              ]
          )
          lines.append(
              "# %s = %s(%s)"
              % (es2func.args[0].ctype, es2func.oname, argnamesstr)
          )
  
      # Write Python function def
      lines.append("def %s(%s):" % (des.apiname, ", ".join(des.args)))
  
      # Construct C function call
      cargs = [arg.name for arg in des.es2.args[1:]]
  
      # Now write the body of the function ...
      if des.ann:
          prefix = "res = "
          # Annotation available
          self.functions_anno.add(des.name)
          callline = self._native_call_line(
              des.name, es2func, prefix=prefix
          )
          lines.extend(des.ann.get_lines(callline, self.backend_name))
  
      elif es2func.group:
          # Group?
          self.functions_todo.add(des.name)
          lines.append("    pass  # todo: Oops. this is a group!")
      elif None in ct_arg_types_easy:
          self.functions_todo.add(des.name)
          lines.append("    pass  # todo: Not all easy types!")
      elif des.args != [arg.name for arg in des.wgl.args[1:]]:
          self.functions_todo.add(des.name)
          lines.append(
              "    pass  # todo: ES 2.0 and WebGL args do not match!"
          )
      else:
          # This one is easy!
          self.functions_auto.add(des.name)
          # Get prefix
          prefix = ""
          if ct_arg_types[0][0] != type(None):
              prefix = "return "
          elif des.es2.shortname.startswith("get"):
              raise RuntimeError("Get func returns void?")
          # Set string
          callline = self._native_call_line(
              des.name, des.es2, prefix=prefix
          )
          lines.append(callline)
  
      if "gl2" in self.__class__.__name__.lower():
          # Post-fix special cases for gl2. See discussion in #201
          # glDepthRangef and glClearDepthf are not always available,
          # and sometimes they do not work if they are
          if es2func.oname in ("glDepthRangef", "glClearDepthf"):
              for i in range(1, 10):
                  line = lines[-i]
                  if not line.strip() or line.startswith("#"):
                      break
                  line = line.replace("c_float", "c_double")
                  line = line.replace("glDepthRangef", "glDepthRange")
                  line = line.replace("glClearDepthf", "glClearDepth")
                  lines[-i] = line
  
imports: from __future__ import annotations
  import os
  import sys
  import headerparser
  from annotations import parse_anotations
  from OpenGL import GL
label_desc: Use image node_id 4 for calling the Gl2ApiGenerator obj's underlying member method code with example usage: obj._add_function(des) without return types