Repository: ManimCommunity/manim

Issue:
Scene selection does not work for the OpenGL renderer
## Description of bug / unexpected behavior
Scene selection seemingly ignores the choice of Scene the user makes when using the OpenGL renderer. For example,

```py
from manim import *

class SphereTest(Scene):
    def construct(self):
        a = Sphere()
        self.play(Create(a))
        self.interactive_embed()

class P(Scene):
    def func(self, u, v):
        return np.array([np.cos(u) * np.cos(v), np.cos(u) * np.sin(v), u])

    def construct(self):
        axes = ThreeDAxes(x_range=[-4,4], x_length=8)
        surface = ParametricSurface(
            lambda u, v: axes.c2p(*self.func(u, v)),
            u_min=-PI,
            u_max=PI,
            v_min=0,
            v_max=TAU,
        )
        # self.set_camera_orientation(theta=70 * DEGREES, phi=75 * DEGREES)
        self.add(axes, surface)
        self.interactive_embed()
```

does correctly bring up the scene selector:

```
C:\Users\Daryl\manim-videos\manim-videos>manim -p --renderer=opengl opengltests.py
Manim Community v0.8.0

1: P
2: SphereTest

Choose number corresponding to desired scene/arguments.
(Use comma separated list for multiple entries)
Choice(s):  2
```

but no matter what scene I choose, it always renders the first scene.


## Expected behavior
<!-- Add a clear and concise description of what you expected to happen. -->


## How to reproduce the issue
<!-- Provide a piece of code illustrating the undesired behavior. -->

<details><summary>Code for reproducing the problem</summary>

```py
Paste your code here.
```

</details>


## Additional media files
<!-- Paste in the files manim produced on rendering the code above. -->

<details><summary>Images/GIFs</summary>

<!-- PASTE MEDIA HERE -->

</details>


## Logs
<details><summary>Terminal output</summary>
<!-- Add "-v DEBUG" when calling manim to generate more detailed logs -->

```
PASTE HERE OR PROVIDE LINK TO https://pastebin.com/ OR SIMILAR
```

<!-- Insert screenshots here (only when absolutely necessary, we prefer copy/pasted output!) -->

</details>


## System specifications

<details><summary>System Details</summary>

- OS (with version, e.g Windows 10 v2004 or macOS 10.15 (Catalina)):
- RAM:
- Python version (`python/py/python3 --version`):
- Installed modules (provide output from `pip list`):
```
PASTE HERE
```
</details>

<details><summary>LaTeX details</summary>

+ LaTeX distribution (e.g. TeX Live 2020):
+ Installed LaTeX packages:
<!-- output of `tlmgr list --only-installed` for TeX Live or a screenshot of the Packages page for MikTeX -->
</details>

<details><summary>FFMPEG</summary>

Output of `ffmpeg -version`:

```
PASTE HERE
```
</details>

## Additional comments
<!-- Add further context that you think might be relevant for this issue here. -->



Discussion:

Resolving patch:
diff --git a/manim/cli/render/commands.py b/manim/cli/render/commands.py
--- a/manim/cli/render/commands.py
+++ b/manim/cli/render/commands.py
@@ -99,21 +99,21 @@ def __repr__(self):
     if config.renderer == "opengl":
         from manim.renderer.opengl_renderer import OpenGLRenderer
 
-        for SceneClass in scene_classes_from_file(file):
-            try:
-                renderer = OpenGLRenderer()
-                while True:
-                    scene_classes = scene_classes_from_file(file)
-                    SceneClass = scene_classes[0]
+        try:
+            renderer = OpenGLRenderer()
+            keep_running = True
+            while keep_running:
+                for SceneClass in scene_classes_from_file(file):
                     scene = SceneClass(renderer)
                     status = scene.render()
                     if status:
                         continue
                     else:
+                        keep_running = False
                         break
-            except Exception:
-                error_console.print_exception()
-                sys.exit(1)
+        except Exception:
+            error_console.print_exception()
+            sys.exit(1)
     elif config.renderer == "webgl":
         try:
             from manim.grpc.impl import frame_server_impl
diff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.py
--- a/manim/scene/scene_file_writer.py
+++ b/manim/scene/scene_file_writer.py
@@ -48,6 +48,8 @@ class SceneFileWriter:
 
     """
 
+    force_output_as_scene_name = False
+
     def __init__(self, renderer, scene_name, **kwargs):
         self.renderer = renderer
         self.stream_lock = False
@@ -74,7 +76,9 @@ def init_output_directories(self, scene_name):
         else:
             module_name = ""
 
-        if config["output_file"] and not config["write_all"]:
+        if SceneFileWriter.force_output_as_scene_name:
+            default_name = Path(scene_name)
+        elif config["output_file"] and not config["write_all"]:
             default_name = config.get_dir("output_file")
         else:
             default_name = Path(scene_name)
diff --git a/manim/utils/module_ops.py b/manim/utils/module_ops.py
--- a/manim/utils/module_ops.py
+++ b/manim/utils/module_ops.py
@@ -8,6 +8,7 @@
 from pathlib import Path
 
 from .. import config, console, constants, logger
+from ..scene.scene_file_writer import SceneFileWriter
 
 
 def get_module(file_name: Path):
@@ -93,7 +94,7 @@ def get_scenes_to_render(scene_classes):
 
 def prompt_user_for_choice(scene_classes):
     num_to_class = {}
-    config["write_all"] = True
+    SceneFileWriter.force_output_as_scene_name = True
     for count, scene_class in enumerate(scene_classes):
         count += 1  # start with 1 instead of 0
         name = scene_class.__name__


Test patch: