Is texture name unique in OpenGL? - multithreading

When I create a texture using glGenTextures, I get a texture name which is actually an integer such as 0,1,2,3...
What the texture name actually mean? Is this the unique index in GPU?
If I create a texture in different threads or processes, I may get the same name.
However I don't think same name means same texture in GPU.
So I guess the texture is just the local texture index in per thread.
So it is impossible to share texture between thread right?

Texture object names are numbers that represent a specific texture. If you generate a texture object name, the system guarantees that it will uniquely identify that specific texture within that OpenGL context, until you delete the texture (and likely sometime thereafter).
And technically, it is unique with the set of contexts that share objects with the current OpenGL context.
But outside of the context sharing group, that texture name has no meaning. It means nothing to the GPU itself; it merely refers to a specific texture.

Related

What is the relationship between renderpass, graphics pipeline and draw call in vulkan?

I have a basic knowledge about vulkan and compute graphic. I also have read the vulkan tutorial in https://vulkan-tutorial.com/ . However, I am confused about the relationship between renderpass, graphics pipeline and draw call.
From vulkan API, the graphics pipeline only can hold one renderpass. Does it mean multi-renderpass would need creating multiple graphics pipelines?
Draw call command is recorded in a renderpass, it does not specify any render target, although a renderpass may contain multiple render targets. Does it mean a renderpass only need a draw call? But I often hear something about draw call limits. It seems multiple draw calls likely happen in a renderpass. Why need multiple draw calls?
A graphic pipeline does not "hold" a render pass at all. It is created with respect to a render pass:
renderPass is a handle to a render pass object describing the environment in which the pipeline will be used; the pipeline must only be used with an instance of any render pass compatible with the one provided.
Specifically, it is created with respect to a subpass of a render pass (also a field of VkGraphicsPipelineCreateInfo). You can only use a graphics pipeline when a render pass instance compatible with renderPass is active and when the given subpass of that render pass is active.
Subpasses determine which render pass attachments will be rendered to by any rendering operation. So the fragment shader outputs are routed to the active attachments, as specified in the render pass's subpass data for that subpass.
Draws happen with respect to whatever graphics pipeline is current, and render to the attachments specified by the graphics pipeline's outputs and routed to the attachments for the current subpass of the current render pass instance.

What is the PixiJS Geometry used for (as opposed to DisplayObjects)?

I am reading through the Pixi.js source code, and coming across Geometry which sounds like it would be the core of everything. But it seems the "Graphics.ts" is the core, and the "Renderer.ts". What is the purpose of Geometry as opposed to the DisplayObject? The DisplayObject, Container, and Sprite are basically a tree of rendered objects with their own matrix transforms. But what is Geometry used for?
Currently reading through this myself.
I found this Medium article that discusses the new Mid Level API that was introduced in PixiJS 5. The Mid-level API being the bridge between WebGL code and the higher abstractions in DisplayObject.
Geometry acts as part of this bridge along with the Shader and State.
A geometry refers to a set of attributes and the buffers in which they are stored. PixiJS likes to divide that into two pieces:
Geometry Style: This is the set of attributes and their properties.
Geometry Data: This is the collection of buffers that provide the data for each attribute.

How to have multiple instances on the screen of the same sprite at the same time with javafx2

I'm quite new in programming and especially with javafx.
I'm writing a game and i'm trying to visualize at the same time more instances of the same sprite ( a kind of bullet). It translates and rotates.
In my attempts program doesn't work or normally when press 'fire', bullet run but when press 'fire' more times, every time the 'old' bullet' disappear and another bullet starts. Only 1 bullet on the screen at the same time. What have i to do to have more bullets on the screen, exactly one bullet for every time 'fire' is pressed?
Thank you in advance!
You are probably trying to add the same node more than once to the scene graph.
From the JavaFX Node documentation:
A node may occur at most once anywhere in the scene graph. Specifically, a node must appear no more than once in all of the following: as the root node of a Scene, the children ObservableList of a Parent, or as the clip of a Node.
The scene graph must not have cycles. A cycle would exist if a node is an ancestor of itself in the tree, considering the Group content ObservableList, Parent children ObservableList, and Node clip relationships mentioned above.
If a program adds a child node to a Parent (including Group, Region, etc) and that node is already a child of a different Parent or the root of a Scene, the node is automatically (and silently) removed from its former parent. If a program attempts to modify the scene graph in any other way that violates the above rules, an exception is thrown, the modification attempt is ignored and the scene graph is restored to its previous state.
It is possible to rearrange the structure of the scene graph, for example, to move a subtree from one location in the scene graph to another. In order to do this, one would normally remove the subtree from its old location before inserting it at the new location. However, the subtree will be automatically removed as described above if the application doesn't explicitly remove it.
Here is a sample of multiple animated images in a single scene. In the example, multiple nodes are used, each sharing the same Image data. Because Image is not a Node, it can be shared without issue:
How show specific part of an image in javafx

libgdx difference between sprite and actor

I'm just going through the javadoc and various tutorials on libgdx and I'm at the stage of trying to figure out differences between various concepts that seem similar to me or provide similar capabilities in libgdx.
At first I thought scene2d was about creating interactive items such as menus, etc but various tutorials I'm reading use scene2d/actors for the main game items (i.e. the player, etc) and others just use sprites.
What exactly is the difference between using Sprite and Actor (i.e. scene2D) in a game and when should you choose?
Thanks.
A Sprite is basically an image with a position, size, and rotation. You draw it using SpriteBatch, and once you have your your Sprites and your SpriteBatch, you have a simple, low-level way to get 2D images on the screen anywhere you want. The rest is up to you.
Actor, on the other hand, is part of a scene graph. It's higher-level, and there's a lot more that goes into a scene graph than just positioning images. The root of the scene graph is the Stage, which is not itself displayed. The Stage is a container for the Actors that you add to it, and is used for organizing the scene. In particular, input events are passed down through the Stage to the appropriate Actor, and the Stage knows when to tell the Actor to draw itself. A touch event, for example, only gets sent to the Actor that got touched.
But note that Actor does not contain a texture like Sprite does. Instead you probably want to use Image, a subclass of Actor that's probably closer to Sprite than just a plain Actor. Other subclasses of Actor contain text, and so on.
Another big advantage of Actors is that they can have Actions. These are a big topic, but they essentially allow you to plan a sequence of events for that Actor (like fading in, moving, etc) that will then happen on their own once you set them.
So basically Actor does a lot more than Sprite because it's part of a graphical framework.
It is more or less matter of taste. If you want to use actions and stage, use actors. Actors cannot be drawn directly, you need to override draw method. Inside draw you can use sprites.

How to model N threads doing same thing with activity diagram?

I want to draw uml-correct activity diagram representing process of my raytracer.
I know I should use black rectangles to model fork/join. But in my application I spawn N threads doing the same thing (which is not simple and will be modeled via multiple activity elements). How can I draw such activity diagram without having the same thing without knowing number of threads?
My explanation is poor, image may help understand what I want to model with activity diagram
You can use the expansion region element.
There is no way I know of to model a fork of N control flows and I found none in three UML2 books nor the UML2.4.1 formal specification (http://www.omg.org/spec/UML/2.4.1/Superstructure).
That said, using an expansion region with the 'parallel' keyword, you can fork N object flows, processing N objects in parallel.
I am, however, not fully satisfied with this solution because I suspect that you don't create N threads because you have N objects to process but because you have N processor cores and that each thread processes a lot of frames (or whatever objects that need processing).
You can, of course, work around this by using the processor cores as objects.

Resources