Code Monkey home page Code Monkey logo

windy's Introduction

Windy

This library is still in development and is not ready to be used.

Windy is a windowing library for Nim that uses OS native APIs to manage windows, set up OpenGL and receive mouse and keyboard input.

nimble install windy

Github Actions

API reference

Windy will work great for 2D and 3D OpenGL games as well as GUI apps using OpenGL. Using this library should feel similar to GLFW or SDL.

Features:

  • Multi-platform (Windows, macOS, Linux)
  • Manage one or many windows
  • Customizable windows (resizable, hidden, fullscreen and more)
  • Use custom window icons and cursors
  • DPI and content-scaling aware
  • Mouse input (position, clicks, scroll)
  • Double-click, triple-click and quadruple-click events
  • Keyboard input (key events + unicode)
  • Easy polling of keyboard state via buttonDown[Button] and more
  • IME support (for Chinese, Japanese etc text input)
  • System clipboard (copy and paste) support
  • Show a system tray icon and menu (Windows only)
  • Non-blocking HTTP requests and WebSockets

Basic Example

import opengl, windy

let window = newWindow("Windy Example", ivec2(1280, 800))

window.makeContextCurrent()
loadExtensions()

proc display() =
  glClear(GL_COLOR_BUFFER_BIT)
  # Your OpenGL display code here
  window.swapBuffers()

while not window.closeRequested:
  display()
  pollEvents()

Check out more examples here.

Why not just use GLFW or SDL?

Here are a few reasons that may be worth considering:

  • Windy is written in Nim so it will be more natural to use than bindings to other libraries. For example, making a window fullscreen is as easy as window.fullscreen = true. Consider browsing some of the examples and consider if you would find this Nim-first API more pleasant to work with.

  • Windy includes events for double, triple and quadruple clicks. Furthermore, Windy maintains the keyboard and mouse state in a way that makes reacting to input state easier each frame. See buttonPressed[], buttonDown[], buttonReleased[] and buttonToggle[] on Window.

  • Windy has IME input support for Chinese, Japanese, Korean and other languages. Text input can also be enabled or disabled at any time (for example, to avoid opening the IME editor when a user just wants to use WASD in a game).

windy's People

Contributors

doongjohn avatar guzba avatar levovix0 avatar skyvault avatar treeform avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

windy's Issues

startMove instead of pos=

Setting (toplevel) window coordinates (relative to the screen) is not available on Wayland.
Setting window pos often used to let user move window when it is client-side decorated, and this behavior is available on Wayland.
So add function to start interactive window moving and remove or mark as not cross-platform pos=

Make Windy Modular

It would be really cool if Windy was modular so you only imported the things you really use.

import windy/clipboard

ImGui implementation example

I just discovered windy and it looks like a promising library.
And I'd really like to use windy instead of GLFW for ImGui but I haven't got it working.

Here's the example I'd like to work with windy
import nimgl/[opengl, glfw]
import nimgl/imgui, nimgl/imgui/[impl_opengl, impl_glfw]

proc main() =
  doAssert glfwInit()

  glfwWindowHint(GLFWContextVersionMajor, 3)
  glfwWindowHint(GLFWContextVersionMinor, 3)
  glfwWindowHint(GLFWOpenglForwardCompat, GLFW_TRUE)
  glfwWindowHint(GLFWOpenglProfile, GLFW_OPENGL_CORE_PROFILE)
  glfwWindowHint(GLFWResizable, GLFW_TRUE)

  var win: GLFWWindow = glfwCreateWindow(600, 400, "Example")
  if win == nil:
    quit(-1)

  win.makeContextCurrent()

  doAssert glInit()

  let context = igCreateContext()
  #let io = igGetIO()

  doAssert igGlfwInitForOpenGL(win, true)
  doAssert igOpenGL3Init()

  igStyleColorsCherry()

  var somefloat: float32 = 0.0f
  var counter: int32 = 0

  while not win.windowShouldClose:
    glfwPollEvents()

    igOpenGL3NewFrame()
    igGlfwNewFrame()
    igNewFrame()

    # Simple window
    igBegin("Hello, world!")

    igText("This is some useful text.")

    igSliderFloat("float", somefloat.addr, 0.0f, 1.0f)

    if igButton("Button", ImVec2(x: 0, y: 0)):
      counter.inc
    igSameLine()
    igText("counter = %d", counter)

    igText("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / igGetIO().framerate, igGetIO().framerate)
    igEnd()
    # End simple window

    igRender()

    glClearColor(0.45f, 0.55f, 0.60f, 1.00f)
    glClear(GL_COLOR_BUFFER_BIT)

    igOpenGL3RenderDrawData(igGetDrawData())

    win.swapBuffers()

  igOpenGL3Shutdown()
  igGlfwShutdown()
  context.igDestroyContext()

  win.destroyWindow()
  glfwTerminate()

when isMainModule:
  main()

Gamepad support

I really like windy's support of keyboard/mouse, but for making a game-engine I want to support gamepads, primarily.

I made a light wrapper for libstem_gamepad, which is made in C, and works on Windows, Linux, and OSX. I could make it feel a bit more like windy's state-helpers (like buttonPressed / buttonDown / buttonReleased / buttonToggle) and make a PR to include this, if there is interest. Is there a more nim-ish way to do this? Is this outside the scope of what windy is trying to do?

Usage currently looks like this:

let windowSize = ivec2(320, 240)
let window = newWindow("null0", windowSize)
makeContextCurrent(window)
loadExtensions()

proc onGamepadAttached(device: ptr Gamepad_device; context: pointer) =
  var js = device[]
  echo "attached: " & $js.deviceID

proc onGamepadRemoved(device: ptr Gamepad_device; context: pointer) =
  var js = device[]
  echo "removed: " & $js.deviceID

proc onButtonDown (device: ptr Gamepad_device; buttonID: cuint; timestamp: cdouble; context: pointer) =
  var js = device[]
  echo "buttonDown(" & $js.deviceID & "): " & $buttonID

proc onButtonUp (device: ptr Gamepad_device; buttonID: cuint; timestamp: cdouble; context: pointer) =
  var js = device[]
  echo "buttonUp(" & $js.deviceID & "): " & $buttonID

proc onAxisMoved (device: ptr Gamepad_device; axisID: cuint; value: cfloat; lastValue: cfloat; timestamp: cdouble; context: pointer) =
  var js = device[]
  echo "axis(" & $js.deviceID & "): " & $axisID & " : " & $value

const GAMEPAD_POLL_ITERATION_INTERVAL=30
gamepad.deviceAttachFunc(onGamepadAttached)
gamepad.deviceRemoveFunc(onGamepadRemoved)
gamepad.buttonDownFunc(onButtonDown)
gamepad.buttonUpFunc(onButtonUp)
gamepad.axisMoveFunc(onAxisMoved)
gamepad.init()

var iterationsToNextPoll = GAMEPAD_POLL_ITERATION_INTERVAL
while not window.closeRequested:
  pollEvents()
  dec iterationsToNextPoll
  if iterationsToNextPoll == 0:
    gamepad.detectDevices()
    iterationsToNextPoll = GAMEPAD_POLL_ITERATION_INTERVAL
  gamepad.processEvents()

Why does Windy deal with HTTP requests and websockets?

Hi,

I'm just curious why does Windy provide HTTP functionality?

It seems that Windy is about making and managing windows on different
platforms and HTTP seems like different topic. Is there a reason
why does Windy also include HTTP support?

Nim 2.0.0 error

.nimble\pkgs\windy-0.0.0\windy\platforms\win32\platform.nim(872, 17) Error: cannot convert 513 to range 0..255(int)

Works fine with ver. 1.6.10

Error: unhandled exception: Image width and height must be > 0 [PixieError]

I want to render text file, encounter this error, I don't know how to set the text pos, with translate(vec2(100, 100)) I get this error.

import std/[os]
import boxy, opengl, windy

const ProjectDir = currentSourcePath.parentDir
let window = newWindow("textee", ivec2(1280, 800))
window.size = (window.size.vec2 * window.contentScale).ivec2

makeContextCurrent(window)

loadExtensions()

let bxy = newBoxy()

var frame: int

let typeface = readTypeface( ProjectDir / "assets/DejaVuSansMono.ttf")
# let source = readFile(currentSourcePath)

proc drawText(
  bxy: Boxy,
  imageKey: string,
  transform: Mat3,
  typeface: Typeface,
  text: string,
  size: float32,
  color: Color
) =
  var font = newFont(typeface)
  font.size = size
  font.paint = color
  let
    arrangement = typeset(@[newSpan(text, font)], bounds = vec2(1280, 800))
    globalBounds = arrangement.computeBounds(transform).snapToPixels()
  echo globalBounds
  let
    textImage = newImage(globalBounds.w.int, globalBounds.h.int)
    imageSpace = translate(-globalBounds.xy) * transform
  textImage.fillText(arrangement, imageSpace)

  bxy.addImage(imageKey, textImage)
  bxy.drawImage(imageKey, globalBounds.xy)

const BackgroundColor = color(1, 1, 1, 1)
const TextColor = color(0, 0, 0)
const FontSize = 28
# Called when it is time to draw a new frame.
window.onFrame = proc() =
  # Clear the screen and begin a new frame.
  bxy.beginFrame(window.size)

  bxy.drawRect(rect(vec2(0, 0), window.size.vec2), BackgroundColor)
  var i = 0
  for line in currentSourcePath.lines:
    bxy.drawText(
      $i,
      translate(vec2(100, 100)),
      typeface,
      line,
      FontSize,
      TextColor
    )
    inc i

  # End this frame, flushing the draw commands.
  bxy.endFrame()
  # Swap buffers displaying the new Boxy frame.
  window.swapBuffers()
  inc frame

while not window.closeRequested:
  pollEvents()

Implementing the wayland backend

Hi,

I've been hacking away on the wayland backend part of windy. I'm working on adding support for hardware graphics buffers as well as supporting some of the wayland protocol extensions used in modern wayland desktops, like:

Are you open for contributions/PRs/discussions? :)

MAC M1 : failed on a simple example

/.nimble/bin/nim c --usenimcache --nimcache=/.cache/nim/jb_windy/triangle.nim_d /windy/examples/triangle.nim
Hint: used config file '/.choosenim/toolchains/nim-1.6.12/config/nim.cfg' [Conf]
Hint: used config file '
/.choosenim/toolchains/nim-1.6.12/config/config.nims' [Conf]
.......................................................................................................................................................................................................................
/.nimble/pkgs/windy-0.0.0/windy/http.nim(68, 3) Warning: The bare except clause is deprecated; use except CatchableError: instead [BareExcept]
/.nimble/pkgs/windy-0.0.0/windy/http.nim(79, 5) Warning: The bare except clause is deprecated; use except CatchableError: instead [BareExcept]
/.nimble/pkgs/windy-0.0.0/windy/http.nim(82, 54) template/generic instantiation of async from here
/.nimble/pkgs/windy-0.0.0/windy/http.nim(91, 70) template/generic instantiation of async from here
/.nimble/pkgs/windy-0.0.0/windy/http.nim(96, 7) Warning: The bare except clause is deprecated; use except CatchableError: instead [BareExcept]
/.nimble/pkgs/windy-0.0.0/windy/http.nim(82, 54) template/generic instantiation of async from here
/.nimble/pkgs/windy-0.0.0/windy/http.nim(91, 70) template/generic instantiation of async from here
/.choosenim/toolchains/nim-1.6.12/lib/pure/asyncmacro.nim(42, 5) Warning: The bare except clause is deprecated; use except CatchableError: instead [BareExcept]
/.nimble/pkgs/windy-0.0.0/windy/http.nim(82, 54) template/generic instantiation of async from here
/.nimble/pkgs/windy-0.0.0/windy/http.nim(112, 38) template/generic instantiation of request from here
/.choosenim/toolchains/nim-1.6.12/lib/pure/httpclient.nim(1086, 14) Warning: Deprecated since v1.5; use HttpMethod enum instead; string parameter httpMethod is deprecated [User]
/.nimble/pkgs/windy-0.0.0/windy/http.nim(82, 54) template/generic instantiation of async from here
/.nimble/pkgs/windy-0.0.0/windy/http.nim(112, 38) template/generic instantiation of request from here
/.choosenim/toolchains/nim-1.6.12/lib/pure/asyncmacro.nim(42, 5) Warning: The bare except clause is deprecated; use except CatchableError: instead [BareExcept]
/.nimble/pkgs/windy-0.0.0/windy/http.nim(82, 54) template/generic instantiation of async from here
/.nimble/pkgs/windy-0.0.0/windy/http.nim(138, 3) Warning: The bare except clause is deprecated; use except CatchableError: instead [BareExcept]
/.nimble/pkgs/windy-0.0.0/windy/http.nim(82, 54) template/generic instantiation of async from here
/.choosenim/toolchains/nim-1.6.12/lib/pure/asyncmacro.nim(42, 5) Warning: The bare except clause is deprecated; use except CatchableError: instead [BareExcept]
/.nimble/pkgs/windy-0.0.0/windy/http.nim(143, 50) template/generic instantiation of async from here
/.nimble/pkgs/windy-0.0.0/windy/http.nim(177, 3) Warning: The bare except clause is deprecated; use except CatchableError: instead [BareExcept]
/.nimble/pkgs/windy-0.0.0/windy/http.nim(143, 50) template/generic instantiation of async from here
/.nimble/pkgs/windy-0.0.0/windy/http.nim(187, 5) Warning: The bare except clause is deprecated; use except CatchableError: instead [BareExcept]
/.nimble/pkgs/windy-0.0.0/windy/http.nim(143, 50) template/generic instantiation of async from here
/.choosenim/toolchains/nim-1.6.12/lib/pure/asyncmacro.nim(42, 5) Warning: The bare except clause is deprecated; use except CatchableError: instead [BareExcept]
/.nimble/pkgs/windy-0.0.0/windy/http.nim(197, 3) Warning: The bare except clause is deprecated; use except CatchableError: instead [BareExcept]
/.nimble/pkgs/windy-0.0.0/windy/http.nim(204, 3) Warning: The bare except clause is deprecated; use except CatchableError: instead [BareExcept]
...
/.nimble/pkgs/windy-0.0.0/windy/platforms/macos/objc.nim(156, 14) Hint: 'addProtocol' is declared but not used [XDeclaredButNotUsed]
/.nimble/pkgs/windy-0.0.0/windy/platforms/macos/objc.nim(156, 14) Hint: 'addProtocol' is declared but not used [XDeclaredButNotUsed]
/.nimble/pkgs/windy-0.0.0/windy/platforms/macos/platform.nim(936, 3) template/generic instantiation of autoreleasepool from here
/.nimble/pkgs/windy-0.0.0/windy/platforms/macos/platform.nim(964, 5) Warning: The bare except clause is deprecated; use except CatchableError: instead [BareExcept]
CC: ../../../../../../..
/.choosenim/toolchains/nim-1.6.12/lib/std/private/digitsutils.nim
CC: ../../../../../../..
/.choosenim/toolchains/nim-1.6.12/lib/system/assertions.nim
CC: ../../../../../../..
/.choosenim/toolchains/nim-1.6.12/lib/system/formatfloat.nim
CC: ../../../../../../..
/.choosenim/toolchains/nim-1.6.12/lib/system/dollars.nim
CC: ../../../../../../..
/.choosenim/toolchains/nim-1.6.12/lib/system/io.nim
CC: ../../../../../../..
/.choosenim/toolchains/nim-1.6.12/lib/system.nim
CC: ../../../../../../..
/.choosenim/toolchains/nim-1.6.12/lib/pure/bitops.nim
CC: ../../../../../../..
/.choosenim/toolchains/nim-1.6.12/lib/pure/math.nim
CC: ../../../../../../..
/.choosenim/toolchains/nim-1.6.12/lib/pure/strutils.nim
CC: ../../../../../../..
/.choosenim/toolchains/nim-1.6.12/lib/posix/posix.nim
CC: ../../../../../../..
/.choosenim/toolchains/nim-1.6.12/lib/pure/dynlib.nim
CC: ../../../../../../..
/.nimble/pkgs/opengl-1.2.6/opengl.nim
CC: ../../../../../../..
/.nimble/pkgs/vmath-1.2.0/vmath.nim
CC: ../../../../../../..
/.nimble/pkgs/chroma-0.2.7/chroma/colortypes.nim
CC: ../../../../../../..
/.choosenim/toolchains/nim-1.6.12/lib/pure/collections/tables.nim
CC: ../../../../../../..
/.choosenim/toolchains/nim-1.6.12/lib/pure/options.nim
CC: ../../../../../../..
/.choosenim/toolchains/nim-1.6.12/lib/pure/times.nim
CC: ../../../../../../..
/.choosenim/toolchains/nim-1.6.12/lib/pure/os.nim
CC: ../../../../../../..
/.nimble/pkgs/pixie-5.0.6/pixie/common.nim
CC: ../../../../../../..
/.nimble/pkgs/nimsimd-1.2.5/nimsimd/runtimecheck.nim
CC: ../../../../../../..
/.nimble/pkgs/pixie-5.0.6/pixie/simd.nim
CC: ../../../../../../..
/.nimble/pkgs/pixie-5.0.6/pixie/internal.nim
CC: ../../../../../../..
/.nimble/pkgs/pixie-5.0.6/pixie/paths.nim
CC: ../../../../../../..
/.nimble/pkgs/pixie-5.0.6/pixie/fonts.nim
CC: ../../../../../../..
/.nimble/pkgs/zippy-0.10.7/zippy/common.nim
CC: ../../../../../../..
/.nimble/pkgs/zippy-0.10.7/zippy/internal.nim
CC: ../../../../../../..
/.nimble/pkgs/zippy-0.10.7/zippy/bitstreams.nim
CC: ../../../../../../..
/.nimble/pkgs/zippy-0.10.7/zippy/adler32_simd.nim
CC: ../../../../../../..
/.nimble/pkgs/zippy-0.10.7/zippy/adler32.nim
CC: ../../../../../../..
/.nimble/pkgs/zippy-0.10.7/zippy/crc32_simd.nim
CC: ../../../../../../../.nimble/pkgs/zippy-0.10.7/zippy/crc.nim
/.cache/nim/jb_windy/triangle.nim_d/@m..@s..@s..@s..@s..@s..@s..@susers@[email protected]@[email protected]@[email protected]:131:10: error: invalid output constraint '=a' in asm
:"=a"(eaxr), "=b"(ebxr), "=c"(ecxr), "=d"(edxr)
^
1 error generated.
CC: ../../../../../../..
/.nimble/pkgs/zippy-0.10.7/zippy/lz77.nim
CC: ../../../../../../..
/.nimble/pkgs/zippy-0.10.7/zippy/snappy.nim
Error: execution of an external compiler program 'clang -c -w -ferror-limit=3 -I~/.choosenim/toolchains/nim-1.6.12/lib -I/windy/examples -o ~/.cache/nim/jb_windy/triangle.nim_d/@m..@s..@s..@s..@s..@s..@s..@susers@[email protected]@[email protected]@[email protected] ~/.cache/nim/jb_windy/triangle.nim_d/@m..@s..@s..@s..@s..@s..@s..@susers@[email protected]@[email protected]@[email protected]' failed with exit code: 1

~/.cache/nim/jb_windy/triangle.nim_d/@m..@s..@s..@s..@s..@s..@s..@susers@[email protected]@[email protected]@[email protected]:826:10: error: invalid output constraint '=a' in asm
:"=a"(eaxr), "=b"(ebxr), "=c"(ecxr), "=d"(edxr)
^
1 error generated.

default center window

I tried figure out how to center window, then I found windy position window to left and top default internally, the macOS default behavior is center window.

"undeclared field: 'onFrame'" for X11 Window.

In src/windy/platforms/x11.nim the Window is missing the onFrame field. Here's a diff of my fix:

--- a/src/windy/platforms/linux/x11.nim
+++ b/src/windy/platforms/linux/x11.nim
@@ -5,6 +5,7 @@ type
 
   Window* = ref object
     onCloseRequest*: Callback
+    onFrame*: Callback
     onMove*: Callback
     onResize*: Callback
     onFocusChange*: Callback
@@ -782,6 +783,8 @@ proc pollEvents(window: Window) =
         window.prevSize = ev.configure.size
         if window.onResize != nil:
           window.onResize()
+        if window.onFrame != nil:
+          window.onFrame()
 
     of xeMotion:
       window.mousePrevPos = window.mousePos

Make macOS internal utilities on a library on its own

I've seen that there are several nice utilities to compose objc classes and bootstrap delegates in the windy internals for macOS. Is it possible to make a separate library in order to use those in other projects ? I'm currently trying to work with Metal directly from nim and some of those classes / methods would come in handy (and don't want to duplicate them in my project).

Btw suggestion for the name: objetty ๐Ÿ˜„

mouseDelta incorrectly accumulates on windows

Not sure if this exists on other platforms

import opengl, windy

let window = newWindow("Windy Basic", ivec2(1280, 800))

window.makeContextCurrent()
loadExtensions()

var offset = ivec2(0, 0)

proc display() =
  glClear(GL_COLOR_BUFFER_BIT)
  # Your OpenGL display code here
  window.swapBuffers()

while not window.closeRequested:
  display()
  pollEvents()
  if window.buttonDown[MouseLeft]:
    offset += window.mouseDelta
  echo offset

Run this, then click and drag the mouse starting in the upper left corner and move it around for ~20 seconds, when you bring the mouse back to the starting point (while still dragging) the offset will be wrong by a magnitude of about 100

Video demonstration:

2022-01-15.14-06-41.mp4

Dependency on vmath?

I don't understand the logic here - why tightly couple this project with another dependency like vmath? IMO users shouldn't have to buy into your linear algebra library to use your windowing library. This is the same type of issue I have with fidget but even more egregious...

Compiler error without feature turned on

win32\platform.nim(1348, 12) Error: startHttpRequest requires --threads:on option

Not sure if this can be configured per nimble library that it needs this feature to be used?

Error creating opengl 2.0 ES context

import opengl, os, windy

when isMainModule:

  let window = newWindow(
    "Windy",
    ivec2(1280, 800),
    openglMajorVersion = 2,
    openglMinorVersion = 0,
  )

  window.makeContextCurrent()
  loadExtensions()

  echo "GL_VERSION: ", cast[cstring](glGetString(GL_VERSION))
  echo "GL_VENDOR: ", cast[cstring](glGetString(GL_VENDOR))
  echo "GL_RENDERER: ", cast[cstring](glGetString(GL_RENDERER))

  while not window.closeRequested:
    pollEvents()
    sleep(10)

Error:

C:\Users\Cameron\Documents\Authored\nimzoom\src\nimzoom.nim(5) nimzoom
C:\Users\Cameron\.nimble\pkgs\windy-0.0.0\windy\platforms\win32\platform.nim(895) newWindow
[[reraised from:
C:\Users\Cameron\Documents\Authored\nimzoom\src\nimzoom.nim(5) nimzoom
C:\Users\Cameron\.nimble\pkgs\windy-0.0.0\windy\platforms\win32\platform.nim(911) newWindow
]]
Error: unhandled exception: Error creating OpenGL context [WindyError]

OpenGL issue with windy

Almost all other example compile and run perfectly except examples/triangle.nim. which produce this error at runtime.

sk@sk-pc:~/myfolder/nim/windy/examples$ ./triangle 
0:1(10): error: GLSL 4.10 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, and 3.10 ES

0:1(10): error: GLSL 4.10 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, and 3.10 ES

error: linking with uncompiled/unspecialized shadererror: linking with uncompiled/unspecialized shader
/home/sk/myfolder/nim/windy/examples/triangle.nim(104) triangle
/home/sk/myfolder/nim/windy/examples/triangle.nim(96) display
/home/sk/.nimble/pkgs/opengl-1.2.6/opengl/private/errors.nim(44) glUseProgram
/home/sk/.nimble/pkgs/opengl-1.2.6/opengl/private/errors.nim(99) checkGLerror
Error: unhandled exception: OpenGL error: invalid operation [GLerror]

Other Information

Nim version: 1.6.6 [amd64]
OS: Linux Mint 20.3
To test if there is anything wrong with OpenGL driver, I run some demo code with

  • NimGL, runs without any issue.
  • PyOpenGL, runs without any Issue.

win32/platform.nim compile error

Compile error:

nimble build -d:mingw
/home/username/.nimble/pkgs2/windy-0.0.0-e0506a1d00e0daf1ffa44f00959853bbae29b01f/windy/platforms/win32/platform.nim(872, 17) Error: cannot convert 513 to range 0..255(int)

Nim version:

Nim Compiler Version 1.9.3 [Linux: amd64]
Compiled at 2023-04-19                                                                                                                                                                        Copyright (c) 2006-2023 by Andreas Rumpf                                                                                                                                                                                                                                                                                                                                                    git hash: 24b6378382f4bcde3b354f0a8137604192c7570f
active boot switches: -d:release

windy version:
windy [(version: 0.0.0, checksum: e0506a1d00e0daf1ffa44f00959853bbae29b01f)]

incompatible function pointer types

I thought I had this working, but started getting this on new projects:

Users/konsumer/.cache/nim/null0_d/@m..@s..@[email protected]@[email protected]@swindy@splatforms@[email protected]:820:10: error: incompatible function pointer types assigning to 'tyProc__ELDcQK9cgdUyzj5KMs6i3sA' (aka 'long long (*)(long long, long long)') from 'tyProc__ln4kdL5W9bbX4a1xl8nnVXQ' (aka 'void (*)(void)') [-Wincompatible-function-pointer-types]
        msgSend = Dl_3472883728_;
                ^ ~~~~~~~~~~~~~~

Here is my simple demo code:

import opengl, windy

let window = newWindow("Windy Basic", ivec2(1280, 800))

window.makeContextCurrent()
loadExtensions()

proc display() =
  glClear(GL_COLOR_BUFFER_BIT)
  # Your OpenGL display code here
  window.swapBuffers()

while not window.closeRequested:
  display()
  pollEvents()

OS: MacOSX Ventura 13.3.1 (22E261)
Arch: x86_64
Nim: 1.6.12

requires "opengl >= 1.2.6"
requires "windy >= 0.0.0"
requires "boxy >= 0.4.1"

mousePrevPos set to zero when mouse not moving on Windows

From this program:

import opengl, windy

let window = newWindow("Windy Basic", ivec2(1280, 800))

window.makeContextCurrent()
loadExtensions()

proc display() =
  glClear(GL_COLOR_BUFFER_BIT)
  # Your OpenGL display code here
  window.swapBuffers()

while not window.closeRequested:
  display()
  pollEvents()
  echo window.mousePrevPos

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.