Friday, August 23, 2013

An old timers view on crunch time.

It's been 20 years of working on video games.
20 years... two damn decades.

The only advice I have for a newbie to the games industry:


  1. Value your life more than work...

Your life is yours, not the property of whatever company you work for, America is NOT a communist country so don't act like it is one.

Sure when you have a hard set deadline you should put in a bit of extra work toward your goal, but realistically here's what happens in a regular work day versus a crunch time work day has little effect on the aggregate total work -- if you crunch for more than a few weeks. After about three weeks of crunching productivity tends to bottom out, at worst you're losing the actual productivity you'd normally be able to put in.

You're groggy from staying at the office till 2 am. You're getting up later and getting to the office later. This means you're taking lunch later, and leaving later. Basically, all you've succeeded at doing is moving your working day to a different part of the clock.

This means you're missing out on what you used to do when you normally got home. Worst of all, you've lost motivation. The death march is the worst state for a game studio to be in. Everyone is on edge, creativity is gone, and hostility between co-workers rises; stop it.

Friday, April 12, 2013

The real reason for PC sales decline.


There's an idiotic blame game going on with the current "slump" in PC sales. The blame is being cast on either mobile devices or operating systems, but no body is pointing a finger at the folks ultimately responsible for making the hardware that is the PC.

There are some writers who have pointed out that their computer from a few years ago doesn't need upgrading. This is half of the truth. They feel that there's no reason for upgrading the hardware because it's still fine.

We were promised real time ray tracing in games in 2008, and now, 5 years later we're still seeing forward rendering or deferred rendering systems at best. We were promised 2560x1440 monitors would be the new standard in monitor resolution, but 1920x1080 is still the "high end" with 1366x768 still on the top of the heap as far as browsers seem to be concerned. I want a 4k monitor, like three years ago.

If i could get a trio of 27" 4k monitors for 700 a piece, sure I'd get that, but then I'd need a set of video cards that don't exist. I'd like to run them in 3d, with physics, and the real time ray tracing with sub-surface scattering, refractions, and all of the "film" like qualities that could be done, if CPUs and GPUs could handle it. But there's the problem. None of the hardware exists for doing these things, and your "just fine" computer has no chance in hell of being able to do even half of this.

Intel, AMD, nVidia, IBM, you guys have been slacking! You're the real bottle neck for the desktop advancement and the reason for the sales slump. Offer up a 10ghz 128core 16GB L3 cache running at 10 watts, I'd be there. Give me a trio of 24GB video cards with millions of cores I'd put them in. If i could get a 20TB SSD sure, I'd put that in my new system as well, but I can't it doesn't exist.

Between 1993 and 2003 CPUs were practically doubling in speed and power, then electrons started giving transistors problems. But we've discovered many different solutions, many different alternatives and new methods to overcome the limitations.

We've been promised graphene wafers, single atom thick germanium wafers to solve these problems, but so far nothing has hit the market. Every day I read about IBM making headway into quantum computers, but I can't buy anything from that research, so why should I care?

I've been reading about super cheap manufacturing methods for making gigantic high res OLED screens, so why aren't there any 300.00 2560x1440 monitors out there?

Common, folks, PCs aren't getting better, that's why no one is buying them. Your old pc sucks, it seriously does. It's just even more unfortunate that nothing better has come out.

Friday, January 4, 2013

Standing Desks

Okay, so on the first week of a standing desk at the office.
Distinct advantages have come to light, the first one is to visit someone at their desk.
When more than one or two people are visiting your workstation at a sitting desk you have to find a lot of chairs. Then the chairs need to roll around and re position for someone to face your computer and do something on your keyboard. This is almost always a slow process involving a lot of awkward chair rolling, and in the rare case, a chair might get stuck and fall spilling a programmer to the floor.
With standing desks you're all standing. Moving around for someone to use your computer is fast, easy and rarely ever involves any effort. Stepping to the side to let someone access your computer is easy. This ease of access is more likely to lead to more people using your computer. It's great!

Aside from being on my feet all day this standing desk thing is great. I feel better, and I think my legs are happier for it. Aside from the usual health benefits, the standing desk is great for your work environment and task sharing. As an engineer it's great for someone to come by, show me where i broke something and fix it, or at the very least point to a line of errant code that I need to fix.

Here's another vote for you getting a standing desk. I'm glad I did.

Wednesday, December 12, 2012

lua string to table

I couldn't find a clear way to do this... the entire bullshit that everyone always does is just reference the damn wiki. Which is about as clear as mud. I hate it when programmers assume you're already a programmer.

in anycase given a string like
myString = "this is a long string"
and you want to turn this into an array of letters
like myArray = {t,h,i,s, ,i,s, , a, ,l,o,n,g, ,s,t,r,i,n,g}
for reasons of being able to do things based on each letter.

you should do this:

myArray = {} -- make empty array
for i = 0, #myString do -- #myString is the length of the string
    local s = string.sub(myString,i,i) -- gets the character at location i in the string
   myArray[i] = s -- assigns the table[i] to the character which was returned to s
end


that's it... a clear example with, imagine that!

Tuesday, November 6, 2012

String^ to const char* C++/CX

So today I was looking to convert a textBox text field into a const char to use as an IP address to send data to. This wasn't exactly easy to find any info on so I had to write this post.

First I needed to get the String^ from the textBox xaml object like this
String^ s = IPAddress->Text;
this assumes that the textBox is named "IPAddress".
then make a size_t object and i'll call it i, this was needed to set the data size for the wcstombs_s function at the end. Not exactly sure what this is used for, but this is working, so if anyone has any good understanding of this function then please fill me in down in the comments below.

String^ s = IPAddress->Text;
size_t   i;
const wchar_t* cw = s->Data();
char *c= new char[s->Length()+1];
memset(c,0,s->Length()+1);
wcstombs_s(&i, c, (size_t)s->Length()+1,  s->Data(), (size_t)s->Length()+1 );
SomeClientFunction.SetIPAddress(c);

then I make the const wchar_t* pointer and use the s->Data() to satisfy that.
then i make a new char[] array with the length of the String^ this is pretty simple. so char[s->Length() + 1] is how that's done.
then I have to allocate the memory for the char*c using memset, pretty easy here.
then the weird wcstombs_s which is needed since wcstombs was depricated, so i needed to use the safe version of it to get past the WinRT checks. I guess this is a memory security thing.
now the new safe version of the function asks for the &i which im not sure what does, then you add in the target char array then set a size, then give it a source using s->Data(), then tell it how long that array is.
and that's that, worked for me!

I'll also note that my SomeClientFunction was expecting (const char * ip) in it's args.

I just use this blog to help remind me how I did things in general.

hope this helps someone.

edit:
So the &i is a returned value that's the size of the actual c in this case. Since c could actually be shorter than the original size allocated for it when using some other methods to create the size of c.

Friday, October 5, 2012

Dealing with create_task in WinRT using C++/CX


Getting into Windows8 C++/CX

Tutorials and introductions to C++/CX
http://msdn.microsoft.com/en-us/library/windows/apps/hh465045.aspx
from that link:
"When you use Windows Runtime objects, you're (typically) using C++/CX, which provides special syntax to create and access Windows Runtime objects in a way that enables C++ exception handling, delegates, events, and automatic reference counting of dynamically created objects. When you use C++/CX, the details of the underlying COM and Windows architecture are almost completely hidden from your app code. For more information, see C++/CX Language Reference. However, you can also program directly against the COM interfaces by using the Windows Runtime C++ Template Library."
"You're primarily programming against a new, easy-to-navigate, object-oriented API, the Windows Runtime, although Win32 is still available for some functionality."
Some functionality has me concerned as the threading and concurrency namespaces are useful for what we were doing in the previous C# version.
This continues into a tutorial about what the different components in a new project are. The partial ref and auto keyword are also mentioned in breif detail.
in the first paragraph of that page there were a couple of links to the C++/CX language reference including...
as a note the example shows Grid^ grid = ref new Grid(); the ^ is used when dealing with anything that uses ref new to create;
I guess this feels sort of like

int s = int(0);
int *i = &s;

where when a pointer is used you need to use a reference operator to get the value at the address of a pointer.
in my test i wrote the following.

auto grid = ref new Grid();//this is the same as Grid^
grid->Width = 600;
grid->Height = 500;
auto red = ref new SolidColorBrush(Colors::Red);
grid->Background = red;
if(grid->Parent == nullptr)
{
LayoutRoot->Children->Append(grid);
}

One important thing is that Colors::Red is not Colors->Red. As -> points to properties of a class and :: points to static members of a class.
"In the most basic sense, a ref class is a COM object that implements the IInspectable interface and whose lifetime is managed by a smart pointer."
"The partial keyword tells the compiler that the declaration of this class is continued in another code file."
good to know, sort of nice you can break up a big source file into a few small ones.

"If you, the programmer, have to add variables or functions to the MainPage class, do so in MainPage.xaml.h and MainPage.xaml.cpp." As you normally would.
"If the XAML editor has to add variables or other boilerplate code, it does so in the *.g.h and *.g.hpp files."

I've got to find where the .g. files are hiding in our project, I'm pretty sure I saw them somewhere, but i'll check if adding things into these files will allow for better cross talk between the C++ and C++/CX stuff.

"In general, you can safely ignore the *.g.* files. That's why Solution Explorer hides them by default."
Hey, hiding them by default? What if we, the programmer, need to edit the xaml?? WTF. Weird I can't find these files. oh well, moving on...
further down in the post there's a special include for

#include <ppltasks.h>

I didn't catch this include before, wasn't in any documentation other than the tutorial. Things like this can't be missed so I think something that important should be a bit more highlighted.

auto grid = ref new Grid();
grid->Width = 600;
grid->Height = 500;
auto red = ref new SolidColorBrush(Colors::Red);
grid->Background = red;

create_task([grid]{
grid->Height = 100; //this throws an error
}).then([grid]{});

if(grid->Parent == nullptr)
{
LayoutRoot->Children->Append(grid);
}

In the previous test code I found that this throws an error when trying to execute anything inside of the lambda in the create_task function. The red squiggle under the [grid] says a local lambda is not allowed in a member function of a WinRT class. Not sure why that is.
expanding on the create_task function. In

I created the following code to stick a wait timer.
auto i = 0.5;

create_task([this, i]{
auto thispage = this;
        thispage->Dispatcher->RunAsync(
CoreDispatcherPriority::Normal,
ref new DispatchedHandler([thispage,i]()
       {
thispage->GridControlElement->Opacity = i;
       }));
wait(SomeRandomInteger); //a static global variable.
}).then([this, i]{
auto thispage = this;
        thispage ->Dispatcher->RunAsync(
CoreDispatcherPriority::Normal,
ref new DispatchedHandler([thispage]()
        {
thispage->GridControlElement->Opacity = 1.0;
        }));
});

So this is scoped as the page that the create_task lives within. It's then passed through the lambda into the create_task function I also added an number value to see how that will work when passed into the [this,i] part of the create_task.

Then I created another auto so that this can be used as thispage. so now the create_task has access to elements on the page. so then we can create a new DispatchedHandler and pass along another referenced task.

Elements in the thispage reference can be accessed and modified asynchronously from the rest of the UI.
So after some amount of time while the wait is running, the UI element will be mostly translucent. then after the timer is up it goes back to being fully opaque.

all the while the wait is running the rest of the interface is doing just fine.

Adding this into a touch event...

http://msdn.microsoft.com/en-us/library/windows/apps/hh699871.aspx
from that link:
"Visual C++ component extensions (C++/CX) is a set of extensions to the C++ language that enable the creation of Windows Store apps and Windows Runtime components in an idiom that is as close as possible to modern C++. Use C++/CX to write Windows Store apps and components in native code that easily interact with Visual C#, Visual Basic, and JavaScript, and other languages that support the Windows Runtime. In those rare cases that require direct access to the raw COM interfaces, or non-exceptional code, you can use the Windows Runtime C++ Template Library (WRL)." and "Windows Store DirectX games and graphics-intensive apps. For more information, see Create your first Windows Store app using DirectX." the DirectX + Xaml are the core of what we're doing. also, that page has a "quick reference" for the other components for C++/CX

A collection of links to various C++/CX documentation dealing with the new extensions for WinRT

http://blogs.msdn.com/b/vcblog/archive/2012/08/29/cxxcxpart00anintroduction.aspx
http://sridharpoduri.com/2012/08/13/programming-windows-8-applications-using-c-cxan-update-on-the-book/

Thursday, October 4, 2012

Timers in windows8 using c++


Just getting a basic timer in c++ isn't as easy as in C#.
So I'm stepping myself through this and documenting my findings.
I just want to start a timer on a touch event to fade out a control when the finger leaves the screen.
So to do this I want that control to wait for a few seconds before going back to it's home position.
I could use wait, but then the rest of the screen locks up till after the wait.
Since I want to use multi touch features this is bad.
The best way to do this *I think* is concurrency and the call function, but finding a good example for this has been really hard.

http://msdn.microsoft.com/en-us/library/dd504870.aspx I started here to get a start on the concurrency run time.
Also writing a windows 8 metro app in WPF, so that's adding some little hitches here and there with various features that I can and can't use.
Also can't use 3rd party libs like boost.asio which is because the client doesn't like those things, doh.
Google for running multuple tasks and I get to
this link http://msdn.microsoft.com/en-us/library/dd728065.aspx.
In here was the following code snippet...

int wmain()
{
// Create a call object that prints a single character to the console.
call<wchar_t> report_progress([](wchar_t c) {
wcout << c;
});
// Create a timer object that sends the dot character to the  
// call object every 100 milliseconds.
timer<wchar_t> progress_timer(100, L'.', &report_progress, true);
wcout << L"Performing a lengthy operation";
// Start the timer on a separate context.
progress_timer.start();
// Perform a lengthy operation on the main context.
perform_lengthy_operation();
// Stop the timer and print a message.
progress_timer.stop();
wcout << L"done.";
}

This looked pretty helpful. There's the call and the timer functions that look pretty good.
Unfortunately in report_progress([] (wchar_t c) {...} there's a lambda and I get the following error

Error: a local lambda is not allowed in a member function of a WinRT class.

damn.

So now what? Dig around more for timer class in WinRT and I find
http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/fd9c3010-484b-4881-88c8-765473fd5b1e
What's going on here?

Instead of SetTimer(), you should use Windows::UI::Xaml::DispatcherTimer.
See the MSDN article here: http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.dispatchertimer.aspx.

Okay, so lets go there.
http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.dispatchertimer.aspx.
and...

Server Error in '/' Application.
The resource cannot be found.Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. Requested URL: /en-us/library/windows/apps/windows.ui.xaml.dispatchertimer.aspx.

Crap, so look up xaml dispatch timer and get to  http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.xaml.dispatchertimer
I think im getting closer. This is looking a bit better, something that seems to be useful, finally.
I just used this in C# for the previous version of the interface I was building in C#, perfect!
I think I can use this. The example is in C# so i need to find a C++ example,
get to this http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/edff3bf2-4223-49fe-b66b-119702458700
The thread goes through a few iterations. I get to what I think is really close but get stuck at.

timer->Tick += ref new  Windows::Foundation::EventHandler<Object^>(this, &DispatcherTimer_Tick); 

I get an error:

object not needed for the specified function

So I delete "this" and the following "," and that seems to do the trick.
No more errors...
So I start my vars with...

Windows::UI::Xaml::DispatcherTimer ^SomeTimer;

and then add in a way to count ticks...

int Ticks;

and when the xaml page is initialized i add in

XAMLPage()
{
InitializeComponent();
//other init stuff...
SomeTimer = ref new DispatcherTimer;
SomeTimer->Tick += ref new  Windows::Foundation::EventHandler<Object^>( &Timer_Tick); 
TimeSpan t;
t.Duration=1;
SomeTimer->Interval = t;
}

Then I precede the page initialization with my Timer_Tick function that looks something like...

void Timer_Tick(Platform::Object^ sender, Platform::Object^ e)
{
OutputDebugString(L"TIMER!!!");
Ticks++;
if(Ticks>10)
SomeTimer->Stop();
}

so after 10 ticks the timer stops.

I'm far from a super c++ programmer, and mostly a C# or unrealscript game programmer guy.
I've been doing this stuff for a while and I learn fast, and that's pretty important.
I do these little process blog entries to help myself out.
It's like a breadcrumb trail I can follow to avoid backtracking.
Hope this helps someone.

rxokita's shared items