From 26e175f0b7d29dab41085324368b8110d0a6aafb Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Fri, 22 May 2015 01:08:49 +0300 Subject: [PATCH] Fix for 2.3 --- examples/shapes.nim | 6 +++--- src/csfml_graphics.nim | 5 +---- src/csfml_window.nim | 7 ++++++- src/private/csfml_union_event.nim | 4 +++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/examples/shapes.nim b/examples/shapes.nim index b3afeb3..fad3859 100644 --- a/examples/shapes.nim +++ b/examples/shapes.nim @@ -28,7 +28,7 @@ while window.open: vertex(vec2(100, 0), Red), vertex(vec2(200, 100), Blue), ] - window.drawPrimitives(addr(vertexSeq[0]), cint(vertexSeq.len), + window.drawPrimitives(addr(vertexSeq[0]), vertexSeq.len, PrimitiveType.Triangles, renderStates()) # Bottom left @@ -40,8 +40,8 @@ while window.open: window.draw convexShape # Bottom right - proc getPointCount(p: pointer): cint {.cdecl.} = 3 - proc getPoint(index: cint, p: pointer): Vector2f {.cdecl.} = + proc getPointCount(p: pointer): int {.cdecl.} = 3 + proc getPoint(index: int, p: pointer): Vector2f {.cdecl.} = case index of 0: vec2(200, 200) of 1: vec2(100, 200) diff --git a/src/csfml_graphics.nim b/src/csfml_graphics.nim index 63b3e98..123b477 100644 --- a/src/csfml_graphics.nim +++ b/src/csfml_graphics.nim @@ -61,10 +61,7 @@ proc `*`*(a, b: Color): Color = modulate(a, b) proc `-`*(a, b: Color): Color = ## *Returns:* The component-wise subtraction of two colors. Components below 0 are clamped to 0. - if a.r > b.r: result.r = a.r-b.r - if a.g > b.g: result.g = a.g-b.g - if a.b > b.b: result.b = a.b-b.b - if a.a > b.a: result.a = a.a-b.a + subtract(a, b) let Black* = color(0, 0, 0) diff --git a/src/csfml_window.nim b/src/csfml_window.nim index b415c3c..03b5716 100644 --- a/src/csfml_window.nim +++ b/src/csfml_window.nim @@ -34,13 +34,17 @@ include private/csfml_window_gen {.pop.} -proc contextSettings*(depth: cint = 0, stencil: cint = 0, antialiasing: cint = 0, major: cint = 2, minor: cint = 0): ContextSettings = +converter toBitMaskU32*(a: ContextAttribute): BitMaskU32 = BitMaskU32 a + ## Allows ContextAttribute values to be combined using the | operator and be used in functions + +proc contextSettings*(depth: cint = 0, stencil: cint = 0, antialiasing: cint = 0, major: cint = 2, minor: cint = 0, attributes = ContextAttribute.Default): ContextSettings = ## *Arguments*: ## ``depth``: Depth buffer bits ## ``stencil``: Stencil buffer bits ## ``antialiasing``: Antialiasing level ## ``major``: Major number of the context version ## ``minor``: Minor number of the context version + ## ``attributes``: The attribute flags to create the context with ## ## *Returns*: ContextSettings with these members result.depthBits = depth @@ -48,6 +52,7 @@ proc contextSettings*(depth: cint = 0, stencil: cint = 0, antialiasing: cint = 0 result.antialiasingLevel = antialiasing result.majorVersion = major result.minorVersion = minor + result.attributeFlags = attributes proc mouse_getPosition*(): Vector2i = mouse_getPosition(nil) diff --git a/src/private/csfml_union_event.nim b/src/private/csfml_union_event.nim index e47cb76..110cff0 100644 --- a/src/private/csfml_union_event.nim +++ b/src/private/csfml_union_event.nim @@ -40,4 +40,6 @@ type mouseMove*: MouseMoveEvent of EventType.MouseWheelMoved: mouseWheel*: MouseWheelEvent - else: nil \ No newline at end of file + of EventType.MouseWheelScrolled: + mouseWheelScroll*: MouseWheelScrollEvent + else: nil