core_scissor_test.bmx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. SuperStrict
  2. Framework Ray.Lib
  3. ' Initialization
  4. '--------------------------------------------------------------------------------------
  5. Const screenWidth:Int = 800
  6. Const screenHeight:Int = 450
  7. InitWindow(screenWidth, screenHeight, "raylib [core] example - scissor test")
  8. Local scissorArea:RRectangle = New RRectangle(0, 0, 300, 300)
  9. Local scissorMode:Int = True
  10. SetTargetFPS(60) ' Set our game to run at 60 frames-per-second
  11. '--------------------------------------------------------------------------------------
  12. ' Main game loop
  13. While Not WindowShouldClose() ' Detect window close button or ESC key
  14. ' Update
  15. '----------------------------------------------------------------------------------
  16. If IsKeyPressed(KEY_S) Then
  17. scissorMode = Not scissorMode
  18. End If
  19. ' Centre the scissor area around the mouse position
  20. scissorArea.x = GetMouseX() - scissorArea.width / 2
  21. scissorArea.y = GetMouseY() - scissorArea.height / 2
  22. '----------------------------------------------------------------------------------
  23. ' Draw
  24. '----------------------------------------------------------------------------------
  25. BeginDrawing()
  26. ClearBackground(RAYWHITE)
  27. If scissorMode Then
  28. BeginScissorMode(scissorArea.x, scissorArea.y, scissorArea.width, scissorArea.height)
  29. End If
  30. ' Draw full screen rectangle and some text
  31. ' NOTE: Only part defined by scissor area will be rendered
  32. DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), RED)
  33. DrawText("Move the mouse around to reveal this text!", 190, 200, 20, LIGHTGRAY)
  34. If scissorMode Then
  35. EndScissorMode()
  36. End If
  37. DrawRectangleLinesEx(scissorArea, 1, BLACK)
  38. DrawText("Press S to toggle scissor test", 10, 10, 20, BLACK)
  39. EndDrawing()
  40. '----------------------------------------------------------------------------------
  41. Wend
  42. ' De-Initialization
  43. '--------------------------------------------------------------------------------------
  44. CloseWindow() ' Close window and OpenGL context
  45. '--------------------------------------------------------------------------------------