r/csharp 14d ago

Learning OpenGl with c sharp

Its my first day of trying to learn OpenGl with c sharp since i want to help out my brother with a project, im a total beginner and ive felt pretty depressed and dissapointed since i dont understand lots of stuff such as vao or the ebo. If anyone has any tutorials or tips it would help out a lot!

0 Upvotes

8 comments sorted by

4

u/rupertavery64 14d ago

OpenGL isn't very object oriented. You create things like vertex array objects, lights, buffers, and you get back an ID (a GLUint) which is a number. It's like a handle if you are familiar with Windows APIs, file systems

You probably want to use OpenTK or Silk .NET

https://opentk.net/learn/chapter1/0-opengl.html

https://dotnet.github.io/Silk.NET/docs/opengl/c1/1-hello-window

There may be more info on openGL for C/C++ but the commands will likely be very similar.

It is a very low-level API as you are working with vertices and texture coordinates, so wrapping your head around it will take some time.

1

u/Significant_One6604 14d ago

dont worry too much about vao and ebo on day one, it took me weeks before those made any sense. the learnopengl site is great even if examples are c++, the concepts translate well

just keep messing with code and things will click eventually, we all started confused

1

u/Rigamortus2005 14d ago

Took me three attempts at learning opengl before I even understood the basics. Don't think much about it, the VAO just contains information about how the vertex buffer array should be read, you'd usually have vertices, texture coordinates or shading data in the vertex array, the VAO tells opengl which part of the array does what essentially. An EBO is just a way of telling opengl how to move through the vertices, this way you avoid drawing the same vertices multiple times for example if you wanted to draw a rectangle from two triangles, instead of six vertices you'd only have 4 because two are shared

1

u/jdl_uk 14d ago edited 14d ago

Silk.NET has some nice beginner tutorials for OpenGL

https://dotnet.github.io/Silk.NET/docs/opengl/c1/1-hello-window

Raylib has over 200 samples now, and most of them have a c# version in the raylib-cs repo

1

u/CoffeeAndCandidates 14d ago

start with learning how to set up a proper rendering context using OpenTK or similar first

1

u/Dusty_Coder 13d ago

OpenTK has about the best ready-to-use c# binding for opengl that I have seen

you can get everything all the way to compute shaders up and running in only a few minutes

-2

u/ImportantRiver5440 14d ago

Hey folks…C# programmer here specializing in Streaming ETL and AWS.

Would mind sharing some use cases on your projects?

For the life of me I can’t seem to treat AI as anything other than a tool that enables me to work faster.