Recent

Author Topic: How do you render a pixel buffer to a window in cocoa?  (Read 723 times)

Artlav

  • New Member
  • *
  • Posts: 36
    • Orbital Designs
How do you render a pixel buffer to a window in cocoa?
« on: March 26, 2023, 03:14:43 pm »
I'm trying to draw an RGB buffer to a window or anything on a window, and i can not for the life of me figure out how to do this.
No LCL, just raw cocoa ( https://wiki.freepascal.org/FPC_PasCocoa )

The closest i found is this https://stackoverflow.com/questions/48293376/render-pixel-buffer-with-cocoa

However, i wasn't able to figure out what is the equivalent of (__bridge id) in pascal, and in general doing or accessing window.contentView.layer.{anything} produces an "Error: Pointer to object expected".

At this point i'm at a complete loss. I can't understand how any of it works there are zero pascal examples anywhere i looked, and i can't figure out how to convert non-pascal examples to pascal.

Could someone please point me to an example of how to do this?

Seenkao

  • Hero Member
  • *****
  • Posts: 546
    • New ZenGL.
Re: How do you render a pixel buffer to a window in cocoa?
« Reply #1 on: March 29, 2023, 10:46:08 am »
  Для рисования в окне нужно создать какой-либо контекст окна. Обычно это OpenGL-контекст или более распространённый сейчас Metal-контекст. Так же вы можете использовать Image-контекст. Если вы знаете как его создать и можете его создать, то тут могу посоветовать использовать формат пикселя 24 бит (32-х битный формат может выдавать ошибку).
  Как создать OpenGL-контекст и Metal-контекст, примеры есть, их можно использовать и без LCL (я использую, правда только для OpenGL). Если вас интересует Image-контекст, то возможно вам кто-то другой сможет в этом помочь.
  Успехов!

Google translate:
  To draw on a window, you need to create some sort of window context. This is usually the OpenGL-context or the more common now Metal-context. You can also use the Image context. If you know how to create it and can create it, then I can advise you to use the 24-bit pixel format (32-bit format may give an error).
   How to create OpenGL-context and Metal-context, there are examples, they can be used without LCL (I use, though only for OpenGL). If you are interested in the Image context, then perhaps someone else can help you with this.
   Good luck!
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

 

TinyPortal © 2005-2018