Showing posts with label blog. Show all posts
Showing posts with label blog. Show all posts

Monday, 22 March 2021

Misc // New PC!


*This is a bit of a long one; I apologise. tldr; New pc with a 3090. Runs perfectly.

So I originally had no plans to upgrade my computer. My boy Kyoya (named after Kyoya Ootori from Ouran Highschool Host Club) was getting dated but still ran Visual Studio and could play most games on high settings with temperatures reaching around 70/75. He has an i7-4790k (base 4ghz) with 16gb DDR3 1600mhz ram and a GTX 980. I bought him back in September 2015 and up till then, he was the beefiest pc I have ever owned. He cost a whopping £1700 and was a pre-built from HP. 

However, in January, Scan had a shipment of Nvidia 3090 FEs and so I impulse bought one because it was in stock. It would not fit in Kyoya's case due to the drive cage and optical drives but also, he has no ventilation (other than exhaust) and pretty much relies on negative pressure. Also, it would've been severely bottlenecked by the 4790k. And so began the hunt for pc parts in a time where there are no pc parts.

I knew immediately I wanted an AMD 5950x but at this point I'm not sure they exist so I settled for the 3950x. I also wanted 128gb of ram but that also didn't exist so I had to settle for 64 (oh no). I did get the motherboard I wanted and the Noctua Chromax Black NH-D15 but failed to research properly and that fan actually blocks the first pcie lane on the Crosshair VIII Formula. I really wanted an air cooler because I think they look cool (pun intended) but ended up with a Corsair Hydro H150i all in one. I've never had an aio before but it's growing on me.


I spent a ridiculous amount of time on the cable management, even though you can't really see it due to the dark tinted glass; I love that you can just see the little bits of rgb in the case from the cooler, gpu and motherboard display.




The new pc is called Archer (after Jonathan Archer from Star Trek Enterprise) and here he is with his little big brother Kyoya who has now become my "minimum specs" testing pc. Side note: This is not the final setup; I was transferring files.

Parts list:
CPU: AMD Ryzen 9 3950X 3.5 GHz 16-Core Processor
CPU Cooler: Corsair iCUE H150i RGB PRO XT 75 CFM Liquid CPU Cooler
Motherboard: Asus ROG Crosshair VIII Formula ATX AM4
Memory: Corsair Vengeance LPX 64 GB (4 x 16 GB) DDR4-3600 CL18
Storage: x2 Samsung 970 Evo 1 TB M.2-2280 NVME Solid State Drive
Storage: Samsung 870 QVO 4 TB 2.5" Solid State Drive
Storage: Seagate BarraCuda Pro 10 TB 3.5" 7200RPM Internal Hard Drive
Video Card: NVIDIA GeForce RTX 3090 24 GB Founders Edition
Case: Fractal Design Define 7 XL Dark ATX Full Tower Case
Power Supply: Fractal Design Ion+ 860 W 80+ Platinum Certified Fully Modular ATX Power Supply 
Case Fans: x3 Noctua Industrial 3000rpm 140mm 
OS: Microsoft Windows 10 Home OEM 64-bit

After some research, I decided to set the ram to a speed of 3200mhz as the 3950x can only work with 3600 when overclocking and I want nothing to do with that; I need this pc to be as stable as possible so OC has been disabled. The ram was running at 2144 when first booted and that speed was painful. My ddr3 1600mhz felt lightning fast compared to it.

This computer was built specifically to handle Unreal Engine 4, Blender and Creative Cloud workloads and boy does it deliver. Eventually I may upgrade to 128gb ram but I really don't need it right now; it runs perfectly with 2 instances of Unreal open, several chrome tabs, PhotoShop and Blender. 

For benchmarks, I tested Unreal Engine 4, Blender and two of my most demanding games; House Flipper and Planet Coaster.

In Blender, my gtx 980 took 2 minutes 14 seconds to render this final doughnut scene using CUDA. The 3090 did it in 9 seconds with the new optix renderer and 14 seconds using CUDA. Every person I talk to has raised their eyebrows at me for spending £1400 on a graphics card but it's sped up my workflow by 1000%. I have zero regrets.

When it comes to Unreal Engine, my i7-4790k usually took 25 minutes to compile 5000 shaders. The 3950x took 2 minutes. Out of the bag UE4 will try its best to utilise all of the cores you have and when I opened up one of my biggest projects, the editor hung for a good 5 minutes but task manager showed it was using every core to compile shaders. Moving round the scene is buttery smooth and landscape editing is no longer a chore.

Photoshop can still be a bit jittery when doing certain things and I've even got it installed on one of the NVME's but Adobe applications will happily take up all your ram and demand more so I'm not too bothered. I am now running CC 2021 now though which is nice. I stayed at 2017 on Kyoya as he was struggling.

I'm impressed with the CPU cooler; even at 100% load the fans stay around 700-1000rpm with the temperature reaching highs of 42 degrees. The highest I saw it was 49 whilst playing Planet Coaster. That game actually turned out to be a great stress tester as one of my worlds has thousands of items. I stopped playing it on Kyoya a year ago because he just couldn't handle all the objects anymore. The 3090 reached up to 70 but I've noticed that it won't even turn the fan on under 60 degrees. It seems Nvidia have made their new cards run happily at temps of 60/70 degrees.


Playing House Flipper on max settings for the first time in 6 months was glorious though. The 980 was getting dangerously close to 90 degrees with all the latest additions and amount of items you can add (also I don't think this game has been optimised well...if at all). I had to limit the game to 60 fps and keep everything on medium. The 3090 happily sits at 60 degrees with max settings and 120fps. I can finally stick as much shit as I want in houses and not worry about my gpu.

On scenes like this, the 980 really struggled on max settings


My most played game is Minecraft but that can pretty much run on a potato. I did turn RTX on and the 3090 didn't even care.


A quick note on some of the other items:

Noctua Industrial case fans -  When these are running at 3000rpm you'll know about it. They sound like jet engines taking off. I keep them around 400 rpm, ramping up to 1500 when the cpu is at max load but even the lower speeds are more than enough to keep the case cool. Plus they look beautiful.

Fractal Design Define 7 XL - I don't know what made me buy the XL. The standard Define 7 would've been more than enough but it was a joy to build in. It's absolutely huge but looks fantastic. Airflow is great, storage solutions are insane (can hold up 20 drives) and it has a fan control center as you can fit an absurd amount of fans in it.

Fractal Ion 860w PSU - I really wanted at least a 1000 watt psu after watching several videos on the 3090 just to be on the safe side but there were no power supplies with a platinum rating going at the time I was buying. I eventually settled on this one as it was the highest platinum wattage I could find and Fractal offers a 10 year warranty. I'm glad I did. The cables are smart and easy to work with and it runs completely silent. I've had no problems with it and seen the 3090 spike several times with no power outages.

Asus Crosshair VIII Formula - Completely unnecessary but it's beautiful. I love the little oled display; it's well worth the price jump from the Crosshair VIII Hero. I like to have it display the CPU temp but it can display custom gifs. Very easy to build on and the IO shield was already installed. I am extremely happy with this purchase. One little thing; I've been using the same speakers from Philips for 15 years and the sound difference from this PC is astonishing. 

Overall; I'm very happy. Even more so for building it myself (it was my first time!) I'm still keeping an eye out for a 5950x but Archer has already exceeded my expectations for a personal dev PC so I probably won't. 

Tuesday, 18 August 2020

Chapter 15 // Exercise 2 - Principles & Practice Using C++

In this exercise I am using Visual Studio 2017 and modified versions of the graphics files used throughout the chapters. You can find those versions through the link below.

Chapter 15 // Exercise 2

Define a class Fct that is just like Function except that it stores its constructor arguments. Provide Fct with "reset" operations, so that you can use it repeatedly for different ranges, different functions, etc.

Github: https://github.com/l-paz91/principles-practice/tree/master/Chapter%2015/Exercise%202


In this one took me a while as I pondered over how to re-write the points that had already been added to a shape once it's drawn. I thought about deleting the shape and creating a new one but the easiest way was to simply provide a function in Shape that clears the points vector. That way no new shapes are made and StoredFct can just call Function.

Tuesday, 21 April 2020

Chapter 13 // Exercise 2 - Principles & Practice Using C++

In this exercise I am using Visual Studio 2017 and the graphics files found here:
https://github.com/l-paz91/principles-practice/tree/master/Graphics%20Files

Chapter 13 // Exercise 2

Draw a box with rounded corners. Define a class Box, consisting of four lines and four arcs.

Github: https://github.com/l-paz91/principles-practice/tree/master/Chapter%2013/Exercise%202


This could've been done quickly however I wanted to be able to give users a way of adjusting the 'roundness' of the corners and I was stumped (I'm not good at this type of stuff...I just like to make things go faster). I got it wrong a couple of times due to not taking the time to understand how  fl_arc() draws.


The arc is basically determined by the radius of the circle it calculates, so by supplying a "roundness" variable we can use that to get the radius of the arcs (by simply dividing it by 2). Perhaps a better name for it would be "Circle Width" but I don't think and end user would find that useful.

The cyan box was given a 'roundness' of 20 and the black box 100. Fl_arc() really confused me in this because I didn't stop to think about the point at where each arc was being drawn from. Fl_arc() simply draws a portion of a given circle from the top left hand corner. So that would mean our top right-hand arc x,y co-ordinates lie before the end of the top vertical line (exactly the end minus the radius). 

When drawing the lines, they use the position of the arcs (plus either the radius or roundness) to determine the length/height they should be; thus allowing them to adapt to tighter corners (but not exceed the width/height supplied).

A quick note on fl_arc as well. Fl_arc() requires you to give two angles (with the first smaller or equal to the second). If you imagine a clock face, FLTK draws an arc clockwise with 3 being 0 (for some odd reason). So the top left-hand arc would be the angles 90 to 180 (or 9 to 12).

To fill in the box, fl_pie() just needs to be supplied with the same data given to fl_arc() and then draw 3 rectangles using fl_rectf().









Friday, 20 March 2020

Chapter 12 // Exercise 5 - Principles & Practice Using C++

In this exercise I am using Visual Studio 2017 and the graphics files found here:
https://github.com/l-paz91/principles-practice/tree/master/Graphics%20Files

Chapter 12 // Exercise 5

Draw a red 1/4-inch frame around a rectangle that is three-quarters the height of your screen and two-thirds the width. 

Github: https://github.com/l-paz91/principles-practice/blob/master/Chapter%2012/Exercise%205

Eurgh, I had to get the calculator out for this one. I hate doing percentages.


Saturday, 24 February 2018

Where does the time go?

So my last post on this blog was the 1st of June 2017. It's disheartening to see I only posted twice last year however I found my first year of uni a little overwhelming. Since the last post I've completed my first year and I'm now four months away from completing my second and receiving a foundation degree. I'll definitely be doing the honours top-up to receive a full bachelors degree next year however the course I'm doing is heavily focused on video-game design with some programming involved. Over the past year and half I've realised that I much prefer programming over making games. 

With the industry moving towards making games in pre-made engines such as Unreal, Unity, CryEngine or their own in-house engines like RAGE and Snowdrop it would appear the art of programming a game from absolute scratch is a thing of the past. Sure you can but it's something that indie devs would do and if you're an indie dev (like I wanted to be) it's hard to complete a full game without the use of an engine like game maker whilst paying the bills. 

I've become a big fan of C and procedural programming as it follows how my brain works. I like to make lists and follow those lists; ticking one task off at a time. Object-Orientated programming is more than a little confusing to me as it jumps around all over the place. I recently just finished implementing a font class for my DirectX 11 engine and the amount of times I had to go back and change function declarations; create new functions or just redesign the entire thing entirely did my head in. Perhaps it just goes to show how weak my C++ skills are right now, I'm certainly more comfortable writing class interfaces now than I was a year ago. A year ago, trying to implement code from MSDN seemed impossible so perhaps I'm just being impatient with myself.

I've decided to do a masters degree in Computer Science once I've finished my bachelors as it's more geared towards data science, memory management and general programming which I'm much more interested in now. The past year of my degree has been filled with writing game design documents, researching mobile input methods and 3D modelling; the latter I detest with a passion. I'm also not a big fan of Unreal and I find it dissatisfying to have to use it constantly throughout my degree. I am however enjoying building my own engine using C++ and DirectX, there is just something about writing code and clicking the build button and it compiles with no issues.

I took this blog off google for while as I wondered if I should continue it, however I am determined to finish this book and his next one which is for more advanced C++ programmers. I will begin re-posting however at a slower pace as I have many deadlines looming. I would like to finish this book by the end of summer though. Thank you to everyone who drops by and I hope someone finds these posts helpful.

Thursday, 1 June 2017

Chapter 6 // Exercise 10 - Principles & Practice Using C++

Chapter 6 // Exercise 10


"Design a program that asks users for two numbers, and asks them whether they want to calculate permutations or combinations, and prints out the result. This will have several parts. Do an analysis of the above requirements. Write exactly what the program will have to do. Then, go into the design phase. Write pseudo code for the program and break it into sub-components. This program should have error-checking. Make sure that all erroneous inputs will generate good error messages."

OK, at first this sounds pretty daunting and there are some rather large(ish) equations given in the book however when you actually break down what he's asking, it becomes a pretty simple task.

We have already been given the formulas so it's just a matter of getting some numbers from the user and throwing them at some functions which solve the formulas, the pseudo code could look like this:

Ask user for two numbers
>numbers
Does user want combination or permutation?
>answer

If answer == Combination
       pass numbers to function and place into equation
       print combinations

If answer == Permutation
       pass numbers to function and place into equation
       print permutations

Pause & Quit

For some more information on combinations and permutations, check out this site. After reading this, it would appear that there are two ways to solve each problem but Bjarne only gives the formula to solve combinations without repetition. According to the site above, solving combinations with repetition requires a slightly different formula. So which one do we use?

For this exercise, I'm just going to stick to the formulas given.



#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <cctype>

#undef max //undefine max so it can be used in getInt

using namespace std;

double a;
double b;

//this function was taken from http://www.cplusplus.com/forum/beginner/21595/
//it makes sure that only numbers can be used
double getInt()
{
  double x = 0;

  while (!(cin >> x)) 
  {
    cin.clear();
    cin.ignore(numeric_limits<streamsize>::max(), '\n');
    cout << "You need to input a number: ";
 }

 return x;
}

//this gets two numbers and asks if the users wants permutations or combinations
//erroneous input is checked by getInt() and only allows P or C to be chosen
char permOrComb()
{
  cout << "Please enter the maximum amount of numbers: " << endl;
  a = getInt();
  cout << "Please enter how many numbers are needed: " << endl;
  b = getInt();

  cout << "\n\nWould you like to perform Permutation (p) or Combination (c)?: " << endl;
  char answer;
  cin >> answer;
  answer = toupper(answer); //converts letter to upper case

  while (answer != 'P' && answer != 'C')
  {
    cout << "You need to enter (p) or (c): ";
    cin >> answer;
    answer = toupper(answer);
  }

  return answer;
}

//this works out a factorial and returns the result
double getFactorial(double n)
{
  if (n == 0)
     n = 1;

  double factorial = n;

  for (double i = n - 1; i > 1; --i)
  {
    factorial = factorial*i;
  }

  return factorial;
}

//this solves permutations
double getPermutation()
{
  double p;
  double temp = a - b;

  //if a - b is a minus, flip it to positive
  if (temp < 0)
    temp *= -1;

  p = (getFactorial(a) / getFactorial(temp));

  return p;
}

//this solves combinations (where there is no repitition)
double getCombination()
{
  double c;
  double tempP = getPermutation();

  c = (tempP) / (getFactorial(b));
 
  return c; 
}

bool getQuit()
{
  char temp;
  bool qTemp = true;

  cout << "\n\nWould you like to quit (q) or continue (c): ";
  cin >> temp;
  temp = toupper(temp);

  while (temp != 'Q' && temp != 'C')
  {
    cout << "You need to enter (q) or (c): ";
    cin >> temp;
    temp = toupper(temp);
  }

  if (temp == 'Q')
    qTemp = false;
  if (temp == 'P')
    qTemp = true;

  return qTemp;
}


int main()
{
  bool quit = true;

  while (quit)
  {
    char answer = permOrComb();

    if (answer == 'P')
    {
      double temp = getPermutation();
      cout << "\nThere are " << temp << " permutations with these numbers.\n";
      quit = getQuit();
    }

   if (answer == 'C')
   {
     double temp = getCombination();
     cout << "\nThere are " << temp << " combinations with these numbers.\n";
     quit = getQuit();
   }

  }

  return 0;
}


I used the factorial function I created in Chapter 6 - Exercise 3 to solve for ! and then it was simply a case of checking for erroneous input. 

As I said above, this only solves combinations where there is no repetition, but it would be simple to create another function which solves for that using the formula given from the link above. Then just ask the user if repetition is allowed or not.

Monday, 26 December 2016

Chapter 6 // Exercise 9 - Principles & Practice Using C++

Chapter 6 // Exercise 9

Write a program that reads digits and composes them into integers. For example 123 is read as the characters 1, 2 and 3. The program should output "123 is 1 hundred and 2 tens and 3 ones". The number should be output as an int value. Handle numbers with one, two, three or four digits.

Hint: To get the integer value 5 from the character '5' subtract '0', that is '5'-'0'==5.


#include "stdafx.h"
#include <vector>
#include <string>
void pause();
void getNumbers();
void printNumbers();
using namespace std;
vector <int> digits;
char er = 'n'; //for error checking

int main()
{
 //get the numbers and convert them to an int from string
 getNumbers();

 //print the numbers out
 printNumbers();


 //ask for letter to quit the program
 pause();

 return 0;
}


void getNumbers()
{
 er = 'n';
 cout << "Please enter a number with up to 4 digits: ";
 string x;
 cin >> x; 

 //error checking
 for (int i = 0; i < x.size(); ++i)
 {
  for (char n = 'a'; n < 'z'; ++n)
  {
   while (x[i] == n)
   {
    er = 'y';
    cout << "That is not a number. Sorry.\n";
    return;
   }  
  }

  int num = x[i] - '0'; //converts letter to int
  digits.push_back(num); //pushes back into int vector
 }
}

void printNumbers()
{
 //continue to get input while er is equal to y
 while (er == 'y')
  getNumbers();

 for (int i = 0; i < digits.size(); ++i)
  cout << digits[i];

 cout << " is ";

 if (digits.size() == 4)
 {
  if (digits[0] == 1)
   cout << digits[0] << " thousand and ";
  else
   cout << digits[0] << " thousands and ";

  if (digits[1] == 1)
   cout << digits[1] << " hundred and ";
  else
   cout << digits[1] << " hundreds and ";

  if (digits[2] == 1)
   cout << digits[2] << " ten and ";
  else
   cout << digits[2] << " tens and ";

  cout << digits[3] << " ones.\n";
 }


 if (digits.size() == 3)
 {
  if (digits[0] == 1)
   cout << digits[0] << " hundred and ";
  else
   cout << digits[0] << " hundreds and ";

  if (digits[1] == 1)
   cout << digits[1] << " ten and ";
  else
   cout << digits[1] << " tens and ";

  cout << digits[2] << " ones.\n";
 }


 if (digits.size() == 2)
 {
  if (digits[0] == 1)
   cout << digits[0] << " ten and ";
  else
   cout << digits[0] << " tens and ";
  cout << digits[1] << " ones.\n";
 }

 if (digits.size() == 1)
 {
  cout << digits[0] << " ones.\n";
 }

}

void pause()
{
 cout << "\n\nPlease enter a letter: ";
 char key;
 cin >> key;
}


I'm sure there must be a much easier way to print the digits grammatically however I decided to just do this by brute force because this small program doesn't really take up any memory by doing it this way, nor does it slow it down. 

At first when I read this question I was like "what on earth does he want me to do now?" I didn't know if he wanted us to write into a char but then a char can't hold more than single character, so I thought about a vector of chars and pushing them back but that would require at least 5 different chars to push back. So I went with a string and I actually learnt something very useful today.

So string has similar functions as vector, I knew that I could get the size of it by using .size after the variable to return how many characters had been inputted. However on a whim I decided to see what would happen if I took away '0' from the character within the string, as suggested by Bjarne in the book. And it worked, it returned a number which I applied to a interger called num and then pushed that into a vector so printNumbers() had them all in one place.

Also, as a little extra this includes error checking. This doesn't allow any letters and will only allow numbers. I did this by comparing whatever the current character of x was to the alphabet using a for loop. For example, if the string x was equal to k then k would be compared to each letter of the alphabet and if it was equal to one then it returns to main and executes the next function. However the char 'er' has been set to 'y' so it will keep calling getNumbers() until er is equal to 'n'. It took me a while to get this error check working, so I'm pretty proud it does.

Sunday, 27 November 2016

Little Hiatus & Blog Update

This blog is currently on a small hiatus as I focus on university work. I am currently half way through chapter 7 but my assignments are top priority.

I just handed in my first which was Maths & Physics for game play which focused on parabolic trajectories and IK Chains and have a programming one and another maths due by Christmas. Whilst doing my assignments it has made me think about the future of this blog and would love eventually to put up tutorials on maths for games programming and c++ tutorials. 

As someone who has been programming for just under a year, I'd like to keep the topics on this blog simple, especially for beginner programmers. I've found that newbies asking questions in places like stackoverflow or cplusplus are met with patronizing answers from 'experts' whose answers are way too technical for their level of understanding. 

For example, someone had posted a question on an exercise from chapter 5 of P&P on stackoverflow (I was searching for an answer myself and I was stumped) and one user replied with "just use maps". Another user then had to point out that maps aren't introduced till a much later chapter (I'm currently still trying to wrap my head around classes). I guess what I'm trying to say is, I want this site to be a place where newcomers to C++ can learn the basics without the fear of experienced programmers thinking they're stupid. 
     We all learn at different paces and in different ways. I still use system("pause") every now and then despite what every single user on stackoverflow says. I only ever use windows and it works for what I want. Would I use it in a professional program? Of course not, but that doesn't mean I'm idiot for using it. You have to learn to walk before you can run. That's why Bjarne provides you with a header file with functions such as keep_window_open(). That function works in exactly the same way as system("pause") but for the first few chapters I had no idea how it worked, I only knew that it kept the console window open (as visual studio has a habit of closing the console window when the program has finished executing). Now I understand how it works and how to create a function which does the same thing. 

I am in no way an expert, I'm still learning, and have a lot to learn, but this blog was created because I could not find any help on Principles & Practice. There are a few blog posts and Bjarne himself has answered a few questions but there doesn't seem to be anyone who actually goes through their answers and how they got them. Therefore I hope that someone else finds this blog somewhat useful, if not I'm pretty proud of how far I've progressed so far. But enough rambling, thank you to those who are dropping by and if you have any questions I will try to answer as best I can.