Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo Mariscal committed Jan 4, 2019
2 parents b081cf8 + 2c95de7 commit 8b1a56f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ daysUntilClose: 1
exemptLabels:
- important

staleLabel: wontfix
staleLabel: "Status: Abandoned"
markComment: >
Thanks for contributing to this issue. As it has been 61 days since the last activity, we are automatically closing
the issue in 24 hours. This is often because the request was already solved in some way and it just wasn't updated or
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ find them at http://editorconfig.org/.
. Modify, commit and push.
. Put yourself on the link:CONTRIBUTORS.adoc[CONTRIBUTORS] file!
. Create Pull Request with squashed commits and changelog.
. Remember to make the Pull Request to the `develop` branch

=== License Note

Expand Down
6 changes: 3 additions & 3 deletions src/nimgl/glfw.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
## Or continue reading to get the documentation shown here.

import private/logo
import stb_image
import stb/image

when defined(glfwDLL):
when defined(windows):
Expand Down Expand Up @@ -621,10 +621,10 @@ proc glfwCreateWindow*(width: int32, height: int32, title: cstring = "NimGL", mo
## Utility to create the window with a proper icon.
result = glfwCreateWindowC(width, height, title, monitor, share)
if not icon: return result
let data: ImageData = stbi_load_from_memory(cast[ptr char](nimgl_logo[0].addr), nimgl_logo.len.int32)
let data: ImageData = stbiLoadFromMemory(cast[ptr char](nimgl_logo[0].addr), nimgl_logo.len.int32)
var image: GLFWImage = GLFWImage(pixels: data.data, width: data.width, height: data.height)
result.setWindowIcon(1, image.addr)
image.pixels.stbi_image_free()
image.pixels.stbiImageFree()

proc glfwInit*(): bool {.glfw_lib, importc: "glfwInit".}
## Initializes the GLFW library. Before most GLFW functions can
Expand Down
21 changes: 12 additions & 9 deletions src/nimgl/stb_image.nim → src/nimgl/stb/image.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@

from os import splitPath

{.passC: "-DSTB_IMAGE_IMPLEMENTATION -I" & currentSourcePath().splitPath.head & "/private/stb",
compile: "private/stb/stb_image.c"}
{.passC: "-DSTB_IMAGE_IMPLEMENTATION -I" & currentSourcePath().splitPath.head & "/../private/stb",
compile: "../private/stb/stb_image.c"}
{.pragma: stb_image, cdecl, importc.}

type
ImageData* = object
width*: int32
height*: int32
channels*: int32
data*: ptr char
data*: ptr cuchar

proc stbi_load*(filename: cstring, width: ptr int32, height: ptr int32, channels: ptr int32, components: int32 = 0): ptr char {.stb_image, importc: "stbi_load".}
proc stbiLoad*(filename: cstring, width: ptr int32, height: ptr int32, channels: ptr int32, components: int32 = 0): ptr cuchar {.stb_image, importc: "stbi_load".}
## returns a pointer to the image requested, nil if nothind found.
## width and height as you imagine are from the image
## channels, how many channels the image has
Expand All @@ -34,12 +34,12 @@ proc stbi_load*(filename: cstring, width: ptr int32, height: ptr int32, channels
## components, define if you require some especific number of channels. If 0
## uses the number of channels the image has.

proc stbi_load*(filename: cstring, components: int32 = 0): ImageData =
proc stbiLoad*(filename: cstring, components: int32 = 0): ImageData =
## a utility to only give the filename and get a tupple with all the data
## more info in the original proc
result.data = stbi_load(filename, result.width.addr, result.height.addr, result.channels.addr, components)

proc stbi_load_from_memory*(buffer: ptr char, len: int32, width: ptr int32, height: ptr int32, channels: ptr int32, components: int32 = 0): ptr char {.stb_image, importc: "stbi_load_from_memory".}
proc stbiLoadFromMemory*(buffer: ptr cuchar, len: int32, width: ptr int32, height: ptr int32, channels: ptr int32, components: int32 = 0): ptr cuchar {.stb_image, importc: "stbi_load_from_memory".}
## returns a pointer to the image loaded from the buffer
## width and height as you imagine are from the image
## channels, how many channels the image has
Expand All @@ -50,13 +50,16 @@ proc stbi_load_from_memory*(buffer: ptr char, len: int32, width: ptr int32, heig
## components, define if you require some especific number of channels. If 0
## uses the number of channels the image has.

proc stbi_load_from_memory*(buffer: ptr char, len: int32, components: int32 = 0): ImageData =
proc stbiLoadFromMemory*(buffer: ptr cuchar, len: int32, components: int32 = 0): ImageData =
## a utility to only give the filename and get a tupple with all the data
## more info in the original proc
result.data = stbi_load_from_memory(buffer, len, result.width.addr, result.height.addr, result.channels.addr, components)

proc stbi_image_free*(data: ptr char): void {.stb_image, importc: "stbi_image_free".}
proc stbiImageFree*(data: ptr cuchar): void {.stb_image, importc: "stbi_image_free".}
## frees the data, loaded from stbi_load

proc stbi_set_flip_vertically_on_load*(state: bool): void {.stb_image, importc: "stbi_set_flip_vertically_on_load".}
proc imageFree*(image: ImageData): void =
image.data.stbiImageFree()

proc stbiSetFlipVerticallyOnLoad*(state: bool): void {.stb_image, importc: "stbi_set_flip_vertically_on_load".}
## flip the image vertically, so the first pixel in the output array is the bottom left

0 comments on commit 8b1a56f

Please sign in to comment.