mirror of
				https://github.com/raysan5/raylib.git
				synced 2025-10-26 12:27:01 +00:00 
			
		
		
		
	Expose scissor functionality
This commit is contained in:
		
							
								
								
									
										17
									
								
								src/core.c
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								src/core.c
									
									
									
									
									
								
							| @@ -1392,6 +1392,23 @@ void EndTextureMode(void) | |||||||
|     currentHeight = GetScreenHeight(); |     currentHeight = GetScreenHeight(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Begin scissor mode (define screen area for following drawing) | ||||||
|  | // NOTE: Scissor rec refers to bottom-left corner, we change it to upper-left | ||||||
|  | void BeginScissorMode(int x, int y, int width, int height) | ||||||
|  | { | ||||||
|  |     rlglDraw(); // Force drawing elements | ||||||
|  |  | ||||||
|  |     rlEnableScissorTest(); | ||||||
|  |     rlScissor(x, GetScreenHeight() - (y + height), width, height); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // End scissor mode | ||||||
|  | void EndScissorMode(void) | ||||||
|  | { | ||||||
|  |     rlglDraw(); // Force drawing elements | ||||||
|  |     rlDisableScissorTest(); | ||||||
|  | } | ||||||
|  |  | ||||||
| // Returns a ray trace from mouse position | // Returns a ray trace from mouse position | ||||||
| Ray GetMouseRay(Vector2 mousePosition, Camera camera) | Ray GetMouseRay(Vector2 mousePosition, Camera camera) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -904,6 +904,8 @@ RLAPI void BeginMode3D(Camera3D camera);                          // Initializes | |||||||
| RLAPI void EndMode3D(void);                                       // Ends 3D mode and returns to default 2D orthographic mode | RLAPI void EndMode3D(void);                                       // Ends 3D mode and returns to default 2D orthographic mode | ||||||
| RLAPI void BeginTextureMode(RenderTexture2D target);              // Initializes render texture for drawing | RLAPI void BeginTextureMode(RenderTexture2D target);              // Initializes render texture for drawing | ||||||
| RLAPI void EndTextureMode(void);                                  // Ends drawing to render texture | RLAPI void EndTextureMode(void);                                  // Ends drawing to render texture | ||||||
|  | RLAPI void BeginScissorMode(int x, int y, int width, int height); // Begin scissor mode (define screen area for following drawing) | ||||||
|  | RLAPI void EndScissorMode(void);                                  // End scissor mode | ||||||
|  |  | ||||||
| // Screen-space-related functions | // Screen-space-related functions | ||||||
| RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera);      // Returns a ray trace from mouse position | RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera);      // Returns a ray trace from mouse position | ||||||
| @@ -1324,8 +1326,6 @@ RLAPI void BeginShaderMode(Shader shader);                                // Beg | |||||||
| RLAPI void EndShaderMode(void);                                           // End custom shader drawing (use default shader) | RLAPI void EndShaderMode(void);                                           // End custom shader drawing (use default shader) | ||||||
| RLAPI void BeginBlendMode(int mode);                                      // Begin blending mode (alpha, additive, multiplied) | RLAPI void BeginBlendMode(int mode);                                      // Begin blending mode (alpha, additive, multiplied) | ||||||
| RLAPI void EndBlendMode(void);                                            // End blending mode (reset to default: alpha blending) | RLAPI void EndBlendMode(void);                                            // End blending mode (reset to default: alpha blending) | ||||||
| RLAPI void BeginScissorMode(int x, int y, int width, int height);         // Begin scissor mode (define screen area for following drawing) |  | ||||||
| RLAPI void EndScissorMode(void);                                          // End scissor mode |  | ||||||
|  |  | ||||||
| // VR control functions | // VR control functions | ||||||
| RLAPI void InitVrSimulator(void);                       // Init VR simulator for selected device parameters | RLAPI void InitVrSimulator(void);                       // Init VR simulator for selected device parameters | ||||||
|   | |||||||
							
								
								
									
										51
									
								
								src/rlgl.h
									
									
									
									
									
								
							
							
						
						
									
										51
									
								
								src/rlgl.h
									
									
									
									
									
								
							| @@ -457,6 +457,9 @@ RLAPI void rlEnableDepthTest(void);                           // Enable depth te | |||||||
| RLAPI void rlDisableDepthTest(void);                          // Disable depth test | RLAPI void rlDisableDepthTest(void);                          // Disable depth test | ||||||
| RLAPI void rlEnableBackfaceCulling(void);                     // Enable backface culling | RLAPI void rlEnableBackfaceCulling(void);                     // Enable backface culling | ||||||
| RLAPI void rlDisableBackfaceCulling(void);                    // Disable backface culling | RLAPI void rlDisableBackfaceCulling(void);                    // Disable backface culling | ||||||
|  | RLAPI void rlEnableScissorTest(void);                         // Enable scissor test | ||||||
|  | RLAPI void rlDisableScissorTest(void);                        // Disable scissor test | ||||||
|  | RLAPI void rlScissor(int x, int y, int width, int height);    // Scissor test | ||||||
| RLAPI void rlEnableWireMode(void);                            // Enable wire mode | RLAPI void rlEnableWireMode(void);                            // Enable wire mode | ||||||
| RLAPI void rlDisableWireMode(void);                           // Disable wire mode | RLAPI void rlDisableWireMode(void);                           // Disable wire mode | ||||||
| RLAPI void rlDeleteTextures(unsigned int id);                 // Delete OpenGL texture from GPU | RLAPI void rlDeleteTextures(unsigned int id);                 // Delete OpenGL texture from GPU | ||||||
| @@ -1344,28 +1347,25 @@ void rlDisableRenderTexture(void) | |||||||
| } | } | ||||||
|  |  | ||||||
| // Enable depth test | // Enable depth test | ||||||
| void rlEnableDepthTest(void) | void rlEnableDepthTest(void) { glEnable(GL_DEPTH_TEST); } | ||||||
| { |  | ||||||
|     glEnable(GL_DEPTH_TEST); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Disable depth test | // Disable depth test | ||||||
| void rlDisableDepthTest(void) | void rlDisableDepthTest(void) { glDisable(GL_DEPTH_TEST); } | ||||||
| { |  | ||||||
|     glDisable(GL_DEPTH_TEST); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Enable backface culling | // Enable backface culling | ||||||
| void rlEnableBackfaceCulling(void) | void rlEnableBackfaceCulling(void) { glEnable(GL_CULL_FACE); } | ||||||
| { |  | ||||||
|     glEnable(GL_CULL_FACE); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Disable backface culling | // Disable backface culling | ||||||
| void rlDisableBackfaceCulling(void) | void rlDisableBackfaceCulling(void) { glDisable(GL_CULL_FACE); } | ||||||
| { |  | ||||||
|     glDisable(GL_CULL_FACE); | // Enable scissor test | ||||||
| } | RLAPI void rlEnableScissorTest(void) { glEnable(GL_SCISSOR_TEST); } | ||||||
|  |  | ||||||
|  | // Disable scissor test | ||||||
|  | RLAPI void rlDisableScissorTest(void) { glDisable(GL_SCISSOR_TEST); } | ||||||
|  |  | ||||||
|  | // Scissor test | ||||||
|  | RLAPI void rlScissor(int x, int y, int width, int height) { glScissor(x, y, width, height); } | ||||||
|  |  | ||||||
| // Enable wire mode | // Enable wire mode | ||||||
| void rlEnableWireMode(void) | void rlEnableWireMode(void) | ||||||
| @@ -1698,7 +1698,6 @@ void rlglInit(int width, int height) | |||||||
|  |  | ||||||
|     // Initialize OpenGL default states |     // Initialize OpenGL default states | ||||||
|     //---------------------------------------------------------- |     //---------------------------------------------------------- | ||||||
|  |  | ||||||
|     // Init state: Depth test |     // Init state: Depth test | ||||||
|     glDepthFunc(GL_LEQUAL);                                 // Type of depth testing to apply |     glDepthFunc(GL_LEQUAL);                                 // Type of depth testing to apply | ||||||
|     glDisable(GL_DEPTH_TEST);                               // Disable depth testing for 2D (only used for 3D) |     glDisable(GL_DEPTH_TEST);                               // Disable depth testing for 2D (only used for 3D) | ||||||
| @@ -3524,24 +3523,6 @@ void EndBlendMode(void) | |||||||
|     BeginBlendMode(BLEND_ALPHA); |     BeginBlendMode(BLEND_ALPHA); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Begin scissor mode (define screen area for following drawing) |  | ||||||
| // NOTE: Scissor rec refers to bottom-left corner, we change it to upper-left |  | ||||||
| void BeginScissorMode(int x, int y, int width, int height) |  | ||||||
| { |  | ||||||
|     rlglDraw();             // Force drawing elements |  | ||||||
|  |  | ||||||
|     glEnable(GL_SCISSOR_TEST); |  | ||||||
|     glScissor(x, framebufferHeight - (y + height), width, height); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // End scissor mode |  | ||||||
| void EndScissorMode(void) |  | ||||||
| { |  | ||||||
|     rlglDraw();             // Force drawing elements |  | ||||||
|  |  | ||||||
|     glDisable(GL_SCISSOR_TEST); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| #if defined(SUPPORT_VR_SIMULATOR) | #if defined(SUPPORT_VR_SIMULATOR) | ||||||
| // Init VR simulator for selected device parameters | // Init VR simulator for selected device parameters | ||||||
| // NOTE: It modifies the global variable: stereoFbo | // NOTE: It modifies the global variable: stereoFbo | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 raysan5
					raysan5