7 Replies - 626 Views - Last Post: 09 September 2019 - 03:50 PM Rate Topic: *---- 1 Votes

#1 Thunderer   User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 119
  • Joined: 25-June 17

Creating a video game using windows.h windows api

Posted 05 September 2019 - 01:28 AM

How should I render images in windows API. Should I use setpixel. How to take input like mouse and keyboard. Please give some code. Currently my computer is broken. I am planning my game in notebook. Speed is necessary. I will be having an array of pixel and display it on the screen.

This post has been edited by Thunderer: 05 September 2019 - 04:12 AM

Is This A Good Question/Topic? 0
  • +

Replies To: Creating a video game using windows.h windows api

#2 Salem_c   User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 2380
  • View blog
  • Posts: 4,515
  • Joined: 30-May 10

Re: Creating a video game using windows.h windows api

Posted 05 September 2019 - 06:16 AM

> Speed is necessary.
Mmm, so you want to use an API that was never designed for games, to run on hardware that was never designed for games, and you want "speed is necessary".

Look at the kinds of games that come with Windows, like solitaire.
Not much moves, and not much moves very often or very fast.

Familiarise yourself with all the functions on offer, not just one.
https://docs.microso...n32/api/wingdi/

If you're wanting 60 frames a second full screen first person shooter, then you need DirectX or OpenGL/Vulkan and a beefed up GPU.
Was This Post Helpful? 1
  • +
  • -

#3 Thunderer   User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 119
  • Joined: 25-June 17

Re: Creating a video game using windows.h windows api

Posted 05 September 2019 - 08:47 AM

How to know how much time elapsed since the program started?
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15262
  • View blog
  • Posts: 61,187
  • Joined: 12-June 08

Re: Creating a video game using windows.h windows api

Posted 05 September 2019 - 08:54 AM

Curious side question - why Windows 32 API?
Was This Post Helpful? 0
  • +
  • -

#5 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7056
  • View blog
  • Posts: 23,989
  • Joined: 05-May 12

Re: Creating a video game using windows.h windows api

Posted 05 September 2019 - 06:58 PM

View PostThunderer, on 05 September 2019 - 11:47 AM, said:

How to know how much time elapsed since the program started?

Most Windows programs just depend to GetTickCount(). They may note of what the current tick count is when the program starts, and then compute the delta from there. Others just get the current machine time and compute the delta. There are high resolution performance counters if you need more precision. There are also other API that let you query Windows process state to determine how much CPU time has been used by a process.
Was This Post Helpful? 2
  • +
  • -

#6 Thunderer   User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 119
  • Joined: 25-June 17

Re: Creating a video game using windows.h windows api

Posted 05 September 2019 - 08:26 PM

What is the use of graphic card, what calculation does it do and how does it make the game faster? How to play sound in windows API?

This post has been edited by Thunderer: 05 September 2019 - 11:04 PM

Was This Post Helpful? 0
  • +
  • -

#7 Radius Nightly   User is offline

  • D.I.C Regular

Reputation: 39
  • View blog
  • Posts: 321
  • Joined: 07-May 15

Re: Creating a video game using windows.h windows api

Posted 06 September 2019 - 10:50 AM

With that idea, you can make games, but 2D, and since most of the things has to be calculated by CPU, dont expect some miracle, GPU probably wont be used at all, and you will still be able to make fine games (but over time it may become too complex), specialy for time counts, because there are multiple variants of how computer can calculate time, and none of them are actually perfect. So if you wanna make games, use the right tool for the right job.
Was This Post Helpful? 0
  • +
  • -

#8 NicVene   User is offline

  • New D.I.C Head

Reputation: 9
  • View blog
  • Posts: 9
  • Joined: 28-May 19

Re: Creating a video game using windows.h windows api

Posted 09 September 2019 - 03:50 PM

View PostThunderer, on 05 September 2019 - 08:26 PM, said:

What is the use of graphic card, what calculation does it do and how does it make the game faster?


This is a substantial topic, but I'll try to be to the point.

A modern GPU process both 3D model data and 2D image data very rapidly using specialized hardware. Even in 2D gaming, the same features in the GPU present rapid frame display using specialized techniques.

A great deal depends on the artwork itself, so relative performance is impossible to state clearly, but typically one might witness barely 1 frame per second if the CPU performs all of the work, where that same graphic material and quality may be rendered by the GPU well over 60 frames per second. Depending on the GPU in question, that could go as far as several hundred frames per second.

There are typical operations performed in gaming. For 3D models this involves linear algebra, which mathematically models a 'camera' (or player's eye view) of a scene. These operations are particularly taxing on CPU resources, where the GPU is designed specifically for that math.

Where typical CPU's may have 4 to 16 cores, GPU's may offer hundreds or thousands working in parallel. This is the primary means by which they generate high performance.

The CPU itself, however, has certain beneficial traits which suit it for generalized software. The GPU is particularly bad at branching, which is to say it's bad at making simple decisions they way a general CPU does. The GPU is tuned to work on lists of tens of thousands of points (usually 3D points, but could be 2D points) without stopping - which is typically how graphics data is processed.

There is a second phase in the GPU (one might say several, but at least 2). Once the 3D models have been transformed according to the camera view, they must be textured. This process is programmable in modern GPU's, and is responsible for a number of special effects. The basic idea is to take the image of a texture, like a brick wall, and paint that onto a shape (like a rectangular solid) to make that shape look like a brick wall. Obviously, there are multiple textures and therefore multiple sources, but this process is basically operated pixel by pixel. Doing that in the CPU would be very slow. The GPU has specialized processing units built just for this phase of the process, and includes programmable processors (called shaders) to perform the work in highly parallel fashion.

The result is many orders of magnitude in performance.

The GPU can also be tasked with computation of high volume that never displays anything, often used for physics, special effects or other applications like video processing, encryption/decryption and artificial intelligence.

GPU's don't just make games faster, they can make nearly all large volume calculations faster.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1