Friday, October 5, 2012

D Programming Error: Module conflicts with itself

This happened to me when I imported a library someone made.

I had to go through the headers and adjust each file's module path to match the path it currently had in my project hiearchy.

As in, file Bloop.d had the original "module: someLibrary.bloop;". It was now in the folder libz/someLibrary/bloop so I changed it to "module: libz.someLibrary.bloop".

That resolved it for  me.

Tuesday, October 2, 2012

D Programming: OpenGL 3.x+ (for Windon't 7) Part 3

First of all, here are some important links you need to bookmark and frequent for D/Derelict/MonoD/COOLSHIT:



Things you'll need:

  • zlib1.dll
  • SDL2.dll
  • SDL2_image.dll
  • libpng15-15.dll
You will put these into your project next to your .exe file you run.

Here is the project code...


import std.stdio;      //required libpng15-15.dll + zlib1.dll placed next to .exe
import std.string; 
import std.conv; 
import std.path; 
import std.file; 
import derelict.sdl2.sdl; 
import derelict.sdl2.image; 
import derelict.opengl3.gl3; 

pragma(lib, "DerelictUtil.lib"); 
pragma(lib, "DerelictSDL2.lib"); 
pragma(lib, "DerelictGL3.lib"); 

SDL_Window *win; 
SDL_GLContext context; 
int w=800, h=600; 
bool running=true; 
uint shader = 0, vao = 0, tid = 0, colLoc = 0; 
int flags=SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_SHOWN; 

bool initSDL_GL(){ 
   if(SDL_Init(SDL_INIT_VIDEO) < 0){ 
      writefln("Error initializing SDL"); 
      return false; 
   } 
   SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); 
   SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); 
   SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); 
   SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); 

   win=SDL_CreateWindow("3Doodle", SDL_WINDOWPOS_CENTERED, 
   SDL_WINDOWPOS_CENTERED, w, h, flags); 
    if(!win){ 
        writefln("Error creating SDL window"); 
      SDL_Quit(); 
      return false; 
     } 

    context=SDL_GL_CreateContext(win); 
    SDL_GL_SetSwapInterval(1); 
    
   glClearColor(0.0, 0.0, 0.0, 1.0); 
   glViewport(0, 0, w, h); 

    DerelictGL3.reload(); 

    return true; 
} 


bool initShaders(){ 
   const string vshader=" 
   #version 330 
   layout(location = 0) in vec3 pos; 
   layout(location = 1) in vec2 texCoords; 

   out vec2 coords; 

   void main(void) 
   { 
      coords=texCoords.st; 

       gl_Position = vec4(pos, 1.0); 
   } 
   "; 
   const string fshader="    
   #version 330 

   uniform sampler2D colMap; 

   in vec2 coords; 
   out vec4 fragColor;

   void main(void) 
   { 
      vec3 col=texture2D(colMap, coords.st).xyz; 

      fragColor = vec4(col, 1.0); 
   } 
   "; 

   shader=glCreateProgram(); 
   if(shader == 0){ 
      writeln("Error: GL did not assigh main shader program id"); 
      return false; 
   } 
   int vshad=glCreateShader(GL_VERTEX_SHADER); 
   const char *vptr=toStringz(vshader); 
   glShaderSource(vshad, 1, &vptr, null); 
   glCompileShader(vshad);    
   int status, len; 
   glGetShaderiv(vshad, GL_COMPILE_STATUS, &status); 
   if(status==GL_FALSE){ 
      glGetShaderiv(vshad, GL_INFO_LOG_LENGTH, &len); 
      char[] error=new char[len]; 
      glGetShaderInfoLog(vshad, len, null, cast(char*)error); 
      writeln(error); 
      return false; 
   } 
   int fshad=glCreateShader(GL_FRAGMENT_SHADER); 
   const char *fptr=toStringz(fshader); 
   glShaderSource(fshad, 1, &fptr, null); 
   glCompileShader(fshad);    
   glGetShaderiv(fshad, GL_COMPILE_STATUS, &status); 
   if(status==GL_FALSE){ 
      glGetShaderiv(fshad, GL_INFO_LOG_LENGTH, &len); 
      char[] error=new char[len]; 
      glGetShaderInfoLog(fshad, len, null, cast(char*)error); 
      writeln(error); 
      return false; 
   } 
   glAttachShader(shader, vshad); 
   glAttachShader(shader, fshad); 
   glLinkProgram(shader); 
   glGetShaderiv(shader, GL_LINK_STATUS, &status); 
   if(status==GL_FALSE){ 
      glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len); 
      char[] error=new char[len]; 
      glGetShaderInfoLog(shader, len, null, cast(char*)error); 
      writeln(error); 
      return false; 
   } 


   return true; 
} 

bool initVAO(){ 
   uint vbov, vboc; 
   const float[] v = [   -0.75f, -0.75f, 0.0f, 
                  0.75f, 0.75f, 0.0f, 
                  -0.75f, 0.75f, 0.0f]; 
   const float[] c = [   0.0f, 0.0f, 
                  1.0f, 1.0f, 
                  0.0f, 1.0f]; 
   glGenVertexArrays(1, &vao); 
   assert(vao > 0); 

   glBindVertexArray(vao); 

   glGenBuffers(1, &vbov); 
   assert(vbov > 0); 
   glBindBuffer(GL_ARRAY_BUFFER, vbov); 
   glBufferData(GL_ARRAY_BUFFER, v.length * GL_FLOAT.sizeof, v.ptr, GL_STATIC_DRAW); 
   glEnableVertexAttribArray(0); 
   glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, null);          
   glBindBuffer(GL_ARRAY_BUFFER, 0); 

   glGenBuffers(1, &vboc); 
   assert(vboc > 0); 
   glBindBuffer(GL_ARRAY_BUFFER, vboc); 
   glBufferData(GL_ARRAY_BUFFER, c.length * GL_FLOAT.sizeof, c.ptr, GL_STATIC_DRAW); 
   glEnableVertexAttribArray(1); 
   glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, null);          
   glBindBuffer(GL_ARRAY_BUFFER, 0); 

   glBindVertexArray(0);    

   return true; 
} 

bool initUniforms(){ 
      glUseProgram(shader); 
   colLoc=glGetUniformLocation(shader, "colMap"); 
   if(colLoc == -1){writeln("Error: main shader did not assign id to sampler2D colMap"); return false;} 

      glUseProgram(shader); 
      glUniform1i(colLoc, 0); 
      glUseProgram(0); 

   return true; 
} 

bool initTex(){ 
   assert(exists("4.png")); 
   SDL_Surface *s=IMG_Load("4.png"); 
   assert(s); 

   glPixelStorei(GL_UNPACK_ALIGNMENT, 4); 
   glGenTextures(1, &tid); 
   assert(tid > 0); 
   glBindTexture(GL_TEXTURE_2D, tid); 

   int mode = GL_RGB; 
   if(s.format.BytesPerPixel == 4) mode=GL_RGBA; 
    
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);    
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 

   glTexImage2D(GL_TEXTURE_2D, 0, mode, s.w, s.h, 0, mode, GL_UNSIGNED_BYTE, flip(s).pixels); 

   SDL_FreeSurface(s); 
   return true; 
} 

//thanks to tito http://stackoverflow.com/questions/5862097/sdl-opengl-screenshot-is-black 
SDL_Surface* flip(SDL_Surface* sfc) 
{ 
     SDL_Surface* result = SDL_CreateRGBSurface(sfc.flags, sfc.w, sfc.h, 
         sfc.format.BytesPerPixel * 8, sfc.format.Rmask, sfc.format.Gmask, 
         sfc.format.Bmask, sfc.format.Amask); 
     ubyte* pixels = cast(ubyte*) sfc.pixels; 
     ubyte* rpixels = cast(ubyte*) result.pixels; 
     uint pitch = sfc.pitch; 
     uint pxlength = pitch*sfc.h; 
     assert(result != null); 

     for(uint line = 0; line < sfc.h; ++line) { 
         uint pos = line * pitch; 
         rpixels[pos..pos+pitch] = 
             pixels[(pxlength-pos)-pitch..pxlength-pos]; 
     } 

     return result; 
} 


int main(){ 
   try{ 
        DerelictSDL2.load(); 
    }catch(Exception e){ 
        writeln("Error loading SDL2 lib"); 
      return false; 
    } 
    try{ 
        DerelictGL3.load(); 
    }catch(Exception e){ 
        writeln("Error loading GL3 lib"); 
      return false; 
    } 
   try{ 
        DerelictSDL2Image.load(); 
    }catch(Exception e){ 
        writeln("Error loading SDL image lib ", e); 
      return false; 
    } 
    
   writeln("Init SDL_GL: ", initSDL_GL()); 
   writeln("Init shaders: ", initShaders()); 
   writeln("Init VAO: ", initVAO()); 
   writeln("Init uniforms: ", initUniforms()); 
   writeln("Init textures: ", initTex()); 
    
   while(running){ 
      SDL_Event e; 
      while(SDL_PollEvent(&e)){ 
         switch(e.type){ 
            case SDL_KEYDOWN: 
            running=false; 
            break; 
            default: 
            break; 
         } 
      } 
      glClear(GL_COLOR_BUFFER_BIT); 

      glUseProgram(shader);       

      glBindVertexArray(vao); 

      glActiveTexture(GL_TEXTURE0); 
      glBindTexture(GL_TEXTURE_2D, tid); 

      glDrawArrays(GL_TRIANGLES, 0, 6); 

      glBindTexture(GL_TEXTURE_2D, 0); 
      glBindVertexArray(0); 
      glUseProgram(0); 

      SDL_GL_SwapWindow(win); 
   } 

   SDL_GL_DeleteContext(context); 
   SDL_DestroyWindow(win); 
   SDL_Quit(); 

   return 0; 
}
So just paste that into your MonoD project's "main.d" and build/compile/run it. You can exit the program by pressing the "ESC" key. Hope this helps speed up your starting up.

D Programming: OpenGL 3.x+ (for Windon't 7) Part 2

To start we need to... start.

You will need to download the D installer, the Mono IDE, the MonoD extension, Derelict3, and some things required to get SDL2 to work.

I will be hosting everything on a single page so you don't have to crawl around for it. These downloads will become outdated but should (for the foreseeable future) work together just fine.

So if you want the latest/greatest make sure you DON'T use my downloads and actually go get copies of these things yourself.

Download everything from me.

  1. https://code.google.com/p/brollace-blog-filehost/source/browse/d_pack.zip
  2. On the right of the page is the link "view raw file".
  3. Right click the link and "save as" to download the zip.
Setup a storage directory
  1. Go to your "Documents" and create a folder called "DontMove".
  2. In this folder create a folder called "D".
  3. Unpack the contents of "d_pack.zip" to "DontMove\D" so that, for instance, you can observe the following path: "DontMove\D\4.png", and NOT "DontMove\D\d_pack\4.png".
Install D Programming Language:

Uses the d_pack files:
  • dinstaller.exe
  1. Run the "dinstaller.exe".
  2. I put my installation on "C:\D\<my stuff installed here yo>"
Setup Derelict3 for OpenGL 3.X+

Now this part was painful so please do allow me to share the fruits of my labor with you to end the chain of suffering.

Uses the d_pack files:
  • aldacron-Derelict3-b4f810c.zip
  1. Unzip the aldracon package.
  2. Go to "import" so you see a folder containing "derelict".
  3. Copy the folder "derelict" with all the stuff in it and paste it into (for example on my machine) "C:\D\dmd2\src".
  4. The folder should look something like "derelict, dmd, druntime, phobos".
  5. Go to "aldracon/lib" and copy everything to (for example on my machine) "C:\D\dmd2\windows\lib".
  6. You should have just copied a bunch of .libs into a folder of other .libs.
  7. Open up "C:\D\dmd2\windows\bin\sc.ini" in some editor like Notepad++ or Scite or ConTEXT.
  8. Change the line: [1] to look something like [2]...
[1] DFLAGS="-I%@P%\..\..\src\phobos" "-I%@P%\..\..\src\druntime\import"
[2]DFLAGS="-I%@P%\..\..\src\phobos" "-I%@P%\..\..\src" "-I%@P%\..\..\src\druntime\import"

Install MonoD

Uses the d_pack files:
  • MonoDevelop-3.0.4.7.msi
  • MonoDevelop.D_0.4.1.4_MD3.0.4.7.mpack
  • ResourceCompiler.zip
.
.
.
.

You should now be able to create D programs in MonoDevelop using MonoD.

Next I will go over how to write your first D OpenGL3.X+ app using SDL2.

D Programming: OpenGL 3.x+ (for Windon't 7) Part 1

D. Just say it. D...

Mmm....

I really want to get away from C++ (lol impossible ikr).  So I'm going to invest my time and projects into developing with D.

These posts will be tutorials on how to start up D programming, and then on how to write an OpenGL 3.X+ application in D.

Thursday, August 23, 2012

Windows 7: Eclipse CDT + OpenGL + MinGW Part 4

Setting up the FreeGLUT project


  1. In Eclipse...
  2. File > New > Project > C/C++ > C++ Project
  3. Hello World C++ Project w/ MinGW GCC
  4. If you didn't see MinGW GCC then uncheck the box "Show project types and ....".
  5. Name the project and finish.
  6. Copy the lib and include folders you've been adding things to over to the eclipse_workspace folder and place them next to the project's src folder.
  7. In Eclipse, right click on the project > Properties > C/C++ Build > Settings
  8. GCC C++ Compiler > Includes > Include paths (-I)
  9. Click the button with the green plus sign and add the "workspace" path to your folder "include" that you copied into the project folder.
  10. MinGW C++ Linker > Libraries.
  11. Go to Libraries (-l) and add: "glu32", "opengl32", "freeglut".
  12. These need to be in a proper order to try to keep them in the order I just described, from the top to the bottom (glew32 on top, then glfw, then...).
  13. Go to Library search path (-L)
  14. Add the "workspace" path to the "lib" folder you copied into the project folder.
  15. Click "Apply" and "Ok".
  16. Take the .dll's you copied into your "bin" folder and copy them into the project's "debug" or "release" folder. I use "debug", and it's what I've confirmed to work, so copy them into the "debug" folder.
  17. Copy and paste the code here over the hello world code. This will run the spinning cube dude:  http://pastebin.com/RfdPESsz
  18. Right click the project and "Build" (or hit the hammer button up top).
  19. Right click the project and "Run As" > "Local C/C++ Application".
Setting up the GLFW project


  1. In Eclipse...
  2. File > New > Project > C/C++ > C++ Project
  3. Hello World C++ Project w/ MinGW GCC
  4. If you didn't see MinGW GCC then uncheck the box "Show project types and ....".
  5. Name the project and finish.
  6. Copy the lib and include folders you've been adding things to over to the eclipse_workspace folder and place them next to the project's src folder.
  7. In Eclipse, right click on the project > Properties > C/C++ Build > Settings
  8. GCC C++ Compiler > Includes > Include paths (-I)
  9. Click the button with the green plus sign and add the "workspace" path to your folder "include" that you copied into the project folder.
  10. MinGW C++ Linker > Libraries.
  11. Go to Libraries (-l) and add: "glew32", "glfw", "glu32", "opengl32".
  12. These need to be in a proper order to try to keep them in the order I just described, from the top to the bottom (glew32 on top, then glfw, then...).
  13. Go to Library search path (-L)
  14. Add the "workspace" path to the "lib" folder you copied into the project folder.
  15. Click "Apply" and "Ok".
  16. Take the .dll's you copied into your "bin" folder and copy them into the project's "debug" or "release" folder. I use "debug", and it's what I've confirmed to work, so copy them into the "debug" folder.
  17. Copy and paste the code here over the hello world code. This will run the spinning cube dude:   http://pastebin.com/yXDzXPYq
  18. Right click the project and "Build" (or hit the hammer button up top).
  19. Right click the project and "Run As" > "Local C/C++ Application".
The GLFW project will build fine but for me I have to run it from the project's debug folder. You can of course run it in debug in the editor just fine.

Here is a copy of my project folders. Everything is referenced from within the project workspaces so things should be portable: THE_PROJECTS.

Wednesday, August 22, 2012

Windows 7: Eclipse CDT + OpenGL + MinGW Part 3

First, pick a place that you won't delete and create the following folders:

  • include
  • lib
  • bin
Now, what are these things going to be for?

FreeGLUT is an up-to-date version of the popular GLUT kit. It makes OpenGL easier to work with by providing windows and some other functionality for you (making the windows is a platform specific thing that is just plain lame and a fucking drag to do in order to get a spinning fucking cube. Fuck.). It's cross platform but doesn't work well on OSX I believe.

GLFW is an alternative to FreeGLUT. It provides windowing and input and some other stuff. Works well on Windows/Linux/OSX. My favorite (o^_^)b.

GLEW allows you to easily enable any extensions you may need. The alternative is sheer torture (maybe not at first but eventually). GLEW it.


FreeGLUT

  1. Go to :  http://www.transmissionzero.co.uk/computing/using-glut-with-mingw/.
  2. Click: "freeglut MinGW Package".
  3. Alternatively, you can follow this link: http://files.transmissionzero.co.uk/software/development/GLUT/freeglut-MinGW.zip
  4. Get the zip file and expand it.
  5. Copy the freeGLUT bin .dll's to your bin folder you made.
  6. Copy the freeGLUT include contents ( copy the entire GL folder ) and put it into the include folder you made.
  7. Copy the freeGLUT lib contents into the lib folder you made.
GLFW
  1. Go to  http://www.glfw.org/download.html.
  2. Download the latest zipped version.
  3. Unzip the package.
  4. Open up the console (WindowsKey + R).
  5. In the windows explorer go to the folder and copy the path from the top of the window.
  6. Go back to the console.
  7. Type "cd ". Space after the cd.
  8. Paste the path you copied and press enter to travel to the folder in the console.
  9. In the console, go to the unzipped folder where the Makefile is.
  10. Run the command "make win32-msys".
  11. If the command errors out then check the "readme.html" for instructions on what other commands to use. I'm pretty sure the error will tell you the options for running the make.
  12. After a few seconds, the console should spew info about the build.
  13. Copy the include/bin/lib stuff like you did before.
  14. Note that you should add the new include/GL stuff to the folder you've already made.
GLEW
  1. Go to  http://glew.sourceforge.net/ and download the latest ZIP.
  2. Don't get the binaries, you will be building it yourself yo.
  3. Unzip the package, console to it, make.
  4. Copy the bin/lib/include stuff like before.

Windows 7: Eclipse CDT + OpenGL + MinGW Part 2

Eclipse CDT C++ plugin( 4.2.0 = Juno )
  1. Open Eclipse.
  2. Go to Help > Install new software > Work with.
  3. Paste in: http://download.eclipse.org/tools/cdt/releases/juno
  4. Press Enter.
  5. Expand "CDT Main Features".
  6. Turn on "C/C++ Development Tools"
  7. Expand "CDT Optional Features"
  8. Turn on: " C/C++ GCC Cross Compiler Support", "C/C++ GDB Hardware Debugging", "C/C++ Memory View Enhancements", "C/C++ Unit Testing Support", "C99 LR Parser", "CDT Visual C++ Support".
  9. Press Next, Finish, w/e. Just go through the installation steps, accept things, until it tells you that it needs to restart.
  10. Allow Eclipse to restart.
MinGW
  1. Go to: http://sourceforge.net/downloads/mingw/MinGW/
  2. Click on (The link will look something like this)"Download mingw-get-inst-20120426.exe (662.7 kB)"
  3. Run the installer.
  4. Say that you want the latest version from teh webz.
  5. Let it do it's thing. Go grab a drink or something.
  6. Go to wherever you installed it and make note of the path to the mingw bin (by default this is C:\MinGW\bin).
  7. Also make note of the mingw msys bin (by default this is C:\MinGW\msys\1.0\bin).
  8. Copy these 2 paths onto the end of your system PATH.
  9. To append these to the path, go to windows start and enter the string "advanced".
  10. Click "View advanced system settings".
  11. Click "Environment Variables".
  12. Go to the "System variables" region at the bottom.
  13. Scroll down to "PATH" and click edit.
  14. Go to the end of this possibly long bigass string and enter a semicolon ";" to separate the last entry from the ones you want to add.
  15. Add the two paths to mingw bin and msys bin (separate these by ";").
  16. Test if you have mingw working now by opening up the console and running make.
  17. Press WindowsKey + R. This will open up RUN.
  18. Type cmd.
  19. Press enter.
  20. Run the command: "make --version".
  21. Run the command: "g++ --version".
  22. If these commands don't error out and complain about something then you are good to go with mingw!

Windows 7: Eclipse CDT + OpenGL + MinGW Part 1

So, I get tired of Visual Studio.

I get tired of it in general, I get tired of it's look, I get tired of it bugging out... And with all the Windows 8 stuff I've been reading about with the "you will develop for Metro or gtfo" what not, I just feel like now is a good time to take my OpenGL preferring self and get away from Visual Studio.

I really like Eclipse. It's easy to work with, it's free, it's got ton's of plug-ins, and it's easy to change the look with templates that don't break everything. Also the code completion is great. In Visual Studio I use Wild Tomato's Visual Assistant X. In Eclipse, I get a free and awesome code completion solution. Score.

Anyway, setting up Eclipse to develop C++ meant installing the CDT plugin. Painless.
Getting OpenGL's spinning cube hello world working... Painful.

But, it always is painful to get OpenGL started up on some dev environment you aren't experienced at working with yet.

So, let me distill the knowledge I have acquired by mentally cartwheeling nude through numerous forums and guides to you, the consumer, so that you may immediately get an OpenGL Spinning Cube application up and working using not only FreeGLUT, but also GLFW and GLEW.

Tuesday, August 21, 2012

Windows: CMake can't find QT? Whaaaattttt....

I got this error while checking out a project.

I found the solution on StackOverflow (http://stackoverflow.com/questions/9933939/cmake-not-finding-qt4).

Plain and simple: add the path "C:\QtSDK\Desktop\Qt\4.8.0\msvc2010\bin" to your advanced system settings PATH variable.

If you're using Qt 4.8.1 or w/e else change it accordingly. Just make sure you get the msvc2010\bin path.

Wednesday, July 11, 2012

Eclipse + Egit + Remote Repo + Add new project

I use Git. I use Eclipse. I use Egit. I use Bitbucket. I needed to add an Eclipse project to my repo. I couldn't find how to do it anywhere. Here is how I did it (roughly).


  • Open Eclipse (4.2+).
  • Install Egit:  http://www.vogella.com/articles/EGit/article.html.
  • File > Import > Git > Projects from Git > URI.
  • Put your Bitbucket repo address in (for example: https://username@bitbucket.org/username/blahblah.git )
  • Go to Window > Show View > Git Repositories.
  • Make note of the repo structure.
  • Copy/Move your project to the repo directory (it should be in your eclipse workspace directory).
  • In Git Repositories view, right click the name of the repo and "commit" then "push".
  • Done.
Hopefully this is helpful.

Tuesday, July 10, 2012

Easily rename batches of files on Windows

http://www.den4b.com/

This guy has made an amazing application called "ReNamer". Get it here: http://www.den4b.com/?x=downloads.

Basically you drag/drop your files into the app, then you tell it what text you want to find/replace, hit go, and wham you're done.

I use Windows 7 and it has done an amazing job so far. Definitely get it, great file renaming tool with a gui.

Wednesday, June 13, 2012

iOS Xcode 4.X : Build Fail "My 64-bit Mac"

This error arose when I began working on a project that a co-worker of mine started. The project was on the iPad using iOS but xcode key yabbering on about how it couldn't build for 64bit desktop. Painful and maddening. Stackoverflow.com showed that this problem happens a lot for several reasons (subversion, files touched outside of xcode, crashes, etc ), but none of the presented solutions were helpful. All except for one.

To resolve this for my iOS project, I went to the project target settings ( the picture of the ruler and brush ), to the"Summary" tab, and changed the "Deployment Target" to 5.0. It was set to something like 5.1, but it needed to be something that my machine had. I imagine that the "My 64-bit Mac" crud is a default that Xcode goes to when all else fails.

Monday, June 11, 2012

A definition of computer science

So after some thought about what I actually do as a computer scientist I've come up with a definition for the field that actually makes sense.

Computer science is the art of using several languages to write books that you then give to machines to tell them how to make something out of collections of content.

Sometimes you write the languages used to write the books. Other times you write about ways to write things that can be used in the books (this thing is faster or more accurate than that thing, and that thing allows us to do this new thing). Often times, these books have been written by other people and you reference them to create a new book.

Content are things created either by machines themselves, or other people. Content can include things like information about who has visited a website, the recorded wind speeds of a region of the Earth, or a picture that paints the body of a character in a 3D video game.

The essence of the definition is that what we do is write many pages of text in order to create some specific system/collection of happenings in machines.

Even if you spend much of your time using nothing but whiteboards and markers to prove equations and ideas (which is great and vital to do), at some point one would hope that you actually implement those things inside of a machine to give the theory a form that can be used.

Lol finally I can explain what I do to people who dont do what I do. I think it's intuitive also as it reminds me of writing English and History papers in high school.

Tuesday, May 22, 2012

Some Great Netbeans shortcuts

Just thought it was cool to see some of the shortcuts for code completion that exist in Netbeans Java.

Here is a link to the post: http://netbeans.dzone.com/top-10-interesting-netbeans-shortcuts

Oh and the shortcut for cold folding is ctrl+shift+minus = collapse, ctrl+shift+plus = expand.

Saturday, May 12, 2012

A Good Place to Start OpenGL

Many people want to learn OpenGL. Most of these people have no idea where to start. About everyone will learn OpenGL in some deprecated or round-a-bout way that discourages them from continuing their studies.

Well that's stupid and I'd like to at least point people in the right direction for getting started. This definitely isn't a tutorial, but I hope that it does serve to broaden your knowledge of available OpenGL tools, libraries and resources.

Here are the resources:

Basically you should walk through the samples provided over at g-truc to get an idea of what it means to create a current generation OpenGL project. The authors say that the code is not for beginners but they are only being modest and probably just don't intend for them to be used by beginners. I can honestly say that they are some of the best examples of OpenGL code available.

To build them on Windows for Visual Studio 2010 you need to install cmake. After that open up command line by running it as administrator. In this cmd window change to the samples folder that contains the /data, /external, /samples... the top level of the folder. Run the command [cmake -G "Visual Studio 10"]. Do not use the cmake GUI for this as it won't work. Now you should have vs2010 projects built that you can explore by opening the .sln.

What I suggest that you do is copy the projects and get accustomed to how they use OpenGL to express themselves. Their image loading tool, GLI, is for bringing in images to the program to use as textures. FreeGLUT is a "make windows and other stuff" utility that some people use. I honestly think all GLUT stuff is lame and suggest you learn to use GLFW instead. GLM is a great way to encapsulate all of your math needs for things such as vectors and matricies (which you will make heavy use of). It gives you a portable math solution that works great with OpenGL.

Wednesday, May 9, 2012

School Parallel Project: OpenGL + Havok + Intel TBB

So I recently had to create a project for my class on parallel computing. It was a semester long project (with lots of homework in between on things like OpenMP, P Threads, CUDA, MPI and OpenCL )and I just recently finished it. I turned it in yesterday but found more time to benchmark it this morning. I will post the project here soon in some way so you can see it for your self but for now here are some stats from my two machines...


  • Laptop - [AMD Phenom 2 N830 [3-Core] 2.10 GHz] [8GB Ram] [Windows 7 64bit] [ATI Mobility Radeon HD 4200]
    • Single Threaded: 10fps
    • Multi Threaded: 15fps
  • Desktop - [Intel i7 2600 [4-Core Hyperthreaded] 3.40 GHz] [16GB Ram] [Windows 7 64bit] [nVidia GeForce GTX 480]
    • Single Threaded: 19fps
    • Multi Threaded: 75fps
Holy crap does it scale well... gDebugger reports poor desktop utilization on my 5th and 7th cores but all the same it's a crazy improvement. 

I'll post more later. Go TBB and Havok!

Tuesday, May 8, 2012

Windows: Getting the Device Context without painful setup

So I use OpenGL a lot. Because of this I use GLFW a lot. GLFW is like GLUT or Free GLUT or SDL or SFML except it's not lame (not saying these kits are all lame but GLUT is lame and SDL is lame lol ). GLFW is a lot more light weight and for me easier to work with.

Using GLFW to create your window and context is painless. However there is no obvious way to get your window's context from GLFW once it's made. In my case, I needed the context for an OpenGL OpenCL interop.

To get the window handle and device context you can go right after your glfwInit() and glfwOpenWindow(...) and call...


HWND *ptr_hwnd = GetForegroundWindow();
HDC ptr_dc = GetDC( *ptr_hwnd );


And that should do it! No pain, some gain. So long window setup code hello actually doing wtf you wanted to make the window for.

Friday, May 4, 2012

Asus P8 Z68-V Pro/GEN3 Blue Screen of Death

I recently upgraded my desktop for development I'll be doing this summer. When starting up Windows 7 I got a quick BSOD followed by a restart. Forums reveal that this issue isn't uncommon but none of the solutions seemed to work for me. Combining them did though...


  • Make sure you have/get Corsair Vengeance ram. It's made for the board and even has the board's picture on the front of the product's box lol.
  • In the bios, go to the auto tuning for overclocking and switch from Auto or Manual to XMP.
  • Go to your Advanced settings and...
    • Turn off all Marvell stuff. It's crap. It won't work (didn't for me and doesn't for most it seems).
    • Switch the SATA from AHCI to IDE.
Doing that fixed everything for me. The machine then started up fine and so did Windows. Hope this helps.

Also, you may want to go into your msconfig > startup and turn off like all of the non-essential stuff. I believe I have old software setup for my old AMD processor. My new Intel isn't jiving with it. Turning those off made my system stable. You may also just want to get a new hard drive (or wipe your existing one).

GLEW VS2010 Wont Link?!?!

This is quite a painful problem that can actually be solved easily if you know what to do.

You'll want to use the static library  (glew32s.lib) and define the preprocessor directive 'GLEW_STATIC'.
You should be able to just download the Windows binaries for this but you can build it yourself also if you'd like (it's also simple to do).

With Binaries:

  • Download glew (32 and 64 as you may need to try both. 32 will probably work though).
  • Properties > Linker > Input > Additional Dependencies : Add ( glew32s.lib, glu32.lib, opengl32.lib ).
  • Properties > General > Additional Library Directories : Add ( --your path to the glew libs-- ).
  • Properties > C/C++ > Preprocessor > Preprocessor Definitions : (Add --GLEW_STATIC-- ).
  • Copy the glew32.dll into the folder with your programs executable.
Building yourself:
  • Download glew.
  • Open up the build/vc6 project.sln.
  • Change build target from Debug to Release.
  • Go to the solution explorer on the right( or left ) side of VS2010 > right click static > build.
  • Copy the newly built .lib to what ever folder you use for your project's libraries.
  • Copy the glew32.dll into the folder with your programs executable.

And that should do it.

I can't stress enough how much of a rut I was stuck in trying to get this to work. Hours down the drain. Rage and frustration at an ever-living wall of linker errors for methods I knew should be linking.

So seriously, use the static build, make your call to glewInit(), and get back to the real work of your project.

Thanks for the solution go to ( many others not included here )

gDEBugger you a good life

Debugging graphics can be a pain. It definitely takes an amount of skill and knowledge that comes to you slowly over whats perhaps a long period of practice. Seeing an ambiguous error pop up and knowing that it has something to do with a color inside of a texture on the graphics device is something that may not be obvious to some.

There exists an amazing gift from humanity to itself (specifically the amazing developers at Graphic Remedy ), and it is called gDEBugger. Simply put it is a must have tool that will change the way you develop OpenGL applications for the better, without question. It's like Pix for DirectX (but I think it may be older and thus the original).

Some of it's features include pausing/breaking execution, examining every texture/buffer active, a performance report of your number of OpenGL calls made a frame, frame rate, examining the depth buffer and adjusting the Z-Near/Far, inverting textures, a full report of every active uniform on the device, all shaders in use, which shader program is currently active (I even think you can edit them in real time for hot changes, haven't tried it though so don't quote me), and tons more things like bottleneck locating by either killing all graphics, setting the view port to a 1x1 stenciled pixel... tons of stuff. This tool is a must.

You can get it for FREE. It's free. That's insane: http://www.gremedy.com/.

So yea. Don't say I never gave you anything lol.

Friday, April 20, 2012

Qt, OpenGL and VS2010 How To

Resources:
My guide:

First, install [1]. Next install [2]. After that, you can notice a new Qt button at the top of your VS2010 toolbar. I haven't had to use the button for anything yet but know that it's there.

Development for me using Qt and VS2010 involves using VS to program my widgets and QtDesigner to create the UI layout.

You can open up your file.ui for designing by:
  • Double clicking it in your VS2010 Solution Explorer.
  • Or by opening QtDesigner directly, finding the file.ui of your project in Explorer, and using the designers opening dialog to go to that path and open it.
I normally use the 2nd longer direct approach.

While following the Zhao Wuluo walkthrough something to look out for is the mainwidget.cpp constructor:

MainWidget::MainWidget(QWidget *parent, Qt::WFlags flags)
 : QWidget(parent, flags),
 ui(new Ui::mainwidgetClass)
{
 ui->setupUi(this);
}


That's what my constructor looks like. The auto-generated class file lacked the ui(new Ui::mainwidgetClass) constructor call and this caused my GLWidget to throw an access violation error when being constructed itself. So don't do that, construct your ui.

Thoughts on beginning Qt:

It's nice. It can seem very overwhelming at first but I believe it's a matter of how you look at it. Let go of the idea of the GUI writing itself completely through the designer. Accept the idea that the entire endeavor is regular code and brackets programming with a nice designer tool to help where it can. Also, be sure to check out the "Qt Examples and Demos" app that comes installed with your SDK because running them and checking out their documentation in the QtAssistant has helped me a lot.

I will post more as I learn more. I hope this was helpful.

Sunday, April 1, 2012

Havok Tutorial: A way to detect bullet collisions

Hey. This will be less of a tutorial and more of a "here's a way to do something".

One way you can detect your bullets hitting objects in Havok is through the use of Phantoms. These are aabb's that exist simply to report what collides with them (and to apply events to those colliding objects if you'd like). This makes Phantoms great for things like triggering events based on a player's location, and bullets.

Check out the demo at: Demo\Demos\Physics\Api\Dynamics\Phantoms\PhantomObject for example code on using Phantoms.

So for example, you can draw your bullets as particles, and maintain a phantom for each of these bullets. When a bullet phantom's collision list contains an enemy you can say doBulletHitEnemy() or whatever.

Tuesday, March 27, 2012

Havok Tutorial: Detect a ball bounce.

So lets say you have several balls bopping around your scene. Or heads. Or grenades. Whatever. And you need to do something every time one of the balls bounces ( off of the ground, a wall, etc ), like play a sound effect.

You'll want to check out the Havok demos at  \Demo\Demos\Physics\Api\Collide\ContactPointCallbacks\EndOfStepCallback. Overriding the hkpContactListener class will give you the ability to launch a callback every time a rigidbody with that listener equipped experiences a collision.

Here is some code...

// Define our derived class for collision call backs.
class MyEndOfStepListener : public hkReferencedObject, public hkpContactListener
{
public:
 HK_DECLARE_CLASS_ALLOCATOR( HK_MEMORY_CLASS_DEMO );

 void collisionAddedCallback( const hkpCollisionEvent& event )
 {
  registerForEndOfStepContactPointCallbacks( event );
 }

 void collisionRemovedCallback( const hkpCollisionEvent& event )
 {
  unregisterForEndOfStepContactPointCallbacks( event );
 }

 void contactPointCallback( const hkpContactPointEvent& event )
 {
  if ( event.m_contactPointProperties->m_flags & hkContactPointMaterial::CONTACT_IS_NEW )
  {
   if(  hkpContactPointEvent::TYPE_MANIFOLD_AT_END_OF_STEP )
    my_func();
  }
 }
};

// Create the listener.
MyEndOfStepListener* m_listener = new MyEndOfStepListener();

// Create the rigid body
hkpRigidBody* rb = new hkpRigidBody(bodyCinfo);

// Set our listener.
rb->addContactListener( m_listener );

// Clean up when done.
rb->removeContactListener( m_listener );


Now of course you can extend this technique to detecting various kinds of collisions by using this and other collision listener types. Check out the demos, they will give you great ideas.

Sunday, March 25, 2012

3D Bezier Rails

If you'd like to have a 3D "rail" in your application you can use Bezier curves.

Rails are really useful for defining paths for objects to travel across.

Bay-Z-Ay curves can be really simple too for implementing rails. All you need are:

  • A list of 3D points in the order of your path.
  • A function to evaluate the position along this path from time 0 to 1.
Here is an example of a function one could use to get this bezier curve position (written in javascript but it doesn't really matter):


function atT( t: float,
     p0 : Vector3, p1 : Vector3, p2 : Vector3 ) : Vector3 {
        var t2 : float = t * t;
        
        var one_min_t : float = 1 - t;
        var one_min_t_2 : float = one_min_t * one_min_t;
        
        var x : float = one_min_t_2 * p0.x + 
         2 * one_min_t * t * p1.x +
         t2 * p2.x;
        var y : float = one_min_t_2 * p0.y + 
         2 * one_min_t * t * p1.y +
         t2 * p2.y;
        var z : float = one_min_t_2 * p0.z + 
         2 * one_min_t * t * p1.z +
         t2 * p2.z;
        
        return(Vector3(x,y,z));
    }


So given your list of points ( 0, 1, 2, 3, 4, 5, 6... ), you'd break them up into groups of 3 like ( [0,1,2], [2,3,4], [4,5,6]... ). Keep track of which group/segment your on and just interpolate from 0 to 1 to move along it. When you hit 1, increment to the next group/segment and restart at 0.

Saturday, March 24, 2012

C++0x Do It Now

Links:

Hey there. This post is just to spread a bit of awareness about the recent changes to C++ that have been made. Check out those links, no seriously go.

I myself have used the auto keyword for iterators and it is indeed sweet. Normally I'd typedef an iterator declaration but no more! I'll get around to the other stuff eventually but in general it's all intuitive and time saving. Nice stuff.

Friday, March 23, 2012

Havok Tutorial: Content Tools Part 1

What are the Havok Content Tools?

A time will come when you've got stuff working and want to flesh out a stage or something with physical objects like rigid bodies so that you can stand on grounds and smack walls... The Content Tools give you Maya, 3DS Max, and some other things I can remember because I don't use them, plugins that allow you to export entire scenes of physical objects for easy (seriously it's very easy) loading into your program.

I use Maya 2011 Student version, so what I have to say here will be about that.

After you've downloaded and installed the plugin (check out my other tutorials for that), open up Maya and go to WINDOWS>SETTINGS/PREFERENCES>PLUGIN MANAGER. Once there scroll down to hctMayaSceneExport.mll. Select both Auto load and Loaded.

Now on your main tool bar (the one with "File" at the far left) you'll see Havok Content Tools (to the far right probably).

To use this stuff, what you can do is create your geometry as you normally would in Maya, and then convert the meshes you want to into rigid bodies by selecting the mesh and then going to HAVOK CONTENT TOOLS > PHYSICS > CREATE RIGID BODIES. This will turn the selected mesh into a rigid body. A rigid body is a physical object the Havok engine can use to express things like surfaces and collisions with those surfaces.

Once you've created your stage/environment/level/world of rigid bodies you an go to HAVOK CONTENT TOOLS > EXPORT (click the box). Hit the export button and the Havok Content Tools Filter Manager should open up.

This part confused me even after reading the help manual that came with the Content Tools (which you need to read at some point). Basically you need to add the following filters in order to use the scene you've created as a bunch of physical objects in your game...

  • Align Scene To Node
  • Find Mesh Instances
  • Transform Scene
  • Create Rigid Bodies
  • Optimize Shape Hierarchy
  • Preview Tool
Now i'll be the first to tell you that I don't know (or care enough to remember) what some of these filters do. However I know that you need the Preview Tool for sure.

Once you have these filters in your Configuration Set hit Run Configuration. The Preview Tool will open and show you your scene running in real time. Nice.

To actually export what you've created to file (something I couldn't find out how to do anywhere) go to your live preview, FILE > SAVE. Now you can save your scene out in any format you choose to for easy loading into your game. I use HKT.

So that's how you make basic use of the Havok Content Tools Plugin for Maya 2011. I hope this helps out.

Havok Tutorial: Physics API Part 2

It's really important to understand a few things about Havok so that you don't spend hours working on a single error that doesn't really make sense.

The following are some things I've figured out in using Havok myself. I can verify that the described methods work.

  1. Havok needs to run within a single scope.
    • The physics engine initialization/destruction, physics world initialization/destruction, yadda yadda, any calls to Havok need to all take place withing a single block scope. What I mean by this is think of Havok as being another game loop. You can put Havok into the same while(running){} loop as your game or give it it's own thread, but either way it's a running thing that demands everything happen withing one block.
    • You can of course break things up into methods and functions, but they must be called within this loop block. Sub-scopes are also of course fine, just keep it withing the big one.
    • Some things will need to be initialized locally and cannot be declared as a class member. If you have a class member pointer to some havok thing and it gives an access violation error when you initialize it then sorry but you probably need to move the dudette's declaration into the local scope of it's use.
I'll continue to add things here. These "gotcha"s can really slow down development so hopefully you'll be able to absorb whats posted here and avoid the problems yourself.

Update:
So a question I posted on the Intel Havok forums was answered and it's related to the scoping and access violation errors. Here is the response...

"Hi, this looks like a fairly common problem. Here's a another thread with the same issue: http://software.intel.com/en-us/forums/showthread.php?t=80707 (see 3rd post). And the same kind of issue here: http://software.intel.com/en-us/forums/showpost.php?p=178103

The problem is your hkMallocAllocator is going out of scope. Since this is just in your main thread the easiest solution is mentioned in the first post - switch to using 'hkMallocAllocator::m_defaultMallocAllocator' which already exists at a global scope and will not be destructed for the duration of the application.

-Tyler

PS. I'm going to go ahead an change the Havok demos that use the stack allocated hkAllocators in main() to use hkMallocAllocator::m_defaultMallocAllocator instead since it seems to be causing a lot of confusion."

Havok Tutorial: Physics API Part 1

So what your going to want to do to get started using Havok in your C++ code is check out the great tutorial here: http://marcoarena.wordpress.com/2011/04/17/nice-to-meet-you-havok/. Its what I used to get started and It really is helpful.

Also, you can check out the Havok Youtube channel here: http://www.youtube.com/user/HavokEnthusiast.

Essentially you need to open up a demo project and recreate the settings in your own from scratch project. It isn't difficult if your used to VS2010 and if you aren't then it will pose a challenge.

Here are the includes I use in my project.


// Havok
 // Common
#include <Common/Base/hkBase.h>
#include <Common/Base/Memory/System/Util/hkMemoryInitUtil.h>
#include <Common/Base/Memory/Allocator/Malloc/hkMallocAllocator.h>
#include <Common/Base/Container/String/hkStringBuf.h>

 // Physics
#include <Physics/Dynamics/World/hkpWorld.h>
#include <Physics/Dynamics/Entity/hkpRigidBody.h>
#include <Physics/Utilities/Dynamics/Inertia/hkpInertiaTensorComputer.h>
#include <Physics/Collide/hkpCollide.h>   
#include <Physics/Collide/Dispatch/hkpAgentRegisterUtil.h>

 // Shapes.
#include <Physics/Collide/Shape/Convex/Box/hkpBoxShape.h>  
#include <Physics/Collide/Shape/Convex/Sphere/hkpSphereShape.h>    
#include <Physics/Collide/Shape/Convex/Capsule/hkpCapsuleShape.h>
#include <Physics/Internal/Collide/BvCompressedMesh/hkpBvCompressedMeshShape.h>
#include <Physics/Internal/Collide/StaticCompound/hkpStaticCompoundShape.h>

 // CInfo.
#include <Physics/Internal/Collide/BvCompressedMesh/hkpBvCompressedMeshShapeCinfo.h>

 // Filter.
#include <Physics/Collide/Filter/Group/hkpGroupFilter.h>

 // Raycasting.
#include <Physics/Collide/Query/CastUtil/hkpWorldRayCastInput.h>         
#include <Physics/Collide/Query/CastUtil/hkpWorldRayCastOutput.h>    
#include <Physics/Collide/Query/Collector/RayCollector/hkpAllRayHitCollector.h>

 // Multithreading.
#include <Common/Base/Thread/Job/ThreadPool/Cpu/hkCpuJobThreadPool.h>
#include <Common/Base/Thread/JobQueue/hkJobQueue.h>
 
 // Character rigid Body.
#include <Physics/Utilities/CharacterControl/CharacterRigidBody/hkpCharacterRigidBody.h> 
#include <Physics/Utilities/CharacterControl/CharacterRigidBody/hkpCharacterRigidBodyListener.h>

 // Character State machine.
#include <Physics/Utilities/CharacterControl/StateMachine/hkpDefaultCharacterStates.h>

 // Reducing collision tolerances between characters and fixed entities.
#include <Physics/Collide/Agent/hkpCollisionQualityInfo.h>
#include <Physics/Collide/Dispatch/hkpCollisionDispatcher.h>
#include <Physics/Collide/Agent3/Machine/Nn/hkpAgentNnTrack.h>
#include <Physics/Dynamics/Collide/hkpSimpleConstraintContactMgr.h>

 // Scene Data.
#include <Common/SceneData/Scene/hkxScene.h>

 // Serialization.
#include <Common/Base/System/Io/IStream/hkIStream.h>
#include <Common/Base/Reflection/hkClass.h>
#include <Common/Base/Reflection/Registry/hkTypeInfoRegistry.h>
#include <Common/Serialize/Util/hkStructureLayout.h>
#include <Common/Serialize/Util/hkRootLevelContainer.h>
#include <Common/Serialize/Util/hkSerializeUtil.h>
#include <Physics/Utilities/Serialize/hkpPhysicsData.h>

 // Visual Debugger includes
#include <Common/Visualize/hkVisualDebugger.h>
#include <Physics/Utilities/VisualDebugger/hkpPhysicsContext.h>

 // Platform specific initialization
#include <Common/Base/System/Init/PlatformInit.cxx>

Havok Tutorial: Getting The Tools Downloaded

First off, your gonna need to download a few things to use Havok properly, or better yet, easily.
Here is a list of things to get...

  • The Havok Physics and Animation API.
  • The Havok Content Tools Kit.
You can get the physics and animation api from here (or something around here): http://www.havok.com/try-havok. This will give you what you will be programming with in your code. It will come with executable demos as well as source code for those demos to serve as complete code examples to learn how to do stuff.

The content tools kit can bet obtained here: http://software.intel.com/sites/havok/en/. MAKE SURE YOU GET A VERSION TO MATCH YOUR MAYA OR 3DS MAX. I had to get the non 64bit 2011 or something version so that I could use the tools in my student copy of Maya 2011.

Unzip the physics and animation api and browse on down to the demos. Check em out, run the executable (there is one that has all the working demos in it), feel cool.

Install your content tools kit too.

I'll go over these things in other tutorials but for now, yea, thats how you get the actual packages needed to use Havok.

Havok Tutorial

So I've recently needed to learn the Havok physics library/engine for a class project. Lol let me tell you something about Havok...

It's great, it really is. But is has so many features that it can be near impossible to get started with it.

BUT FEAR NOT! I have shed blood learning the Havok API well enough to support basic (but good) use. I'm going to pass on the fruits of my labor to you, the visitor of this modest blog page, and tell you what you need to do to express your ideas using Havok in your own programs/projects.

First let me make a few things clear...

  • This/These tutorials are aimed at those create VS2010 C++ projects.
  • I learned all this in order to create a Windows7 PC game.
  • I am not a professional but I *try* use efficient designs.
  • The Havok demo source code will be your primary source of learning the api (other than me lol huuray!).
  • The tutorials will be broken up into multiple posts to cover several topics.
With all that being said, I hope what I post is useful to anyone out there looking to integrate Havok into their games.

Tuesday, March 20, 2012

Intel Thread Building Block Resources

Getting started with Intel's Thread Building Blocks (TBB) library can be pretty painless if you know how to go about it. Their pdf resources are great, but I just was not impressed with the lack of complete code examples for beginners. With a complete "hello world!" you can get up and running fast and can actually figure out the rest for yourself from there on.

So, here are some resources for getting started with TBB. I use these and can say for sure that they are very useful.

Note that these resources are targeted towards Visual Studio users. I myself use vs2010.

Monday, March 19, 2012

HowTo: Blogger Syntax Highlight

The following is a way to get code syntax highlighting into your blogger posts.

I've had easier times with Wordpress if I remember correctly but w/e this is for Blogger so who cares.

Sources:
In there search for the </head> tag.
Right above that post the following:





















To actually post code you need to take a block of html like this into your posts "Edit HTML" and paste it like so:



int main( int argc, char** argv ){
printf("Hi there...\n");
return 0;
}





Which will give you this:


int main( int argc, char** argv ){
printf("Hi there...\n");
return 0;
}




Here is the html for this page. The completeness of it may help...



The following is a way to get code syntax highlighting into your blogger posts.

I've had easier times with Wordpress if I remember correctly but w/e this is for Blogger so who cares.

Sources:
In there search for the </head> tag.
Right above that post the following:





















To actually post code you need to take a block of html like this into your posts "Edit HTML" and paste it like so:



int main( int argc, char** argv ){
printf("Hi there...\n");
return 0;
}





Which will give you this:


int main( int argc, char** argv ){
printf("Hi there...\n");
return 0;
}





vs2010 Add console to win32

source: http://stackoverflow.com/questions/3009042/how-to-view-printf-output-in-win32-app-on-visual-studio-2010

I'd done this before with utilities and what not but this is by far the simplest solution I've seen to getting console output into a win32 vs project. I really like it so far.

Go to properties (alt + f7).

Linker > System > SubSystem.

Change it to Console.

Go your your main file.

Go to :



int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR    lpCmdLine,
int       nCmdShow){...}




Below that function add:



int main() {
return _tWinMain(GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOW);
}



And your done.

Saturday, March 17, 2012

C++ auto indention online yes....

http://indentcode.net/,

These things can strip out your newlines and what not so they aren't bullet proof solutions to jarbled source, but, you may still want to try them out for yourself.

Wednesday, March 7, 2012

Class Project - Albert Rhesus Space Racing

My team recently completed a prototype for our Games Group.

Here is the link to our Unity project: http://tier7.net/arsr/WebTest/.

Lol the controls suck (one of the things I developed). We have moved onto the next stage of development and things should get cooler soon.

Monday, March 5, 2012

First post

I figured I should take my home server wordpress and move it over to something more accessible like a blogspot.

I'll transport the posts soon!