Shaders, Shaders, Shaders…

Long time no post… Have been busy finishing my degree and dealing with some non college related work, getting hyped for the day I get my bachelor degree and start a new life chapter!

Anyway, just a quick update with something I did today, I’m learning OpenGL 3.3 shaders in a subject, which is something I was looking forward to learn for some time. Monday’s class was about texturing and the final exercise was to create a multi textured crate with an ugly snow flake on it & diffuse + specular illumination. After the multi textured crate was done, had to mess it up a little, just for the fun of it:

Image

First milestone, blah

Image

Final result

- Triple multitexture with linear blending

- Alpha attenuation in moss layer

- Ambient + Diffuse + Specular lighting

The cake image is from Borgore – Decisions marketing stuff, all rights reserved to Borgore and his awesomeness.

One problem I struggled while implementing this was that I had an uniform in the shaders named very similarly but not the exact same as the location I was querying OpenGL in my application. When dealing with textures this is something you will only have a problem when you try to sample two different textures in the same shader program. And why is that? Because by default, when you run glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture1);, without setting the uniform, OpenGL will propagate texture1 to all the samplers in your shader, therefore, if you only want one, there will be no problem at all… Always learning!

That’s all for today, but don’t forget:

Image

How to: Bullet Physics in Visual Studio 2012

I’m going to use Bullet Physics in a university course this semester, as usual, the online documentation to create projects from scratch always lacks something / are outdated / all sorts of useless time consuming crap.

Creating a project from scratch with Bullet is actually pretty simple, this are the steps:

In this example I’m supposing you downloaded the file “bullet-2.81-rev2613.zip” and extracted it to “c:\bullet-2.81-rev2613″

  • Bullet comes already with all the compiled to your environment, but you can compile them for yourself using CMake ( Bullet wiki has a fairly good tutorial on this ) or Premake4. We are going to use the ones that already come with Bullet for simplicity.
  • Create a new C++ Win32 Console Project (I recommend that you use the Precompiled Headers, if you don’t know what they are, google it ;)  )
  • Now Add all the Bullet projects you need. For this example, in VS go to File>Add> Existing Project and, separately, add:
  1. c:\bullet-2.81-rev2613\build\vs2010\BulletCollision.vcxproj
  2. c:\bullet-2.81-rev2613\build\vs2010\BulletDynamics.vcxproj
  3. c:\bullet-2.81-rev2613\build\vs2010\LinearMath.vcxproj
  • In Solution Explorer, go to your project Properties (select it and ALT+ENTER)
  • Go to Common Properties> Framework and References and click on “Add New References…”. Choose all the projects you’ve previosly added
  • Click on Configuration Properties
  • At the top, change Configuration to All Configurations
  • Go to Configuration Properties> C/C++> General
  • In Additional Include Directories, add c:\Bullet-2.81-rev2613\src\

That’s it.

To test it, use this code in your project .cpp:

#include "stdafx.h"
#include "btBulletDynamicsCommon.h"
int _tmain(int argc, _TCHAR* argv[]){
btBoxShape * box = new btBoxShape(btVector3(1,1,1));
delete box;
return 0;
}

Did it run or did you got this error?

If so, the projects you’ve added have weird references. Do this:

  • In each added project, go to project Properties Page (ALT+ENTER)
  • In Common Properties> Framework and References, remove references to ZERO_CHECK

Run it again. Worked?

Compiled

Windows 8 Run Dialogue with chrome-like inline autocomplete

I, for one, use the Run Dialogue a lot, and by “a lot” I mean, always, for anything and for everything.

I’ve managed to take this to a hole new level adding new alias commands, with this I can go to anywhere in my system and/or do any common task I need to do, for instance, I’ve a bitlocked drive with sensitive information, after I’m done working with it and I want to re-lock the drive, I just need to:

  1. Press WIN+R
  2. Write “lock”
  3. Press Enter. This will execute a batch that I’ve created for this propose, that is somewhere in my drive

Isn’t it simple?

One thing that I just LOVE in Chrome is it’s autocomplete, which adds the rest of the word selected in place so, in contrast to the classic way of only showing a dropdown list with the possible matches and you need to use the keyboard or mouse to choose one. This simple feature enhances my productivity like hell and I just wish it would be globally adopted as standard.

That being said, what if I told you that, you can have that type of autocomplete in Windows 8 Explorer, therefore, in the Run Dialogue? That’s right, you just need to:

  1. Open IE Internet Properties (I really don’t know why the hell this option is in Internet Properties but well, to be honest, don’t really care)
  2. Go to Advanced tab
  3. Scroll down the Settings list, in the Browsing part, after the Underline links you have “Use inline AutoComplete in File Explorer and Run Dialogue”
Inline AutoComplete option in Internet Properties

That sneaky and useful little bastard !

As I’ve found this by accident in Windows 8, I don’t really know if this already existed in 7 / Vista / XP, if you have any of these OS drop a comment stating if you have this option there or not.

Productivity like this.

Productivity like this.

That’s all for today ! Hope you had a blessed Christmas, have a great 2013 !

Refreshing/Reseting Windows 8 without DVD, the “Insert Media” Dilema

Situation: You’re pissed because something is not ok with your Windows 8 and you heard that there’s new and awesome features that can save your life – Refresh or Reset -, and your like “F*CK YEAH let’s get rid of this”, but, when you try to do it you get this:

Some files are missing. Your Windows installation or recovery media will provide these files.

Insert media: Some files are missing. Your Windows installation or recovery media will provide these files.

This happens because Windows is expecting you to insert a DVD with the installation files.

Solution 1# (if you have the DVD)

  1. Insert the damn DVD
  2. Next Next Next
  3. Wait for it
  4. There’s no 5th step.

Solution 2# (if you only have an ISO image)

  1. Create a folder in your system root called “windows8″ (the path to it would then be “C:\windows8″ )
  2. Mount the Windows 8 ISO
  3. Go to Sources folder and copy ”install.wim” file to “C:\windows8″
  4. Open an Admin Command Prompt with WIN+X A
  5. Run this: reagentc.exe /setosimage /path C:\windows8 /target c:\Windows /Index 1
  6. Try to Refresh / Restart again and it should work as expected!

Problem Solved

Build Conference!

Building Windows event, today @ 16h in Portugal | 9am PDT

Yesterday we had the Windows Phone 8 unveil, that showed a lot of cool new features that you can see at Windows Phone site. The Windows Phone event was clearly directed to everyone, on another note, today Microsoft talks geek, BUILD conference is directed to developers and, if you want to be a cool dev you shouldn’t miss one (or at least see some recaps/reviews if you do), because they’re *high pitch*AWESOME!

It will be at 16h Portugal time (UTC) !

Windows Phone 8 presentation event webcast !

If you don’t already know about this event, please, wake up and smell the coffe, Santa will come early bringing Windows Phone 8 to the tables (of paying customers of course, or lucky bastards), but on a more important note, to developers !

The event will be today in San Francisco, at 10AM Pacific (17:00 Portugal time), and as usual, there will be a webcast / livestream, more info on that in the Windows Phone Development blog official post !

 

 

How to: Install Language Pack file ( lp.cab ) in Windows 8 RTM

Currently, DreamSpark Premium (formerly MSDNAA) only have access to the en-US version of Windows 8 RTM, fortunately enough if you want to change the display language now you can download the official Language Pack.

Problem: There’s no way to manually install a language pack file (lp.cab) in Windows 8, at least accessible through Control Panel as it was in Windows 7 (Microsoft must be planing to only distribute language packs through Windows Update, but, at the time of writing, they aren’t available yet )

Solution #1:

  • Press Win key
  • In Start Screen write lpksetup
  • Press enter and follow instructions
  • After the successful installation, restart and enable the new display language in Control Panel\Clock> Language and Region> Language

Solution #2:

  • Press Win key
  • In Start Screen, write cmd
  • Right mouse click over Command Prompt and select Run as Administrator
  • Write the following command, restart afterwards and enable your display language in Control Panel:
dism /online /add-package /packagepath:C:\languagepacks\de-de\lp.cab

NOTE 1#: You will need to adapt the commands requirements for your specific usage, for instance, if i want to install a pt-PT language pack that is located at c:\users\me\lpacks\pt-PT\lp.cab, the command would be

dism /online /add-package /packagepath:C:\users\me\lpacks\pt-PT\lp.cab

NOTE 2#: Don’t forget to change your Locale settings also, so you can get the same language everywhere.

PS: I don’t know if I’m allowed to share the full .iso file here, but you can easly find this anywhere, they are named as follow in MSDN:

  • x86: mu_windows_8_language_pack_x86_dvd_917546.iso
  • x64: mu_windows_8_language_pack_x64_dvd_917544.iso