Quantcast

Jump to content

» «
Photo

Random Programming Questions

22 replies to this topic
Liamardo
  • Liamardo

    Player Hater

  • Members
  • Joined: 25 Nov 2011

#1

Posted 25 November 2011 - 04:32 PM

Hey people.

So basically I have been modding for a while now but only at a basic level.
Ive used Img Tool, SAMI, TXD workshop, GGMM, Ped Editor and Obviously Cleo.
Ive designed vehicles, peds, buildings, etc. (3ds Max, Photoshop & Flash)

But I feel this is becoming small fry for me.
I've started looking into C++ and Direct x programming and finding it all a little overpowering.
The eventuality is that I want to be able to write my own codes and build my own games.

So this is kinda a request really, could anybody help me out with the basics of code writing?
and general advise?

I do realise there are plenty of resources out there to help me on my way but I would like the opportunity to
liaise with some one on the matter, say if I run into any problems or have questions I cant find answers to.

Cheers for now!

Liamardo.

Barguast
  • Barguast

    Thy next foe is...

  • Andolini Mafia Family
  • Joined: 27 Jul 2002

#2

Posted 25 November 2011 - 05:07 PM

QUOTE (Liamardo @ Friday, Nov 25 2011, 17:32)
I've started looking into C++ and Direct x programming and finding it all a little overpowering.

I'm not surprised, you're jumping in the deep end!

If you're just starting out with C++, you're best off writing some small programs to teach yourself the basics of the language. I mean text-based console applications that perform very basic tasks like adding numbers. You'll probably find this a lot more rewarding than it sounds, and you'll inevitably end up creating more and more complex programs and indirectly learning good habits.

Once you've nailed the basics of programming, the big bad scary world of DirectX will seem a little less daunting and a little more accessible, but again, you'll need to start with the basics. Your first Direct3D application will probably be a tricoloured gouraud triangle - but you'll look at it thinking that you're GOD. tounge.gif

In summary, take it slow, start from the beginning, and have patience.




Swoorup
  • Swoorup

    Foot Soldier

  • Feroci
  • Joined: 28 Oct 2008
  • Nepal

#3

Posted 25 November 2011 - 05:37 PM Edited by Swoorup, 25 November 2011 - 05:40 PM.

I started out with C a month ago, should I go with C++ at the same time?
I looked at making a window-based app from C++ and really its too complex process going on! What I meant to say is, how long will an average programmer be fluent in these languages?

EDIT:Liamardo, I would suggest you take a look at cprogramming.com site. They contain the basic stuffs of C/C++ and explain very well.
Also you have any problems then there is always the forum. icon14.gif

Liamardo
  • Liamardo

    Player Hater

  • Members
  • Joined: 25 Nov 2011

#4

Posted 25 November 2011 - 05:54 PM

QUOTE (Barguast @ Friday, Nov 25 2011, 17:07)
If you're just starting out with C++, you're best off writing some small programs to teach yourself the basics of the language. I mean text-based console applications that perform very basic tasks like adding numbers. You'll probably find this a lot more rewarding than it sounds, and you'll inevitably end up creating more and more complex programs and indirectly learning good habits.



Cheers for the info dude!
I'm assuming your already adept at using c++.

so far Ive covered the basics but in the stuff I've read, it doesn't really explain too well how to create codes, if that makes sense. basically I understand how to make codes work and what processes have to happen before a basic application can work but what I don't get is, How do I know what codes to use... is there a list of data I should learn? for example Data works in binary witch is basically 1's & 0's witch is the computers native language (so to speak) but there is the other language witch is in text.... so does this mean for a specific number sequence there is a preset text equivalent? or is that over simplified? lol!




K^2
  • K^2

    Vidi Vici Veni

  • Moderator
  • Joined: 14 Apr 2004
  • United-States
  • Best Poster [Programming] 2015
    Most Knowledgeable [Web Development/Programming] 2013
    Most Knowledgeable [GTA Series] 2011
    Best Debater 2010

#5

Posted 25 November 2011 - 07:30 PM

QUOTE (Swoorup @ Friday, Nov 25 2011, 13:37)
I started out with C a month ago, should I go with C++ at the same time?

You should keep learning C until you get hang of structures, linked lists, and trees. That's a good point to switch over to C++.
  • lpgunit likes this

Swoorup
  • Swoorup

    Foot Soldier

  • Feroci
  • Joined: 28 Oct 2008
  • Nepal

#6

Posted 26 November 2011 - 04:16 PM

I am learning from the site you told me, but with slower pace, applying each and every chapters into practical by just programming some useful things.
But how can I apply those linked lists and binary trees in practical. I mean for which problems.

Thank you though for all the information!

K^2
  • K^2

    Vidi Vici Veni

  • Moderator
  • Joined: 14 Apr 2004
  • United-States
  • Best Poster [Programming] 2015
    Most Knowledgeable [Web Development/Programming] 2013
    Most Knowledgeable [GTA Series] 2011
    Best Debater 2010

#7

Posted 26 November 2011 - 11:16 PM

Any time you want to have an "array" of objects, where you might want to take out or add an element, especially somewhere in the middle of the "array", linked lists might be a good solution. Their only downside is that they aren't easy to search. If you need the Nth element, you have to start with the first, jump to second, then to third... But sometimes, you only need the array to be processed in that order, and then there is simply no better option.

Lists can also save you a ton of time on memory allocation. Imagine that you have a bunch of objects that you keep creating and destroying. If you had to allocate memory every time and the delocate it, it can become rather slow, not to mention fragmentation issues. Instead, create a linked list of unused objects. Since they don't have to be ordered in memory, you can take and add objects to that list as you please. Just make sure you check its length every once in a while, and delocate unused objects if you ended up with too many. If the list is empty, and you need more, you allocate memory then.


And trees... It's a broad topic. There are search trees. Just about any AI will involve a search in a tree. Directory structure is a tree, so if you want to represent one in your program you'll have to have a tree of some sort. For rendering and graphics, there are partition trees. In particular, there is binary space partition (BSP - might sound familiar) and there are octrees. Octrees are used for everything from graphics, to physics, to AI for all kinds of neat optimization tricks. BSPs are absolutely brilliant for rendering. If you're going through NeHe tutorials, they do have one on BSPs later on. But basically, whenever you get to transparency, do realize that order in which you render things is important. BSP makes ordered transparency an absolute breeze, but there are some limitations.

So yeah, lists and trees are extremely important in programming. And you will cuss and want to throw things while learning them, because when writing pointer-chasers, the fact that your program compiled means absolutely nothing, and trying to find an error in a program that compiles and just crashes can be a pain.

SagaciousKJB
  • SagaciousKJB

    Captain tl;dr

  • The Connection
  • Joined: 21 Jun 2003
  • None

#8

Posted 05 December 2011 - 09:27 PM

I hate lists and trees, mostly because I can never find a good way to actually practice using them, so always find myself going back to reference manuals when trying to do something with them, never really getting a complete understanding since I seldom use them.

Swoorup
  • Swoorup

    Foot Soldier

  • Feroci
  • Joined: 28 Oct 2008
  • Nepal

#9

Posted 07 December 2011 - 03:34 PM

I have not seriously gotten into game programming now, because I am just covering some windows programming with C++. And honestly, I feel kind off empty doing linked list and trees now.

bartoc
  • bartoc

    Player Hater

  • Members
  • Joined: 15 Jun 2016
  • United-States

#10

Posted 17 June 2016 - 06:53 PM

Linked lists are nice to know, but I don't find myself using them that often, just because for most applications a flexible length array or some kind of good deque implementation (usually a linked list of little arrays actually) work better. Linked lists are CRITICAL structures though because they are how the memory allocator that enables all the nice things like flexible length arrays, hash tables, and easy to use strings possible actually works. To be honest once you understand graphs and trees you will probably understand how linked lists work pretty much intuitively.


Mr.Arrow
  • Mr.Arrow

    God Save the Penis

  • Members
  • Joined: 08 Nov 2011
  • United-Kingdom

#11

Posted A week ago

Is assembly language worth learning for a programmer like me? Me and my group of friends are planning to write an operating system once I'll finish my degree in the next 4 years.

trip
  • trip

    ~

  • Andolini Mafia Family
  • Joined: 10 Oct 2007
  • United-States
  • Contribution Award [GTAF]
    Contribution Award [Gen Chat]

#12

Posted A week ago

Is assembly language worth learning for a programmer like me? Me and my group of friends are planning to write an operating system once I'll finish my degree in the next 4 years.

Sure. Back in school we actually had to produce a simple OS in assembly. And I do mean simple.

Call -151 :)
  • lpgunit, Mr.Arrow and Sweet Bellic like this

K^2
  • K^2

    Vidi Vici Veni

  • Moderator
  • Joined: 14 Apr 2004
  • United-States
  • Best Poster [Programming] 2015
    Most Knowledgeable [Web Development/Programming] 2013
    Most Knowledgeable [GTA Series] 2011
    Best Debater 2010

#13

Posted A week ago

Is assembly language worth learning for a programmer like me? Me and my group of friends are planning to write an operating system once I'll finish my degree in the next 4 years.

Knowing Assembly will make you a better programmer, period. If you are going to attempt writing an OS, it is absolutely vital to know.
  • lpgunit, Mr.Arrow and Sweet Bellic like this

lpgunit
  • lpgunit

    It's L, as in Lpgunit, not I.

  • Feroci
  • Joined: 24 May 2008
  • Philippines

#14

Posted 6 days ago

Is assembly language worth learning for a programmer like me? Me and my group of friends are planning to write an operating system once I'll finish my degree in the next 4 years.

Knowing Assembly will make you a better programmer, period. If you are going to attempt writing an OS, it is absolutely vital to know.

Well since that'll certainly give you access to the bare metal. 'Tis a pain to master though, and I heard that part of the reason why the Sega Saturn failed was that programmers were forced to write things in assembly for them to get better performance in games.

K^2
  • K^2

    Vidi Vici Veni

  • Moderator
  • Joined: 14 Apr 2004
  • United-States
  • Best Poster [Programming] 2015
    Most Knowledgeable [Web Development/Programming] 2013
    Most Knowledgeable [GTA Series] 2011
    Best Debater 2010

#15

Posted 6 days ago

Seems dubious. Writing assembly code for optimized performance was a still a common thing back then. A lot of DOS games would have bits of assembly code for graphics and audio performance. It's only with emergence of protected mode and operating systems using it that APIs became the only way of dealing with environment, and so the assembly use began to wane.

On the other hand, Saturn did have a weird architecture. It's possible that programming it in assembly was just that much harder than other systems.
  • lpgunit likes this

lpgunit
  • lpgunit

    It's L, as in Lpgunit, not I.

  • Feroci
  • Joined: 24 May 2008
  • Philippines

#16

Posted 6 days ago

Seems dubious. Writing assembly code for optimized performance was a still a common thing back then. A lot of DOS games would have bits of assembly code for graphics and audio performance. It's only with emergence of protected mode and operating systems using it that APIs became the only way of dealing with environment, and so the assembly use began to wane.

On the other hand, Saturn did have a weird architecture. It's possible that programming it in assembly was just that much harder than other systems.

They didn't come up with the likes of DirectX or OpenGL for nothing. Most held on to DOS simply because you have bare metal access to things, unlike with Windows where layers upon layers of abstraction add up to a programmer's woes. Chris Pirih, the programmer behind SkiFree, recalled as to how hard it was to get reasonable performance off an average 386 with an ISA video card. GDI wasn't exactly oriented for animation-intensive stuff like games, hence why Microsoft initially came up with WinG. But along with it came The Lion King and the PR disaster Disney, Microsoft and Compaq got, though it was more on part of Compaq's video card supplier who didn't thoroughly test their drivers.

Yeah the Saturn was an oddball in most respects. Adding a second CPU was a knee-jerk reaction (much like Sony's choice of using the Cell in the PS3), along with quad-based geometry. They got a fan in the name of Nvidia who implemented a similar quads-based scheme with the NV1, which led to a number of games ported to said graphics chip, but alas, both the NV1 and the Saturn didn't bode well.

K^2
  • K^2

    Vidi Vici Veni

  • Moderator
  • Joined: 14 Apr 2004
  • United-States
  • Best Poster [Programming] 2015
    Most Knowledgeable [Web Development/Programming] 2013
    Most Knowledgeable [GTA Series] 2011
    Best Debater 2010

#17

Posted 6 days ago

You can do direct-to-buffer writes with Windows just like you did with DOS and skip nearly all the GDI nonsense. For a good implementation see Quake II, which had both OpenGL for hardware rendering and completely custom software renderer that ran on machines without 3D acceleration. You didn't have any dynamic lighting in software, but it still looked rather impressive for its time. Although, one should keep in mind that it was created by people who weren't afraid to use techniques like Fast Inverse Square Root.

But yeah, it pales in comparison to what people pulled on DOS titles, where you could hijack the interrupt table.

If either of you feel like taking on a small assembly challenge, a really good one is writing your own SoundBlaster driver. It will only take a few functions in assembly, and you can write a C/C++ program that plays .wav files around it. Naturally, I strongly recommend using DOSBox rather than an actual DOS machine, and you can use DJGPP to compile an MS-DOS compatible binary. See my signature for hints. :p
  • lpgunit likes this

Mr.Arrow
  • Mr.Arrow

    God Save the Penis

  • Members
  • Joined: 08 Nov 2011
  • United-Kingdom

#18

Posted 6 days ago Edited by Mr.Arrow, 6 days ago.

^  I really like that source code for Fast inverse square root , the comments in particular :lol:
 
Spoiler

lpgunit
  • lpgunit

    It's L, as in Lpgunit, not I.

  • Feroci
  • Joined: 24 May 2008
  • Philippines

#19

Posted 6 days ago

You can do direct-to-buffer writes with Windows just like you did with DOS and skip nearly all the GDI nonsense. For a good implementation see Quake II, which had both OpenGL for hardware rendering and completely custom software renderer that ran on machines without 3D acceleration. You didn't have any dynamic lighting in software, but it still looked rather impressive for its time. Although, one should keep in mind that it was created by people who weren't afraid to use techniques like Fast Inverse Square Root.

But yeah, it pales in comparison to what people pulled on DOS titles, where you could hijack the interrupt table.

If either of you feel like taking on a small assembly challenge, a really good one is writing your own SoundBlaster driver. It will only take a few functions in assembly, and you can write a C/C++ program that plays .wav files around it. Naturally, I strongly recommend using DOSBox rather than an actual DOS machine, and you can use DJGPP to compile an MS-DOS compatible binary. See my signature for hints. :p

Besides being that game programmers back then were loyal DOS fanboys, and wouldn't easily give up their system of choice.

Shmoopy
  • Shmoopy

    Thug (͡ ͜ʖ ͡)

  • Members
  • Joined: 16 Jun 2009
  • None

#20

Posted 3 days ago

Making games with plain C++ and Directx is so 2006, you'll just gonna waste your time, you better start using tools that target all platforms (mobile-console-desktop), Choose between : Unity 5 and Construct 2, I recommend the latter ( HTML5 and WebGL ). 


K^2
  • K^2

    Vidi Vici Veni

  • Moderator
  • Joined: 14 Apr 2004
  • United-States
  • Best Poster [Programming] 2015
    Most Knowledgeable [Web Development/Programming] 2013
    Most Knowledgeable [GTA Series] 2011
    Best Debater 2010

#21

Posted A day ago

Depends on what you are making and why. There are a lot of legitimate reasons to write a custom rendering engine. You just have to realize that it's a huge time investment. If you are the only programmer on the team, or worse, the only person, it's probably an unwise use of time. But if you're working with a team of 5-10 people, then it's a matter of priorities. Do you want to have 2-3 people spend development time just writing rendering engine, or do you want them working on other systems?

As for platform compatibility, you can target PC and XBOne with almost identical code, and PS4 can run on the same core rendering code with a wrapper around its native graphics calls. So if you are making a "serious game", which you don't expect to run on the web anyways, the benefits of using stock engine for cross-compatibility are greatly diminished. I'm telling you this as someone who has actually developed PC/XBOne/PS4 games on a completely custom engine. Our graphics team consisted of 3 people.
  • lpgunit likes this

lpgunit
  • lpgunit

    It's L, as in Lpgunit, not I.

  • Feroci
  • Joined: 24 May 2008
  • Philippines

#22

Posted A day ago

Depends on what you are making and why. There are a lot of legitimate reasons to write a custom rendering engine. You just have to realize that it's a huge time investment. If you are the only programmer on the team, or worse, the only person, it's probably an unwise use of time. But if you're working with a team of 5-10 people, then it's a matter of priorities. Do you want to have 2-3 people spend development time just writing rendering engine, or do you want them working on other systems?

As for platform compatibility, you can target PC and XBOne with almost identical code, and PS4 can run on the same core rendering code with a wrapper around its native graphics calls. So if you are making a "serious game", which you don't expect to run on the web anyways, the benefits of using stock engine for cross-compatibility are greatly diminished. I'm telling you this as someone who has actually developed PC/XBOne/PS4 games on a completely custom engine. Our graphics team consisted of 3 people.

That accounts for why Unreal Engine is so popular, as it's been on over 9000 games from M-rated FPSes to even children's games. Heh, it has also been used on LazyTown as well as a CGI platform of choice for their virtual sets.

And besides, some developers choose to do a bespoke renderer either as an exercise/hobby or since an off-the-shelf framework is out of the question due to specific demands.

On the subject of doing a wrapper for the PS4, wouldn't that add up to the overhead like Wine's Direct3D-to-OpenGL implementation did, or is it possible to mitigate such issues?

K^2
  • K^2

    Vidi Vici Veni

  • Moderator
  • Joined: 14 Apr 2004
  • United-States
  • Best Poster [Programming] 2015
    Most Knowledgeable [Web Development/Programming] 2013
    Most Knowledgeable [GTA Series] 2011
    Best Debater 2010

#23

Posted 18 hours ago

You lose time on actual translation with WinE, which you have to do if all you have is a compiled binary. If you are working from source code, you don't need to do that. As a toy example, imagine that you want to render a mesh. Hardware dictates that you need to have a vertex buffer and index buffer then make a draw call. (I'm ignoring shader for the moment.) Specific ways that is implemented will be different in different graphics libraries, but all of them have to go through these steps. So you write a function, say, RenderMesh(const BaseMesh& mesh). You will write a DirectX version of that function for Windows/XBox and GNM/GNMX version for PS4. (Or OpenGL, Vulkan...) You might also derive DirectXMesh and PS4Mesh from BaseMesh to have additional information available for each version, but BaseMesh would have interface your rendering engine can use regardless of platform. Now your rendering engine just needs to call RenderMesh and not worry about which platform it's running on. So the hard part of the rendering system, which is sorting meshes, doing culling, maintaining draw list, handling LODs, and so on, remains platform-independent. And only the wrappers around low level stuff have to be written for each platform.

This still involves doing some extra work. But it's nowhere near the same amount of work as writing a rendering engine from scratch. So if the later doesn't scare you, former certainly shouldn't.
  • lpgunit likes this




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users