Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 28 Apr 2007
Offline Last Active Yesterday, 10:57 PM

Topics I've Started

HLSL 5 to GLSL cross compiler

08 September 2014 - 03:11 PM

Right now I am working on a graphics engine for my next game. I have tried using Ogre in the past but it feels too outdated. In my over ambitious quest to make a cross platform and cross API graphics engine I have decided to make a HLSL to GLSL cross compiler. I know there is already a cross compiler for DX9 HLSL, but I want a cross compiler that works with DX11.


Its nowhere near being complete but I thought I would post a link to the repo if anybody was interested in helping or using the project.


The cross compiler is located under the subdirectory ShaderBunder/HLSLParser


If you would like to contribute to the project let me know

If you would like to use this let me know and let me know what features you need


It isn't ready for use yet, but I wanted to get some feedback to make sure I am not taking this in the wrong direction.


15 August 2014 - 02:59 PM

A friend of mine told me about an experience he had in one of his programming classes. I found it funny, so I thought I would share it here.

Programming joke of the day; this actually happened to me:

We have a little program we need to run on our code called "Checkstyle" that goes through our code to find anything stylistically wrong with it. If it doesn't pass check style, we can't get credit on it. Sometimes, it takes issue with stuff that really shouldn't (in my opinion) be an issue.

Today, it spat out a bunch of error messages telling me that some of my lines of code were more than 100 characters long. I said "Are you kidding me? We aren't allowed to have lines of code longer than 100 characters?"

A haughty T.A. passing by said "Of course. Checkstyle likes readable code. It's more professional."

A person sitting next to me said "Hey, if your line is too long, try taking out the 'space' characters between your operators and your operands. They aren't needed to compile anyway."

I said "Great Idea! That'll cut down the line size, which makes it more readable, right?"

Somebody else suggested "Are your variable names too long?"

I said "Yeah, probably. I'll global search and replace them into names that are only one character long. That should help too."

After looking at my code, I found that the issue was my error message. My error message was about 60 characters long, politely informing that the only legal strings allowed in the method are "heads" and "tails". I replaced the error message with a frowny face emoticon instead.

After putting the finishing touches on my code, I ran it through checkstyle. It passed. I got 102% on the lab. I'm so glad they gave me such a wonderful tool to make my code more professional and readable!

Along a similar vein, checkstyle doesn't like "magic numbers." In one lab, it told me that "4" was a magic number, and needed to be replaced. In class, somebody commented on it. "What is a magic number, and how do you avoid using them?"

The teacher said "A magic number is a number in the code that is there for no apparent reason, but makes the program work right. Typically, you should replace them with global variables. Like, can anybody tell me how to handle the magic number '4' in the first lab?"

I raised my hand.

"Well, '1' isn't considered a magic number, so just replace all instances of '4' with '(1+1+1+1)."

The entire class laughed. Including the teacher.

"Just in case you were wondering," he added, "that was not the right answer."

Weird Syntax Tricks

23 July 2014 - 02:04 PM

So I was looking to see if any languages supported overloading a function by return type and found this answer.

The bottom of the post contained this snippet of code that fakes overloading by return type in c++. 

struct func {
   operator string() { return "1";}
   operator int() { return 2; }

int main( ) {
   int x = func(); // calls int version
   string y = func(); // calls string version
   double d = func(); // calls int version
   cout << func() << endl; // calls int version
   func(); // calls neither

While I would never use this hack in a real project, it does make a fun exercise in understanding c++.


What other examples of strange language hacks do you know of?


28 June 2014 - 02:44 AM

I am working with directx for the first time in a a long time. I am working on generating input layouts and notices that DXGI_FORMAT_R8G8B8_UNORM doesn't exist.  R8, R8G8, and R8G8B8A all exist. For some reason R8G8B8 doesn't. Why is that? Why add support for 1, 2 and 4 normalized byte components but leave out support for 3? It seems like it is a common use case to have a RGB color stored as bytes, yet this is left out.

Linking error caused by adding DxErr.lib

22 June 2014 - 01:03 AM

I am working on a DirectX project and I can build and link the project just fine without adding DxErr.lib to the project. When I add the line

#pragma comment (lib, "DxErr.lib")

To include the library, without even referencing it, I get a linking error to D3D11CreateDevice even though that function is defined in d3d11.lib.


Error 1 error LNK2019: unresolved external symbol _D3D11CreateDevice@40 referenced in function "public: __thiscall DX11Graphics::DX11Graphics(void)" (??0DX11Graphics@@QAE@XZ) DX11Graphics.obj DeferredRendering

If I don't include DxErr.lib then it links just fine.


Any thoughts as to why this is happening? This problem has me stumped.