This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository direct3d.

View the commit online.

commit 2d51fb5a5889819fe646214ad5cb6ce2c7371863
Author: Vincent Torri <vto...@outlook.fr>
AuthorDate: Wed Jul 20 08:04:58 2022 +0200

    add stub scene functions, refactor D3D pipeline
---
 src/d3d_0.c |  9 +++++++++
 src/d3d_1.c | 45 +++++++++++++++++++++++++++++++++++----------
 src/win.c   |  3 +++
 src/win.h   |  4 ++++
 4 files changed, 51 insertions(+), 10 deletions(-)

diff --git a/src/d3d_0.c b/src/d3d_0.c
index 25b42fe..074fe12 100644
--- a/src/d3d_0.c
+++ b/src/d3d_0.c
@@ -52,6 +52,15 @@ void d3d_shutdown(D3d *d3d)
     free(d3d);
 }
 
+void d3d_scene_begin(D3d *d3d)
+{
+    (void)d3d;
+}
+
+void d3d_scene_end(void)
+{
+}
+
 void d3d_resize(D3d *d3d, int rot, UINT width, UINT height)
 {
     (void)d3d;
diff --git a/src/d3d_1.c b/src/d3d_1.c
index b141fd9..fd24755 100644
--- a/src/d3d_1.c
+++ b/src/d3d_1.c
@@ -186,8 +186,6 @@ D3d *d3d_init(Window *win, int vsync)
      * the image format
      * the number of back buffers (>= 2 for flip model, see SwapEffect field)
      * vsync enabled: need refresh rate
-     *
-     * Settings are different in win 7 and win10
      */
 
     d3d_refresh_rate_get(d3d, &num, &den);
@@ -347,6 +345,11 @@ void d3d_resize(D3d *d3d, int rot, UINT width, UINT height)
 
     ID3D11Texture2D_Release(back_buffer);
 
+    /* update the pipeline with the new render target view */
+    ID3D11DeviceContext_OMSetRenderTargets(d3d->d3d_device_ctx,
+                                           1U, &d3d->d3d_render_target_view,
+                                           NULL);
+
     /* set viewport, depends on size of the window */
     d3d->viewport.TopLeftX = 0.0f;
     d3d->viewport.TopLeftY = 0.0f;
@@ -354,6 +357,19 @@ void d3d_resize(D3d *d3d, int rot, UINT width, UINT height)
     d3d->viewport.Height = (float)height;
     d3d->viewport.MinDepth = 0.0f;
     d3d->viewport.MaxDepth = 1.0f;
+
+    /* update the pipeline with the new viewport */
+    ID3D11DeviceContext_RSSetViewports(d3d->d3d_device_ctx,
+                                       1U, &d3d->viewport);
+}
+
+void d3d_scene_begin(D3d *d3d)
+{
+    (void)d3d;
+}
+
+void d3d_scene_end(void)
+{
 }
 
 void d3d_render(D3d *d3d)
@@ -369,19 +385,28 @@ void d3d_render(D3d *d3d)
                                               d3d->d3d_render_target_view,
                                               color);
 
-    /* Rasterizer Stage */
+    /*
+     * Rasterizer Stage
+     *
+     * RSSetViewports() called in the resize() callback
+     */
     ID3D11DeviceContext_RSSetState(d3d->d3d_device_ctx,
                                    d3d->d3d_rasterizer_state);
-    ID3D11DeviceContext_RSSetViewports(d3d->d3d_device_ctx,
-                                       1U, &d3d->viewport);
 
-    /* Output Merger stage */
-    ID3D11DeviceContext_OMSetRenderTargets(d3d->d3d_device_ctx,
-                                           1U, &d3d->d3d_render_target_view,
-                                           NULL);
+    /* pixel shader stage */
+    ID3D11DeviceContext_PSSetShader(d3d->d3d_device_ctx,
+                                    d3d->d3d_pixel_shader,
+                                    NULL,
+                                    0);
+
+    /*
+     * Output Merger stage
+     *
+     * OMSetRenderTargets() called in the resize() calback
+     */
 
     /*
-     * present frame, that is flip the back buffer and the front buffer
+     * present frame, that is, flip the back buffer and the front buffer
      * if no vsync, we present immediatly
      */
     pp.DirtyRectsCount = 0;
diff --git a/src/win.c b/src/win.c
index d5ac2e1..f1c0ae5 100644
--- a/src/win.c
+++ b/src/win.c
@@ -377,6 +377,8 @@ int main()
         goto del_window;
     }
 
+    d3d_scene_begin(d3d);
+
     ret = 0;
 
     SetWindowLongPtr(win->win, GWLP_USERDATA, (LONG_PTR)win);
@@ -403,6 +405,7 @@ int main()
     }
 
   beach:
+    d3d_scene_end();
     d3d_shutdown(d3d);
   del_window:
     window_del(win);
diff --git a/src/win.h b/src/win.h
index c859411..4c75ecf 100644
--- a/src/win.h
+++ b/src/win.h
@@ -21,6 +21,10 @@ D3d *d3d_init(Window *win, int vsync);
 
 void d3d_shutdown(D3d *d3d);
 
+void d3d_scene_begin(D3d *d3d);
+
+void d3d_scene_end(void);
+
 void d3d_resize(D3d *d3d, int rot, UINT width, UINT height);
 
 void d3d_render(D3d *d3d);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to