1. Am I going to Hell for enjoying programming in Visual Basic in my class today?

Seriously beats making Word and Excel documents.

Code:
```    Sub Main()
Dim weight, waist, neck, hat, shoe As Integer

Console.Write("Input Weight in pounds: ")
Console.Write("Input Waistsize in inches: ")
Console.WriteLine()

neck = 3 * (weight / waist)
hat = (3 * weight) / (2.125 * waist)
shoe = 50 * (waist / weight)

Console.WriteLine("Neck Size: " & neck)
Console.WriteLine("Hat Size: " & hat)
Console.WriteLine("Shoe Size: " & shoe)

Console.WriteLine("Press any key to continue")

End Sub```
Everybody else spent like 10 extra minutes working on that exercise and asking the teacher for help. I feel like an outcast.
Funny x 3 Winner x 1 Friendly x 1 (list)

2. Am I going to Hell for enjoying programming in Visual Basic in my class today?

Seriously beats making Word and Excel documents.

Code:
```    Sub Main()
Dim weight, waist, neck, hat, shoe As Integer

Console.Write("Input Weight in pounds: ")
Console.Write("Input Waistsize in inches: ")
Console.WriteLine()

neck = 3 * (weight / waist)
hat = (3 * weight) / (2.125 * waist)
shoe = 50 * (waist / weight)

Console.WriteLine("Neck Size: " & neck)
Console.WriteLine("Hat Size: " & hat)
Console.WriteLine("Shoe Size: " & shoe)

Console.WriteLine("Press any key to continue")

End Sub```
Everybody else spent like 10 extra minutes working on that excercise...
Better than nothing
Agree x 14 (list)

3. Phong is the reflection model, what you're referring to is phong interpolation. I don't understand why you are having to set this up manually, doesn't opengl have automatically interpolated normals in pixel shaders like dx?
Only if you give it the right information in the right order. If he's drawing that sphere as individual triangles but passing the same normal for every vertex in a triangle he won't see normal interpolation at all. For some reason I'm having a hard time reading his normal calculation code (what's the "norm" variable even for?) or else I'd try to point out a problem there.

4. Only if you give it the right information in the right order. If he's drawing that sphere as individual triangles but passing the same normal for every vertex in a triangle he won't see normal interpolation at all. For some reason I'm having a hard time reading his normal calculation code (what's the "norm" variable even for?) or else I'd try to point out a problem there.
Well that makes sense. I'm only really good with shaders anyway. I just thought he was trying to achieve the reflections, not actually interpolate stuff.

5. I'm working on a terrain generator in Java.
Winner x 2 Informative x 1 Artistic x 1 (list)

6. Only if you give it the right information in the right order. If he's drawing that sphere as individual triangles but passing the same normal for every vertex in a triangle he won't see normal interpolation at all. For some reason I'm having a hard time reading his normal calculation code (what's the "norm" variable even for?) or else I'd try to point out a problem there.

I add a triangle to the polygon and compute the triangles normal.
```void Drawable::addTriangle(const Triangle &tri)
{
int amount = vertex_data.size();
glm::vec3 const & a = tri.v1;
glm::vec3 const & b = tri.v2;
glm::vec3 const & c = tri.v3;

/*
Calculate the normal of the triangle using this formula:
triangle ( v1, v2, v3 )
edge1 = v2-v1
edge2 = v3-v1
triangle.normal = cross(edge1, edge2).normalize()
*/

const glm::vec3 n1 = glm::normalize(glm::cross(b - a, c - a));

vertex_data.push_back(tri.v1);
vertex_data.push_back(tri.v2);
vertex_data.push_back(tri.v3);

uv_data.push_back(tri.u1);
uv_data.push_back(tri.u2);
uv_data.push_back(tri.u3);

norm_data.push_back(n1);
norm_data.push_back(n1);
norm_data.push_back(n1);

index_data.push_back(amount);
index_data.push_back(amount + 1);
index_data.push_back(amount + 2);
}
```

Once all triangles have been added I call phongNormals()

```void Drawable::phongNormals()
{
int amount = vertex_data.size();

//Get a list of all individual vertecies
std::vector<glm::vec3> vecsToCheck;
for(int i = 0; i < amount; i++)
{
bool foundIt = false;

for(int j = 0; j < vecsToCheck.size(); j++)
{
if(vecsToCheck[j] == vertex_data[i]) foundIt = true;
}

if(!foundIt) vecsToCheck.push_back(vertex_data[i]);
}

for(int i = 0; i < vecsToCheck.size(); i++)
{

const glm::vec3 ver = vecsToCheck[i];
std::vector<glm::vec3> norms;
std::vector<unsigned int> indexs;

///compare the current verticie to check with all verticies in the polygon
///if its equal I store that verticies normal(and thus the normal of the triangle it creates) as well as the position that the original normal is stored in.
for(int j = 0; j < amount; j++)
{
if(ver == vertex_data[j])
{
norms.push_back(norm_data[j]);
indexs.push_back(j);
}
}

///
///Using this formula:
///vertex v1, v2, v3, ....
///triangle tr1, tr2, tr3 // all share vertex v1
///v1.normal = normalize( tr1.normal + tr2.normal + tr3.normal )
///

glm::vec3 norm = glm::vec3(0.0f);
for (unsigned int j = 0; j < norms.size(); j++)
{
///add the normal of all the triangles that share the given verticie
norm += norms[j];
}
///normalize it
norm = glm::normalize(norm);

///and replace the old normal with the new one
for (unsigned int j = 0; j < indexs.size(); j++)
{
norm_data[indexs[j]] = norms[j];
}

}

}```

In the vertex shader i multiply the normal by the model matrix to account for rotation or scaling(not translation)
```#version 120
uniform mat4 MVP;
uniform mat4 Model;
attribute vec4 Position;
attribute vec2 UV;
attribute vec3 Normals;
varying vec2 uv;
varying vec3 normals;

void main(){
normals = normalize((Model * vec4(Normals.x, Normals.y, Normals.z, 0.0f)).xyz);
uv = UV;
gl_Position =  MVP * Position;
}```

and then apply it in the frag
```#version 120
varying vec2 uv;
uniform sampler2D myTexture;
uniform bool DrawLines;
varying vec3 normals;
uniform vec4 AmbientLight;
uniform vec4 DiffuseLight;

void main(){
vec4 color;

if(DrawLines)
{
color = vec4(1,1,1,1);
}
else
{
color = texture2D( myTexture, uv ).rgba;

vec3 ambLight = AmbientLight.xyz * AmbientLight.w;

float DiffuseFactor = dot(normals, DiffuseLight.xyz);

vec3 diffLight = vec3(0, 0, 0);
if (DiffuseFactor > 0) {
diffLight = DiffuseLight.xyz * DiffuseLight.w * DiffuseFactor;
}

color.xyz = color.xyz * (ambLight + diffLight);
}

gl_FragColor = color;

}
```

7. -snip'd-
Dumb x 3 (list)

8. this might be too graphic
Funny x 60 Agree x 2 Winner x 2 Artistic x 1 (list)

9. Ludum Dare.
Disagree x 4 Informative x 2 Agree x 1 (list)

10. Anyone know if there is already an app that takes a pass phrase and translates it into a secure password that you can use with a website? If not I was thinking something like this.

Input: Super secure easy to remember passphrase. But goes over the password size limit and doesn't meet the symbol/number requirement.
Output: GP04vg!?9NSEZF\$

I think it would be a nice little app to use with a password manager. That way if you don't have your password file on you, you can still get the password using the pass phrase it derived from. Also it allows you to create a password that is easy to remember and secure without needing the 1 symbol, 1 number most sites require.

11. Anyone know if there is already an app that takes a pass phrase and translates it into a secure password that you can use with a website?
Yes but it costs money: 1password
Disagree x 1 (list)

12. Yes but it costs money: 1password
Does it have that feature? Seems more like just a password manager. Anyways if its costs money then I am going to do something simple/free in javascript(for accessibility).

13. Does it have that feature? Seems more like just a password manager.
Yeah my father bought it; it just runs as a web-browser plugin and whenever you enter a password into a website it translates the password to a very strong one.
This way you can type one password for everything, but actually have many strong passwords.
Informative x 1 Winner x 1 (list)

...

///
///Using this formula:
///vertex v1, v2, v3, ....
///triangle tr1, tr2, tr3 // all share vertex v1
///v1.normal = normalize( tr1.normal + tr2.normal + tr3.normal )
///

glm::vec3 norm = glm::vec3(0.0f);
for (unsigned int j = 0; j < norms.size(); j++)
{
///add the normal of all the triangles that share the given verticie
norm += norms[j];
}
///normalize it
norm = glm::normalize(norm);

///and replace the old normal with the new one
for (unsigned int j = 0; j < indexs.size(); j++)
{
norm_data[indexs[j]] = norms[j];
}

}

...
But unless I'm just blind, you never DO anything with the new normal after you normalize it...right? How are you supposed to adjust for shared vertices like that if you never save the information. That variable just runs out of scope and it's all gone. Barring my potential inability to read code right now, I'd say that's your problem.
Informative x 1 (list)

15. But unless I'm just blind, you never DO anything with the new normal after you normalize it...right? How are you supposed to adjust for shared vertices like that if you never save the information. That variable just runs out of scope and it's all gone. Barring my potential inability to read code right now, I'd say that's your problem.
Well thats slightly embarrassing.

That last for loop should be:
```///normalize it
norm = glm::normalize(norm);

///and replace the old normal with the new one
for (unsigned int j = 0; j < indexs.size(); j++)
{
norm_data[indexs[j]] = norm;
}```

which gives the correct result... Oh the dangers of programming at 4 am.

Thanks for spotting it :D
Winner x 7 Friendly x 1 (list)

16. But unless I'm just blind, you never DO anything with the new normal after you normalize it...right? How are you supposed to adjust for shared vertices like that if you never save the information. That variable just runs out of scope and it's all gone. Barring my potential inability to read code right now, I'd say that's your problem.
I just noticed he uses the word "verticie." Vertex and vertices Richy...

17. I've started using shaders.. Let's just say I don't understand them as well as I'd hoped I would:

This used to be a dice...

Edited:
It's something :/

Next step is figuring out how to do lighting.
Edited:

After searching around I've used this as my shaders.
Is this correct? My lighting seems way off, could that be due to normals being off?
Funny x 8 Artistic x 1 (list)

18. LuaOS seems pretty cool.
Agree x 5 Disagree x 2 Programming King x 1 (list)

19. Spent an interesting afternoon putting up scaffolding :)
I'm back home now, had a bit of a gotcha moment when I realised that textures "belong" to the context that they are bound in, which was the source of a couple of problems for me. For the moment I'm uploading two copies of each texture (which isn't much of a burden), but I'd like to fix that at some point.
Anyway, texture selection/sampling:

Just need to get the file dialog working, and then I could perhaps add mesh importing so you can actually do something useful with the vertex shader. I was thinking of using ROBO_DONUT's BSM lib.
Winner x 1 Artistic x 1 (list)

20. Ok, so I've switched the model to see what'd happen:

I thought, that looks ok!
But then I went INSIDE the ball:

I think my normals weren't what they were supposed to be

Edited:
Yep, that solved my problem.
Winner x 7 (list)

21. Code:
```>(declare i32 printf i8* ...)
; ModuleID = 'JIT'

declare i32 @printf(i8*, ...)

>(declare i32 atoi i8)
; ModuleID = 'JIT'

declare i32 @printf(i8*, ...)

declare i32 @atoi(i8)

>```
Foreign Function Interface declarations.

I love LLVM.
Agree x 1 (list)

Houses are always on their side, right?

Funny x 15 Agree x 1 (list)

Houses are always on their side, right?

How are you handelling obj files with/without some of the attributes?
Such as obj files with only vertecies or ones with normals/vertecies/uv's?

24. I might have messed something up...

Agree x 1 (list)

25. How are you handelling obj files with/without some of the attributes?
Such as obj files with only vertecies or ones with normals/vertecies/uv's?
I'm not. When the file has more than one attribute I just take the vertex and ignore the rest.
It's a terrible method but I can't be arsed to implement all the other stuff right now, I've only just started with all this complicated OpenGL stuff

26. this might be too graphic
Dobby?!
Agree x 2 Dumb x 1 (list)

27. Dobby?!
Yeah?

on topic - wrapping up my fyp:

Funny x 5 Artistic x 1 (list)

28. Heh, just managed to get a gstreamer plugin I'm writing in Vala up and running. Was kind of tough getting it to build correctly since Vala doesn't support DLL targets. I had to compile the C output it spews then link it manually.

It took me a while to figure that out, surprisingly easy once you get to know how it all works though.

Now to the next part, getting my sink to live-stream media over HTTP, not sure how that's going to work as of yet..

29. Also:

Making a minimalistic roguelike for Ludum Dare.
The window is small and the game is minimalistic because the theme is Tiny World. Also because I cannot art.
Funny x 8 Informative x 1 Friendly x 1 (list)

30. Now, every object can be masked/destroyed and still has a fully dynamic pixel-perfect collision model.

You may think the physics suck, that's because they do. I suck at implementing physics calculations.
Winner x 13 Programming King x 6 Artistic x 3 (list)

31. Reminds me of Cortex Command, needs more explosions
Agree x 5 (list)

32. Now, every object can be masked/destroyed and still has a fully dynamic pixel-perfect collision model.

You may think the physics suck, that's because they do. I suck at implementing physics calculations.
Why do the particles slow down when they are about to hit the ground?

33. Why do the particles slow down when they are about to hit the ground?
You may think the physics suck, that's because they do. I suck at implementing physics calculations.

Well, to make them stack up and collide properly without falling into each other, I stop them in mid air, when the next update cycle would have them colliding with a blocking pixel. after that, only gravity remains, pulling them down. Instead, I would have to move them backwards until they do not collide anymore, but that's a to-do.

34. Well that was more of a pain than it should have been. wxWidgets pretty much insists on using unicode strings for everything, and the first couple of characters of the file paths were getting mangled when I converted them to regular strings for file loading. All fixed now though, I can load the exported heightmap TGAs from the terrain thing.

Edited:

I was thinking that I need some way of saving/loading shader files. I thought the most clutter-free way of doing it would be to just right-click on the text box and click "Save"/"Load"? Plus the regular Ctrl+S and Ctrl+O.

Edited:

Loaded up my old terrain raymarcher shader, along with the textures. It works! :D
Artistic x 7 Programming King x 1 (list)

35. I'm doing something very evil right now: generating machine code at runtime and executing it. Together with the Intel manual and x86asm.net, I'm now working on a little class that allows you to generate programs at runtime from C++.

An example:

```#include <cstdio>
#include "Assembler.hpp"

int main()
{
Assembler as;
as.IMov32( REG_EAX, 2 );
as.IMov32( REG_ECX, 4 );
int eax = as.Run();

printf( "EAX contains %d\n", eax );

return 0;
}```

Remember that this is not a virtual machine, this is actual code being run on the processor. The assembler class outputs machine code to a buffer that is copied into memory and called as a function:

```...

void Assembler::IMov32( Register dst, int value )
{
code.push_back( 0xC7 );
code.push_back( 0xC0 | dst );
PushInt32( value );
}

void Assembler::IMov32( Register dst, Register src )
{
code.push_back( 0x8B );
code.push_back( 0xC0 | ( dst << 3 ) | src );
}

...```

You can see how it works here. I'm not planning to go very far with this, but I'd like to create a Brainfuck compiler with it.
Programming King x 6 Useful x 3 Artistic x 1 (list)

36. Been really into stealthy type games lately and decided to work with that as a new project.

I've started a top down shooter style stealth game but the gimmick is that the levels/missions will be randomly generated for infinite replay value and fun times.

How do you guys make gifs of your work? Screenshots just won't get the message across.

37. I had imagined I could do this, but it almost seemed to good to be true:

1000 samples, 3 minutes 38 seconds

Same scene, same samples, 3 minutes and 39 seconds

Originally, I had been sampling from a ray sent down the center of a given pixel. Then I changed this to randomly select rays within the pixel's area. Voila, free anti-aliasing. (I actually think this is the right way to do it in the first place)
Winner x 7 Artistic x 4 (list)

38. Don't have any pictures but currently I'm working on a sort of demo for when I apply to any software companies. Only goals so far are to generate a planet based on a seed and be able to keep detail up at ground level.
Winner x 3 Programming King x 1 (list)

39. Don't have any pictures but currently I'm working on a sort of demo for when I apply to any software companies. Only goals so far are to generate a planet based on a seed and be able to keep detail up at ground level.
Nice, thats what im learning OGL to try to accomplish.
I was thinking of something like a procedural planet generation for my fyp, tho i still have another year for that.

something like these: