Mat2012H

u/Mat2012H




r/learnprogramming•

I started learning Haskell today (Coming from other languages), and I been trying to make a simple program is meant to calculate an average based on user input.

  1. Asks user for the number of values to calculate an average for
  2. Sums up user input
  3. Calculate average
  4. Print average

My code probably isn't great, but here it is:

avg.hs gist

and I am getting several errors, but I have no idea what these actually mean:

errors gist

Any help for what these errors mean for someone new to Haskell, as well as any code improvements

12

r/learnprogramming•

I want to export a simple project template using Visio Studio for OpenGL, so I don't have to set this up every time I want to create a project.

The project tree looks like this:

https://i.imgur.com/gJDNNef.png

As you can see, I have some source and header files, and some DLL files, which have all been added to be part of the solution.

So, I got to Project > Export Template... and select Project template

https://i.imgur.com/NJMXoda.png

On the next page of the wizard, I give it a name etc.

https://i.imgur.com/Kl1lTsH.png

When I go to create a new project, as expected, my custom template appears in the list of project templates.

https://i.imgur.com/WoMntZB.png

However, when I a

00


r/opengl•

I am trying to replicate a torch beam effect, similar to the ones from Doom 3 or Slender.

However, I cannot work out how to get this kind of effect. Messing with shaders, I managed to get this:

https://i.imgur.com/fORH4A9.png

This is nearly what I want, except for it is literally just a circle in the middle of the screen where light is, and then darkness outside it.

https://i.imgur.com/wgGbCC8.png

Here is my "spotlight.frag" shader: https://pastebin.com/Nm6xK9Cv

The inputs are:

passNormalDirection this is

310

r/opengl•

When I have been creating programs in C++ and OpenGL, a typical thing I do is create a renderer class, shader class, and GLSL shaders for each type of object/ entity/ thing I need.

For example, I might have something like this:

  • WaterShader.h/.cpp
  • WaterRenderer.h/.cpp
  • WaterShader.vert/.frag
  • FloraShader.h/.cpp
  • FloraRenderer.h/.cpp
  • FloraShader.vert/.frag
  • TerrainShader.h/.cpp
  • TerrainRenderer.h/.cpp
  • TerrainShader.vert/.frag

etc etc

Why? Because each "object" has different requirements.

For example, the water may require some kind of alpha blending, so I would enable that in the water renderer class and then iterate through water objects that need to be drawn, while

188