Graphic Programming In C

0 views
Skip to first unread message

Lauro Pericles

unread,
Aug 3, 2024, 5:06:27 PM8/3/24
to thatspocontbelt

In computing, a visual programming language (visual programming system, VPL, or, VPS), also known as diagrammatic programming,[1][2] graphical programming or block coding, is a programming language that lets users create programs by manipulating program elements graphically rather than by specifying them textually.[3] A VPL allows programming with visual expressions, spatial arrangements of text and graphic symbols, used either as elements of syntax or secondary notation. For example, many VPLs are based on the idea of "boxes and arrows", where boxes or other screen objects are treated as entities, connected by arrows, lines or arcs which represent relations. VPLs are generally the basis of Low-code development platforms.

VPLs may be further classified, according to the type and extent of visual expression used, into icon-based languages, form-based languages, and diagram languages. Visual programming environments provide graphical or iconic elements which can be manipulated by users in an interactive way according to some specific spatial grammar for program construction.

As of 2005, current developments try to integrate the visual programming approach with dataflow programming languages to either have immediate access to the program state, resulting in online debugging, or automatic program generation and documentation. Dataflow languages also allow automatic parallelization, which is likely to become one of the greatest programming challenges of the future.[5]

The Visual Basic, Visual C#, Visual J# etc. languages of the Microsoft Visual Studio integrated development environment (IDE) are not visual programming languages: the representation of algorithms etc. is textual even though the IDE embellishes the editing and debugging activities with a rich user interface. A similar consideration applies to most other rapid application development environments which typically support a form designer and sometimes also have graphical tools to illustrate (but not define) control flow and data dependencies.

The following list is not mutually exclusive, as some visual programming environments may incorporate elements from multiple paradigms. The choice of visual programming paradigm often depends on the specific requirements of the application or the preferences of the users or the developers.

Most of the VPLs are designed for education or domain-specific usage where is the target users are novice programmers. But there are some research projects try to provide a general-purpose visual programming language that can be used by mainstream programmers in any software project instead of using textual programming languages like (C, C++, Java, etc.).

For example, research projects such as Envision [8][9] and PWCT[10] are designed to achieve this goal. It's common for a VPL to be developed using a textual programming language. Developing general-purpose VPLs allows the other way around. For example, a new textual programming language Compiler and Virtual Machine is developed using visual programming in 2016.[11]

Many modern video games make use of behavior trees, which are in principle a family of simple programming languages designed to model behaviors for non-player characters. The behaviors are modeled as trees, and are often edited in graphical editors.

Ever since I opened up my Direct Messages and invited everyone to ask me computer graphics related questions on Twitter, I am very often asked the question"How can I get started with graphics programming?".Since I am getting tired of answering this same question over andover again, I will in this post compile a summary of allmy advice I have regarding this question.

Quite a few API:s for coding against the GPU hardware have appeared over the years: Direct3D, OpenGL, Vulkan, Metal, WebGL, and so on.These API:s can be difficult to get started with, since they often require much boilerplate code, and I consider that they are not beginner friendly at all.In these API:s, even figuring out how to draw a single triangle is a massive undertakingfor a complete beginner to graphics.Of course, an alternative is that we instead use a Game Engine like Unity and Unreal Engine. The game engine will be doing the tedious workof talking to the graphics API for you in this case. But I think that even a game engine is too much to learn for a complete beginner,and that time should be spend on something a bit simpler.

Instead, what I recommend for beginners, is that they writethemselves either a raytracer or a software rasterizer(or both!). Put it simply, A raytracer is a programthat renders 3D scenes by sending out rays from every pixel in the screen,and does a whole bunch of intersection calculations and physical lighting calculations, in order to figure out the final color of each pixel. A software rasterizer, renders 3D scenes(which in a majority of cases is just a bunch of triangle) like this:for every triangle we want to draw, we figure out which pixels on the screen thattriangle covers, and then for each such pixel, we calculate how the light interacts with the point on the triangle that corresponds to the pixel.From this light interaction calculation, we obtain the final color of the pixel.Rasterization is much faster than raytracing, and it is the algorithm that modern GPU:s uses for drawing 3D scenes. And software rasterization, simplymeans that we are doing this rasterization on the CPU, instead of the GPU.

Both rasterization and raytracing are actually two pretty simple algorithms,and it is much easier for a beginner to implement these,than it is to figure out modern graphics API:s.Furthermore, by implementing one or both of these, the beginner will be introduced to many concepts that are fundamental to computer graphics, likedot products, cross products, transformation matrices, cameras, and so on,without having to waste time wrestling with modern graphics API:s.I believe that these frustrating graphics API:s turn off a lot of beginnersfrom graphics, and making your first computer graphics project into a rasterizer or a raytraceris a good way of getting around this initial hurdle.

Note that one large advantage to writing a software rasterizer before learning a graphics API, is that it becomes much easier to debug things when things inevitably go wrong somewhere, since these API:s basically just provide an interfaceto a GPU-based rasterizer(note to pedantics: yes,this is a great simplification,since they provides access to things like computer shaders as well). Since you know how these API:s work behind the scenes,it becomes much easier to debug your code.

My next advice is that you should study the math you need for computer graphics. The numberof math concepts and techniques I use in my day-to-day work as a graphics programmeris surprisingly small, so this is not as much work as you might think.When you are a beginner in graphics, a field of mathematics called 'linear algebra' will be your main tool of choice. The concepts from linear algebra that you will mostly be using are listed below

From the beginner to intermediate level, you will mostly not encounter anyother math than the above. Once you get into topics like physically based shading, a field of mathematics called 'calculus' also becomes useful, but that is a story for another day :-).

I will list some resources for learning linear algebra. A good online mathbook on the topic is immersive linear algebra.A good video series on the topic that allows you to visualize many concepts isEssence of linear algebra. Also, this OpenGL tutorial has useful explanations of elementary, yet usefullinear algebra concepts. Another resource isThe Graphics Codex.

Once you have written a raytracer or rasterizer, you will feel more confidentin learning a graphics API. The hello world of learning a graphics API is to simply draw a triangle on the screen. It can actually be surprisingly difficult to draw your firsttriangle, since usually a large amount of boilerplate is necessary, and debugging graphics code tends to be difficult for beginners.In case you have problems with drawing your first triangle, and is gettinga black screen instead of a triangle, I will list some debugging advice below.It is a summary of the steps I usually go through when I run into the same issue.

Advice 4: Good Projects for BeginnersIn my view, the best way to become good at graphics, is to work on implementingvarious rendering techniques by yourself. I will below give a list of suggestions ofprojects that a beginner can implement and learn from.

LinkedIn and 3rd parties use essential and non-essential cookies to provide, secure, analyze and improve our Services, and to show you relevant ads (including professional and job ads) on and off LinkedIn. Learn more in our Cookie Policy.

Drawing things on a computer is really fascinating. In fact, it was one of the first things I figured out to do when I got my first Z-80 based computer! However, there is a lack of quality information on the web for someone looking to start on graphics programming. Simple google searches such as "graphics programming" or "how to program computer graphics" can either misled them to learn obsolete technologies such as BGI or get them overwhelmed with advanced 3D programming. In this article, I hope to present a gentle introduction to computer graphics programming and provide useful pointers.

Graphics programming is a very (visually) rewarding experience. You can draw really cool pictures, make your own games, create business charts, render your own worlds (AR, VR, etc.)... In short, you can unleash your creativity!

If you are just getting started, and have the itch to draw something on a screen, don't despair. It is very easy! Turtle Logo is a very small programming language that enables you to draw vector graphics very easily. Try online at

There are a lot of libraries that do much of the heavy lifting for you. A basic understanding of Analytic Geometry, Matrices, and Linear Algebra would help you a lot when you want to draw things on a screen, or on everyday projects.

c80f0f1006
Reply all
Reply to author
Forward
0 new messages