Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 01 Aug 2007
Offline Last Active Feb 22 2014 09:35 PM

Topics I've Started

Help compiling GLFW from source?

22 February 2014 - 03:43 PM

Hi guys.  I downloaded glfw-3.0.4 from the glfw site and I am trying to follow their instructions to build the project from source.  However, when I type 'cmake .' in the glfw-3.0.4 directory, I get the following errors:


CMake Error: Cannot determine link language for target "glfw".
CMake Error: CMake can not determine linker language for target:glfw

Now it's very obvious what's causing these errors but I am wondering why they are cropping up if I am following the build directions that are posted on the GLFW site?



Why isn't my code using Pipes working?

04 January 2014 - 02:37 AM

I am trying to set up communication via a Named Pipe between two programs.  I am very new to the concepts behind pipes and multithreaded applications so correct me if my terminology is wrong or if I am doing something terribly.  Here's how the program is designed:  


My client program (C# .NET) takes strings via command line input and writes them over a named pipe to my host program (C++/Windows API).  The host program simply outputs these strings in its own command line window.


The problem I am having is that once I create the pipe in the host application and then startup the client application using ShellExecute(), the C# client code reports that it has connected to the Pipe successfully.  However, on my first call to ReadFile() from within my C++ code, GetLastError() reports an ERROR_NO_DATA error (which according to MSDN's minimal documentation means "The pipe is being closed."


Here is the client-side code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.IO.Pipes;

namespace PipeClient
    class Program
        static void Main(string[] args)
            using (NamedPipeClientStream pipeStream = new NamedPipeClientStream(".","testPipe"))

                Console.Out.WriteLine("Attempting to connect to host...");
                Console.Out.Write(" Successful");

                while (true)
                    String input = Console.In.ReadLine();

                    byte[] buff = new byte[input.Length * sizeof(char)];
                    System.Buffer.BlockCopy(input.ToCharArray(), 0, buff, 0, buff.Length);

                    pipeStream.Write(buff, 0, buff.Length);

Here is the Host code:




bool init(void);
void freeResources(void);

bool init(void)
	DWORD error;
	int result;

	//set the name of the console to a random name guaranteed to be unique so that we can retrieve the HWND with FindWindow()
	/*std::wstring newConsoleName(L"asdfasdfasdf");

	wchar_t consoleName[MAX_WINDOW_NAME_LENGTH];
	GetConsoleTitle(consoleName, MAX_WINDOW_NAME_LENGTH);

	hWnd = FindWindow(NULL, newConsoleName.data());

	//create the pipe
	hConsolePipe = CreateNamedPipe(

	if(hConsolePipe == INVALID_HANDLE_VALUE)
		OutputDebugString(L"\nfailed to create the console pipe\n");
		return false;

	//launch the client
	result = (int)ShellExecute(hWnd, L"open", L"PipeClient.exe", NULL, L"C:\\Users\\Jared\\Documents\\Visual Studio 2012\\Projects\\PipeTest\\Debug\\", 1) ;
	if(result <= 32)
		OutputDebugString(L"\nUnable to open 'PipeClient.exe'\n");
		return false;

	while(!ConnectNamedPipe(hConsolePipe, NULL))
		error = GetLastError();


			OutputDebugString(L"\nClient-Host connection failed\n");
			return false;

	return true;

		if data is pending in the read-buffer:
			parse the data and execute the commands it contains

		if data is pending in the write-vector:
			while(write-vector is not empty):
				write data in write-vector[i] to the pipe
				remove write-data[i]


	//run the client app and then hook it up 

void freeResources(void)

int main(void)
	char readBuffer[256];
	DWORD numBytesRead;
	int error = 0;

		return 0;
		if(!ReadFile(hConsolePipe, readBuffer, 256, &numBytesRead, NULL)) //This is the line which causes ERROR_NO_DATA
			error = GetLastError();
			if(error != ERROR_IO_PENDING)
				OutputDebugString(L"\nGetLastError() != ERROR_IO_PENDING\n");
			std::cout << "\nData received:  \n\n";
			for(int i = 0; i < numBytesRead; i++)
				std::cout << readBuffer[i];

			std::cout << "\n\n";


Help me fix this code using std::shared_ptr

04 December 2013 - 11:52 PM

I am starting to integrate smart pointers into my code.  However, I am still getting stuck up on exactly how to use them.  Here is the relevant code snippet:

bool DebugLayer::Init(
		DebugOptions options, 
		const std::shared_ptr<Renderer> &renderer, 
		const std::shared_ptr<const InputController> &inputController, 
		const std::shared_ptr<const Timer> &timer,
		const RECT& windowRect)
		if(!inputController || !timer || !renderer || !inputController)
			OutputDebugString("\nInvalid parameters passed to DebugLayer::Init()\n");
			return false;

		this->debugOptions = options;
		this->renderer = std::make_shared<Renderer>(*renderer);
		this->inputController = std::make_shared<const InputController>(*inputController);
		this->timer = std::make_shared<const Timer>(*timer);



I am trying to pass const pointers to const objects into the function.  For some reason, when I try and set my own class instance shared_ptr objects to what I pass into Init() I get the following errors from <memory>:


Error 8 error C2440: '<function-style-cast>' : cannot convert from 'std::shared_ptr<_Ty>' to 'std::shared_ptr<_Ty>'
Error 9 error C2228: left of '.swap' must have class/struct/union
Error 10 error C2440: '<function-style-cast>' : cannot convert from 'std::shared_ptr<_Ty>' to 'std::shared_ptr<_Ty>'

Can someone explain [loop] and [unroll] to me?

26 October 2013 - 09:53 PM

So I am having a hard time understanding the difference between [loop] and [unroll].  From what I understand, [unroll] causes the compiler to take the contents inside a loop and repeatedly place it's machine code in the output for as many times as the loop executes.  I am unsure of how to use [loop] and what the tradeoff's are between the two?  I have looked at the MSDN explanation but it seems to be brief and doesn't really give me enough information to understand it.



How do I implement the singleton I describe without circular inclusion?

24 September 2013 - 03:07 AM

I have a class called 'Window' which essentially contains everything need to run my program.  Inside window, I have 'Simulation', 'Renderer' and 'InputController' classes.  In some instances, these classes need access to a global pointer to a 'Window'.  For example:  I have a DrawDebug() function in 'Renderer' which needs to get information about the status of the Simulation so it can be drawn as text on screen.  I'm not sure exactly how to go about doing this and some help would be much appreciated.  Thanks :)