These are chat archives for opentk/opentk

18th
Dec 2017
Kristoffer Semelka
@krstoff
Dec 18 2017 07:16
Wow, the link to opentk documentation is... a web.archive.org link.
Kristoffer Semelka
@krstoff
Dec 18 2017 07:59
@varon you mentioned earlier in this chat log that the XML documentation in the assembly is great. But how do I browse this? I'm just looking for a quick way to look over the API, I don't need a tutorial or anything like that.
Ghost
@ghost~59d9ee50d73408ce4f7916bf
Dec 18 2017 08:25
Wow i don't see documentation of opentk please don't hide me i feel stupid
I will go back and develop again!
varon
@varon
Dec 18 2017 10:49
@krstoff - it'll show up in your IDE, use ctrl+space and start reading what stuff does.
The documentation is an archive.org link because the old website got taken down and the domain owner vanished.
and... nobody has yet PR'ed in stuff to our new website.
If you'd like to help on that, it would be amazing.
chatbridge
@chatbridge
Dec 18 2017 11:33
(Discord) Secticide: It would be awesome use those XML comments with DocFX: https://dotnet.github.io/docfx/
(Discord) Secticide: It'd generate some nice API reference pages for the website, example here: http://doc.xenko.com/latest/en/api/SiliconStudio.Xenko.Engine.Entity.html
Dternity
@Dternity
Dec 18 2017 17:50
We're using SFML with the .NET binding and we're moving as much as we can away from SFML's codebase to be more inline with OpenTK's codebase. I've just implemented a basic icon system of which me make the icons using an vertex array then position and size it where we want. The trouble is Transforms. I have no clue how they how and what each of the separate variables inside the 9x9 matrix does. I've identfied what i think is location(m10 & m12) and maybe scale(m00 & m11).
There i no information what these values represent that i could find so I'm starting to think that I'm wrong in my understanding on how translations work
Basically what i want to do is move and resize the vertex array where i want it
Also when changing scale it affects the location of the vertex array for some reason.
chatbridge
@chatbridge
Dec 18 2017 17:55
(Discord) Jax (Nihlus): @Dternity Why don't you use the Translation/Rotation/Scale methods on Matrix3?
Dternity
@Dternity
Dec 18 2017 18:04
Isn't that basically the same as a transform since it contains 9 values ? (I'm making a UI framework using 2D, shouldn't i use Matrix2?)
Rosen Iliev
@winterhell
Dec 18 2017 18:07
From what I understand, for just 1 transformation you can use a 3x3 matrix for 3D and 2x2 matrix for 2D
but to stack multiple operations, you need a 4x4 matrix and maybe 3x3 respectively
chatbridge
@chatbridge
Dec 18 2017 18:12
(Discord) Jax (Nihlus): A matrix contains a complete set of rotation, translation, and scale data
(Discord) Jax (Nihlus): (a 3x3 matrix, that is)
(Discord) Jax (Nihlus): You can combine and alter that data by multiplying matrices together
Dternity
@Dternity
Dec 18 2017 18:13
image.png
I am very confused now
chatbridge
@chatbridge
Dec 18 2017 18:13
(Discord) Jax (Nihlus): You should not be editing the contents of the matrix directly
(Discord) Jax (Nihlus): (unless you know what you're doing)
(Discord) Jax (Nihlus): Store your transform values as euler angles, scale factors, and vector offsets
varon
@varon
Dec 18 2017 18:14
The only reason to use matrices is for performance, later on, when you have to.
keep things simple for now.
chatbridge
@chatbridge
Dec 18 2017 18:14
(Discord) Jax (Nihlus): Then, when the time comes to create a transform matrix, use the static methods and multiply the resulting matrices together in the correct order
varon
@varon
Dec 18 2017 18:15
tbh you can do the whole of 2D without a matrix, it's a bit slower but it'll work fine.
chatbridge
@chatbridge
Dec 18 2017 18:15
(Discord) Jax (Nihlus): Yeah
(Discord) Jax (Nihlus): Good to learn though
Dternity
@Dternity
Dec 18 2017 18:16
I need to use some kind of transformation on the vertex array or else i have to use SFML shapes or rebuild the vertex arrays every draw frame
chatbridge
@chatbridge
Dec 18 2017 18:17
(Discord) Jax (Nihlus): Do your transforms in your shader
Dternity
@Dternity
Dec 18 2017 18:17
We're not using shaders, it's an UI framework
chatbridge
@chatbridge
Dec 18 2017 18:17
(Discord) Jax (Nihlus): Eech. Should still use shaders
varon
@varon
Dec 18 2017 18:17
if you're using OpenGL, you HAVE to use shaders...
chatbridge
@chatbridge
Dec 18 2017 18:17
(Discord) Jax (Nihlus): Yeah unless you're using the old FFP
(Discord) Jax (Nihlus): (which you should not be doing)
Dternity
@Dternity
Dec 18 2017 18:18
I think we're using OpenGL1 haha
chatbridge
@chatbridge
Dec 18 2017 18:18
(Discord) Jax (Nihlus): aaaaah
(Discord) Jax (Nihlus): no
(Discord) Jax (Nihlus): stop
varon
@varon
Dec 18 2017 18:18
use 3.3 core or upwards
Dternity
@Dternity
Dec 18 2017 18:18
We had some issues with the application running with OpenGL4 and OpenTK seems to only support those 2
chatbridge
@chatbridge
Dec 18 2017 18:18
(Discord) Jax (Nihlus): OpenTK supports all OpenGL profiles
Dternity
@Dternity
Dec 18 2017 18:19
Oh
varon
@varon
Dec 18 2017 18:19
you just need to create a different context.
Dternity
@Dternity
Dec 18 2017 18:19
But basically how we draw the controls is using rectangles(We hate rounded controls) and pure colors
varon
@varon
Dec 18 2017 18:20
you should STILL do that with shaders :)
just have a simple one colour shader and set the colour as a uniform
chatbridge
@chatbridge
Dec 18 2017 18:20
(Discord) Jax (Nihlus): Yeah. Those verts should be sent to the shader and drawn to screen space there
Dternity
@Dternity
Dec 18 2017 18:20
Mind blown
Rosen Iliev
@winterhell
Dec 18 2017 18:20
OpenGL4 is just an namespace
varon
@varon
Dec 18 2017 18:20
OpenGL is pretty crazy until you get used to it
chatbridge
@chatbridge
Dec 18 2017 18:21
(Discord) Jax (Nihlus): In fact, you could probably do things a lot quicker using geometry shaders but that's outside the scope of this convo
Rosen Iliev
@winterhell
Dec 18 2017 18:21
In fact, OpenGL4 works even on systems that have only OpenGL 2.0
chatbridge
@chatbridge
Dec 18 2017 18:21
(Discord) Jax (Nihlus): ...no?
Dternity
@Dternity
Dec 18 2017 18:21
We're using the "OpenGL" namespace
varon
@varon
Dec 18 2017 18:21
(the namespace, he means, @nihlus)
Rosen Iliev
@winterhell
Dec 18 2017 18:21
Thought you wont be using VAOs on a 2.0 system
Yeah, the OpenGL4 namespace is misleading
chatbridge
@chatbridge
Dec 18 2017 18:22
(Discord) Jax (Nihlus): OpenGL 4 is most certainly not available on a 2.0 system. You're going to get a 2.0 context
(Discord) Jax (Nihlus): Ah
(Discord) Jax (Nihlus): On that topic... I'd like to remove deprecated functions from their respective profile classes for the 4.0 release of OpenTK. So if you're using the 3.3 core profile namespace, you can't use FFP
Dternity
@Dternity
Dec 18 2017 18:23
Okay, so what are my options here ? Rebuilding the vertex array every frame, use transformation on the renderstate or use geometry shader ?
chatbridge
@chatbridge
Dec 18 2017 18:23
(Discord) Jax (Nihlus): It's deprecated, so why provide it in that namespace etc
(Discord) Jax (Nihlus): It all depends on what you want to do
(Discord) Jax (Nihlus): Learn how shaders work first
Dternity
@Dternity
Dec 18 2017 18:24
Move and resize the verts
Rosen Iliev
@winterhell
Dec 18 2017 18:24
I can tell you
chatbridge
@chatbridge
Dec 18 2017 18:24
(Discord) Jax (Nihlus): You can do any of the ones you listed
Rosen Iliev
@winterhell
Dec 18 2017 18:24
For example you want to draw sprites
Dternity
@Dternity
Dec 18 2017 18:24
We're not using image files
Rosen Iliev
@winterhell
Dec 18 2017 18:24
The way I'm doing it, I have a bound VBO/VAO with coordinates -1,-1 through +1,+1
same thing applies
chatbridge
@chatbridge
Dec 18 2017 18:25
(Discord) Jax (Nihlus): Yeah, a sprite is just a textured quad
(Discord) Jax (Nihlus): You want to draw a coloured quad
Rosen Iliev
@winterhell
Dec 18 2017 18:25
Then you pass to the shader XY coordinates of the center of the image/rectangle, and XY for scale
and render
So its just 1 uniform value of Vector4
You dont have to update the VBO or change the shader
Its heck fast
more than 10 million per second individual draw calls like that
And you can make an array of uniforms and batch it and render like that
Dternity
@Dternity
Dec 18 2017 18:26
Shit, i got a metric ton of reading up to do
Rosen Iliev
@winterhell
Dec 18 2017 18:27
Or you can have a VBO with like 100 vertices, and you update them all with the XY coordinates and XYZA color values
And then do 1 draw call
It'll again be many times faster than your solution with GL.Begin(), GL.Vertex(), GL.Color(), etc
Dternity
@Dternity
Dec 18 2017 18:28
We need to completely redo the whole framework now xD
chatbridge
@chatbridge
Dec 18 2017 18:28
(Discord) Jax (Nihlus): Chop chop lol
Rosen Iliev
@winterhell
Dec 18 2017 18:28
On that note, if what you have already works, and you dont plan to break it, there is that
But shaders and modern opengl as we know it has been around since 2002, the first DirectX 9 cards
except the VAO thing
Dternity
@Dternity
Dec 18 2017 18:29
The only problem is that we don't want to use SFML
Rosen Iliev
@winterhell
Dec 18 2017 18:29
OpenTK is not using it
Nor its using SDL2
Dternity
@Dternity
Dec 18 2017 18:29
I know but OpenTK's text support is horrible
Rosen Iliev
@winterhell
Dec 18 2017 18:30
What text you need to do?
Dternity
@Dternity
Dec 18 2017 18:30
Resize at runtime
chatbridge
@chatbridge
Dec 18 2017 18:30
(Discord) Jax (Nihlus): OpenTK doesn't really have text support
(Discord) Jax (Nihlus): It's a low-level OpenGL wrapper
(Discord) Jax (Nihlus): You're going to have to roll your own solution
Rosen Iliev
@winterhell
Dec 18 2017 18:31
Graphics gfx = Graphics.FromImage(text_bmp);
        gfx.Clear(Color.Transparent);
        gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
        Brush brush = Brushes.Black;
        gfx.DrawString(text, font, brush, 0, 0, StringFormat.GenericDefault);
For those you need
using System.Drawing;
using System.Drawing.Imaging;
And also you'll init a font from somewhere etc
its really a dozen lines of code
Dternity
@Dternity
Dec 18 2017 18:32
You can't change the size of the font at runtime without it getting blury
Rosen Iliev
@winterhell
Dec 18 2017 18:32
But it uses GDI+ and System.Drawing.Bitmap
Dternity
@Dternity
Dec 18 2017 18:32
GDI+ is rendered on the CPU, no thanks
chatbridge
@chatbridge
Dec 18 2017 18:32
(Discord) Jax (Nihlus): That's down to the resampling algorithm used
Dternity
@Dternity
Dec 18 2017 18:32
We need as much free time for the CPU for the game
Rosen Iliev
@winterhell
Dec 18 2017 18:33
And mind telling me that SMFL is rendering the font in realtime on the GPU ?
Compute Shaders?
Dternity
@Dternity
Dec 18 2017 18:33
It is ?
Rosen Iliev
@winterhell
Dec 18 2017 18:33
Hell no
Dternity
@Dternity
Dec 18 2017 18:33
What
Rosen Iliev
@winterhell
Dec 18 2017 18:33
Yeah, mind blown right
Dternity
@Dternity
Dec 18 2017 18:33
Wait
Rosen Iliev
@winterhell
Dec 18 2017 18:33
You havent even tried it
Want to hear a benchmark?
Dternity
@Dternity
Dec 18 2017 18:34
So GDI+ is actually doing the text rendering ?
Rosen Iliev
@winterhell
Dec 18 2017 18:34
With GDI+ you can do 100 000 character per second
Probably
chatbridge
@chatbridge
Dec 18 2017 18:34
(Discord) Jax (Nihlus): You really shouldn't be optimizing at this point
(Discord) Jax (Nihlus): Make it work, then make it work well, then make it work fast
Rosen Iliev
@winterhell
Dec 18 2017 18:34
Yeah you dont even know how fast is it running
let alone determine what is the bottleneck
Dternity
@Dternity
Dec 18 2017 18:35
Mind blown
Rosen Iliev
@winterhell
Dec 18 2017 18:36
Your fixed functionality pipeline might be even 20 times slower than what you can do with modern opengl, but it might turn out its still fast enough
Dternity
@Dternity
Dec 18 2017 18:37
I guess we'll be moving back to OpenTK in that case
While i have you great wizards here, i was thinking on making the a font with vertices and actually the defining the characters by hand. Wouldn't that be the absolute fastest way of drawing text on screen ?
chatbridge
@chatbridge
Dec 18 2017 18:42
(Discord) Jax (Nihlus): Sort of, but you'd be better off using a vectorized font
(Discord) Jax (Nihlus): It's effectively the same thing as what you're saying
varon
@varon
Dec 18 2017 18:45
easiest thing is distance field
it's like a non-shitty bitmap.
easy to generate offline too.
Dternity
@Dternity
Dec 18 2017 18:46
Alright, thanks guys :)
Rosen Iliev
@winterhell
Dec 18 2017 18:47
I'd still recommend trying to render from GDI+, and only when it gets to the point that it hinders your performance, to think about changing something
Dternity
@Dternity
Dec 18 2017 18:49
The game we are making is purely UI based so CPU time will be at a luxury, we want all things that can be moved onto the GPU instead of the CPU
ThomasD13
@ThomasD13
Dec 18 2017 21:32
Maybe a bit late but: I use SharpFont for rendering Text with OpenGL
It brings its own shader maybe the slowest part of it is to change the program.
Under the hood it works with vbos
No complains so far from Herr
Here
Dternity
@Dternity
Dec 18 2017 22:18
We tried the C# version(QuickFont) very little documentation so we ended up not using it. We've decided to stick with SFML now because it would take weeks to re-do the framework
Thanks though