Call GetGlobalContext instead of GetValidGlobalContext for gl::GetError

If the context is lost due to an OUT_OF_MEMORY error, it was
impossible to check the error.

BUG=angleproject:1309

Change-Id: I50fbd46b139d44774dde804445f12b8d34d73e29
Reviewed-on: https://chromium-review.googlesource.com/521203
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
diff --git a/scripts/generate_entry_points.py b/scripts/generate_entry_points.py
index 875b0bd..98df261 100644
--- a/scripts/generate_entry_points.py
+++ b/scripts/generate_entry_points.py
@@ -95,7 +95,7 @@
 {{
     EVENT("({format_params})"{comma_if_needed}{pass_params});
 
-    Context *context = GetValidGlobalContext();
+    Context *context = {context_getter}();
     if (context)
     {{
         context->gatherParams<EntryPoint::{name}>({pass_params});
@@ -160,6 +160,12 @@
     else:
         print(return_type)
 
+def get_context_getter_function(cmd_name):
+    if cmd_name == "glGetError":
+        return "GetGlobalContext"
+    else:
+        return "GetValidGlobalContext"
+
 def format_entry_point_def(cmd_name, proto, params):
     pass_params = [just_the_name(param) for param in params]
     format_params = [param_format_string(param) for param in params]
@@ -175,7 +181,8 @@
         validate_params = ", ".join(["context"] + pass_params),
         format_params = ", ".join(format_params),
         return_if_needed = "" if default_return == "" else "return ",
-        default_return_if_needed = "" if default_return == "" else "\n    return " + default_return + ";\n")
+        default_return_if_needed = "" if default_return == "" else "\n    return " + default_return + ";\n",
+        context_getter = get_context_getter_function(cmd_name))
 
 for cmd_name in gles2_commands:
     command_xpath = "command/proto[name='" + cmd_name + "']/.."
@@ -227,4 +234,4 @@
 
 with open(entry_points_enum_header_path, "w") as out:
     out.write(entry_points_enum)
-    out.close()
\ No newline at end of file
+    out.close()