Showing posts with label visual studio. Show all posts
Showing posts with label visual studio. Show all posts

Wednesday, 25 December 2019

C++ Programming : SDL2 Graphics Rendering Loop

Today, it's a bit of a programming ramble, I'm literally throwing this code together, from memory and the docs... What does it do?

Well, I set up an SDL2 based graphics project.  Added font loading and set up the compilation environment and get something updating on screen, at the end there's then a second short video debugging a flickering... or if not properly fixing it, I at least start to pull the thread as to what is going wrong.

You can find the final code here: https://github.com/Xelous/Frog


And the short follow up:


Thursday, 11 October 2018

When to Dark and When to Light

As a programmer I spend a lot of my time either looking at a screen, using a keyboard or both.  As such over the years I've gotten quite particular about both, I like a nice crisp screen (or more than one to be honest) and I like my keyboard to be mechanical and be one I enjoy working with, rubber domed plastic crap from hell... For eight to ten hours a day, no thank you.

The screens, today it's easier to get nice screens, so I focus more on what's on them, which will generally be my IDE or text editor of choice on the Operating System I happen to be on at the time.

And I've come to loath the themes available in some IDE's but only in very specific circumstances...

Lets take the majority one of my time, Microsofts Visual Studio, it comes with a dark and light theme, I like both... I LIKE BOTH... But I like them in different circumstances.  The Dark theme I like when I'm in my own dark room, when it's late at night, when I'm not interacting with others.  Because (and maybe you get this as well) if I look at brighter text on a dark background the text sears a blot into my retina, not a problem if you're in a dark room, but then in a bright room or an office where you then need to go interact with others you're left with the problem of this blur in your vision... So I keep dark to my own space at my own time, I know when to Dark.

Light themes, I use in the office, I find it doesn't alienate anyone (programmer and non-programmer alike can get into dark text on a light background), and it keeps my ever changing focus in an open plan office from distracting too badly a vibrant and colourful display, I know when to Light.

The problem?  Well, seems many people don't, I've met a programmer recently whom steadfastly would not look at my work on my machine as it was "too bright"... Like he was allergic to LED light or something.  Literally telling me he couldn't read the code... Not because of formatting, not because of a lack of understanding or bad coding standards, but because I was in a light theme.

Folks, stop now and learn when to Dark and when to Light.  Please.

Tuesday, 17 January 2017

Development : Microsoft Tools Troll the Office

Today, I've been working on a brand new project, which literally I thought was parked just yesterday... My mistake it seems this project was expected to be being worked on.. A coworker is currently slogging through the same API but for a different (embedded platform) and it's taken him quite a while.

So the product owner for this new piece of software from me (which is to call XML Web Services through SOAP up stream and a hardware device over USB or serial down stream) was quite upset when they arrived at my desk and asked how their product was coming, and my reply was "Doesn't exists, waiting for the hardware".

After a short, and shirty, moment with them I assured them I would do all I could with the interface, implement ALL the XML Web Service calls through the published ASMX tomorrow... Which is today... They looked sceptical, gave me that long stare saying "no, no you won't"....

And of course I have!... Microsoft Visual Studio Troll tool award of the day, it is so simple to work with a published ASMX, just add a service reference to the URL and it generated everything for you, then tell C# you're using that name space and voila there it all is laid out for you on a platter.

I just finished this project, less than 5 hours after starting it, so have dished it back to the product owner to find the hardware, I know they're not going to believe how quickly I've completed this cycle on the development, not least because the other chap has been on it weeks and has only done about 60% of the calls so far... Yeah, I say... But he's not using troll Tools.

Sometimes, times like this in fact, I quite like C#... Don't let on, it's my dirty secret.

Tuesday, 4 October 2016

Software Engineering : C++14 Factory Create Pattern for GCC

In my previous Software Engineering item, I covered a factory create pattern, to prevent programmers using my classes with their vanilla constructors, forcing them into using a smart pointer in the hope that they would never get a memory leak from using my classes (assuming my classes clean up cleanly internally).

This pattern can be seen here, but is specific to the Microsoft STL implementation of the Memory classes.

On Linux however, with GCC, you have to make a different class a friend, this is "__gnu_cxx::new_allocator", which like "_Ref_count_obj" is an implementation of a counter to references to the allocated class type.  It is also templated, and used exactly the same way as the Microsoft version.

Use it like this:


You can see my whole screen, with all the code here:

Click to Zoom in

On the left is the example code, on the right you see me invoke g++ with C++14 to compile and then run the example program.

The code clearly shows the private constructor, it's a trivial class, if any of that confuses you then this maybe too advanced an item for you to pick up on just yet, but do come back and learn this, as it's very useful when you've built up your C++ confidence.




Friday, 25 May 2012

VS2011 Analysis Tools Are Good


I've been giving Visual Studio 2011 BETA a try, and... I'm very sad to say... I like it.


There are some things about it which annoy me, for instance I created a new C++ empty project, only to find (by default) the program was linked into the CLR - and I hate the CLR - no big deal, just pop into the options and stop the use of the CLR right?... No, you have to set both the "don't use CLR" options under the General tab, and under the C++ Language General tabs... Setting one should set the other in my opinion.



The biggest, and best addition though - one which must have a fair few vendors of tools for plug-ins quaking in their boots - is the performance profiler and graphing tools.

I'm not going to whittle on about these features, you can go read about them yourself, but I think Microsoft have not really shown off these features properly, here's the code I used to test their implementation of the new std::thread

#include <iostream>
#include <thread>

using namespace std;

void ThreadedFunction ()
{
for (int i = 0; i < 100; i++)
{
cout << i << "\r";
}
}

int main(int argc, char* argv[])
{
    cout << "Hello World" << endl;

    thread t(ThreadedFunction);
    t.join();

    return 0;
}

The reason I tested the thread work out is that I wanted to try out the "Concurrency Visualizer", often times at work I spend a lot of time proving that one artifact in an application is some part of the system breaking in to interrupt my applications... Armed with the Concurrency Visualizer my time wasted doing this will be much reduced...

Here's my full graph....


This is available from the UI, its just a tabbed item in the code environment, and so snug does it look... And very intuitavly, as I've done with music/wave editing software for two decades (and as I've done with the ANTS performance profiler) I can zoom into a specific area of the chart, thus:


And I really really like this feature, i can see how the "other processes" and how the "system process" interrupts my code... I was running this on a dual core virtual machine, so I have two cores shown, but I have tried it on my native 8 core laptop and desktop machines and seen it scale.  I've also tried to compile the C++ program with loops set as SIMD/SSE instructions, and not.  All in all, this analysis tool built in is a great new feature, and I like it.

Otherwise the editing experience is slightly better than on Visual Studio 2010 - which suffered from a slow databasing and updating sequence to generate the intellisense and code completion data for use.  2011 seems to get around that problem, and has loaded, compiled and edited my large project much more smoothly than 2010 did, on the same virtual machine.

I do agree with everyone else though, that the colour pallet, is very washed out... I've not updated to a newer beta though...

Monday, 21 May 2012

SkyPlayer Failing Whilst Debugging Code

I usually sit coding with some form of streaming media running on my secondary screens, notably I use BBC iPlayer, Channel 4 OD, ITV Player and Sky Player... The latter of which I pay a hefty subscription for the movie channels and everything.

Now, this evening is the first time I've tried to stream one of the films live, I usually download them to the SkyPlayer desktop application and let them run locally, but this often means a loooooong wait for the film to download (as my connection is usually very busy).

And I'm sorry to say, that playing films live, whilst debugging code is an utter shit.  The keep stopping and stuttering, distracting me from my code, and worse of all if they play they seem to get so far and then report an error that the media file is not available and give the obtuse "contact sky help pages"... which are no help whatsoever.

Now, the machine is a octo-core i7 (yes 8 cores) its got massive 16GB of RAM, its hefting two 24" screens off of a dual 470GTX SLi graphics solution... Yet it can't play a media file from sky, which its been playing no problem for the previous 15 minutes?  Just long enough for the film to actually begin proper...

They have no problem screaming the pre-film adverts to me, adverts despite this being a paid for stream already!

So, I started to get itchy and look what the service is doing, now I have a suspicion that the application running the stream (a silverlight application - urgh) is testing, looking at the system, for things it thinks might be trying to rip the film off...

And I think its decided that having Visual Studio open is one such situation.  I can't be sure, but everytime I start the film playing with VS open, after a while the player stops falls on its ass, arses around with a buffering page for longer than I care to think and then it says this stupid "can't find the media file mate" message.

Without Visual Studio running... It plays no issue... hmmmmm

I can't prove a link, but if I do, expect me to just cancel my sky subscription, I've already had a moan at them this month, see my earlier post, this is just another nail in the coffin.