Handmade Hero»Forums»Code
Joakim
3 posts
Introduction of a Swede!
Hi guys!

My name is Joakim and I live in Sweden. Im quite old, 38 years. I have started the path to learn how to program C, I have just a little bit knowledge of programming from my teen years back on amiga, 286, 386 and kinda stopped due to life events. I did not get very far in my programming skills so consider me as a novice in this field.

I did go through the basics of Assembly, C and Qbasic. Wrote some smaller programs in ASM, opened mode13h, put some pixels and stuff like that. With Qbasic I did a couple of rouge games and with C i did not get very far.

I spent most of my time with Trackers and Acid draw, making music and ansi art. I released a couple of packs on the ansi scene.


Ok so I have gone through the intro to C and the first week, how to open a windows window. It all seems a little bit to complicated to start out with, as a beginner, so I'm trying to find information of header files and there functions. What I want to be able to do now is to put pixels on the screen, making a line function, triangle and so on to get more familiar with C and coding in general.

For example:
I would like to find the function "putpixel" on screen, where can i find all these functions and see in which header file they are?
I remember in Borland c/c++ in MS-DOS it was quite easy, just open the help file and all information was there.

Best regards
Joakim "freqit"
Mārtiņš Možeiko
2562 posts / 2 projects
Introduction of a Swede!
Edited by Mārtiņš Možeiko on
Have you seen up to day 4 and 5? In these days Casey is changing pixels and putting them on window.

The approach he takes is one where he allocated memory for holding bitmap, changes values that represents pixels. And then blits whole memory to screen. This is one of the faster ways how to put pixels on window.

Another option for drawing in Windows is to use GDI functions. They provide drawing pixels, lines, etc.. each with its own function. Drawing will happen into internal buffer, so no blitting required. This will be a bit slower way because of function call overhead. There's also GDI+ API with a bit more advanced functionality, and more features like antialised primitives.

Unfortunately creating window and managing it in Windows will require some boilerplate code which you cannot really avoid (unless you use somebodies library which will do that for you). The good news is that once you do it, you can forget about it and just focus on your pixels.

As for libraries that will do all the window setup for you and allow plot pixels in software to screen out [url=https://github.com/emoon/minifb
]MiniFB[/url] or PixelToaster. They both will have similar code as in Handmade Hero from day 4/5. Well PixelToaster is a bit more advanced with float pixel format (possible by using d3d9).
Joakim
3 posts
Introduction of a Swede!
mmozeiko
Have you seen up to day 4 and 5? In these days Casey is changing pixels and putting them on window.

The approach he takes is one where he allocated memory for holding bitmap, changes values that represents pixels. And then blits whole memory to screen. This is one of the faster ways how to put pixels on window.


Yes i watched it, I guess I need to rewatch them as I did not quite get that apparently. I might have missed something there where he explained how it works with the bitmap, really don't recall about that. Perhaps I missed that part, I will go back and rewatch from day3-5 again and rewrite the code along Casey.

I took a look at the other libs you suggested, thoose seems even more complicated than Casey's version, tho I might take a look at thoose later.

Worth to mention is that I have preordered the game and downloaded all the files. I have setup my enviroment exactly the same as Casey on Windows10.

Could you point me to some articles or other information that explains the concept of blits and frame buffers that are related to game and graphic development? (demoscene perhaps?)

Thank you for your answers and time!
Best Regards
Freqit
Mārtiņš Možeiko
2562 posts / 2 projects
Introduction of a Swede!
Edited by Mārtiņš Možeiko on
I really think that this is not very complicated: https://github.com/emoon/minifb/blob/master/tests/noise.c
It opens window on line 13, draws pixels in a loop on line 30, and blits it to screen on line 33. Line 39 closes window.

Even the implementation is super simple: https://github.com/emoon/minifb/blob/master/src/windows/WinMiniFB.c

I suggest you to study source of minifb and watch Casey's videos. He explains all the basics about how to blit to window. If you have specific questions about some parts of video, just ask - we'll try to answer and explain in more details.
Joakim
3 posts
Introduction of a Swede!
mmozeiko
I really think that this is not very complicated: https://github.com/emoon/minifb/blob/master/tests/noise.c
It opens window on line 13, draws pixels in a loop on line 30, and blits it to screen on line 33. Line 39 closes window.


This actually is good, it lets me focus on the pixels and not worry so much about the rest. A more newbie friendly start i would say. Thank you for that.

Anyways I'm going through the videos again and apparently I had missed a bit on DAY 3, it's a bit clearer now for me.

I will probally have some more questions later :)