• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
dustydoodoo

SDL main?

21 posts in this topic

I was just wondering what the arguments in the SDL main mean?, i dont ussually like using stuff i dont understand, and the main looks like this int main(int argc, char *argv[]) I know its a small thing but i would just like to know :)
0

Share this post


Link to post
Share on other sites
its just standart entry point for console program, you can find description of it in the MSDN, argc - number of input command line arguments, arv - arguments themselves
0

Share this post


Link to post
Share on other sites
just check MSDN. i thought argument and parameter are synonyms. entry point is the part of the program from which it starts. console program .. well dunno how do describe it.. its just console program
0

Share this post


Link to post
Share on other sites
Man will this ever stop!!? Whats a synonym!?, i looked it up on google, but i couldnt find anything! oh wait never mind, it a word with the same or near the same meaning of the another.
0

Share this post


Link to post
Share on other sites
K, i got one more question, why does a SDL program need this in the main function? And why would these parameters be usefull? could someone tell me in simple words? lol, i dont have a very good vocabulary.
0

Share this post


Link to post
Share on other sites
its not SDL. Every Windows program should have either WinMain or main functions which are entry points for executables.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by X3
its not SDL. Every Windows program should have either WinMain or main functions which are entry points for executables.


Actually it kind of is SDL. The way SDL works is with you declaring your own main() function which it then uses #defines to overwrite with its own so it can initialise your application correctly. Because of the fickleness of #define you have to use the correct declaration otherwise it won't work. You can't for instance have int main() or void main() you need the full declaration int main(int argc, char **argv)

As for dustydoodoo ... how long have you been programming? I suggest you go look up some c/c++ tutorials on google befor launching into SDL if you've never seen main() befor.
0

Share this post


Link to post
Share on other sites
LOL! i have seen main() but ive never seen "int argc, char *argv[]" in the main functions arguments.
0

Share this post


Link to post
Share on other sites
Ok well for a console application (an app which has no gui - just uses text output) main accepts those arguments. its basically just a list of everything passed in on the command line.

So if you run your program like this:

myapp.exe -p something.txt

you'll have "myapp.exe" "-p" and "something.txt" as your command line arguments. argc says how many there are (in this case its 3), and argv is the char arrays of each string. This is the full and proper declaration of main - and IMHO should always be used.

As for the entry point: its the part of your program that starts running first - so when you run your program it'll start at the beginning of main.
0

Share this post


Link to post
Share on other sites
They are command line arguments used when you run the actual program, just like kaysik said. Here's a small demo I put together to test them:

#include <iostream>

int main ( int argc, char *argv[] )
{
// Check if there is only one program argument
if(argc == 2){ // 2 because 1 is the program name
// Display the output
std::cout << "Argument: " << argv[1] << std::endl;
std::cin.get();
} else {
// Display an error using the program name
std::cout<<"Usage: "<< argv[0] <<" <output>\n";
std::cin.get();
}
}
0

Share this post


Link to post
Share on other sites
hey thanks for all the info, but the one thing i dont get is why would you need this? esspetially(dont know how to spell) when you dont use the command line? because this isnt in one of those dos windows.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by dustydoodoo
hey thanks for all the info, but the one thing i dont get is why would you need this? esspetially(dont know how to spell) when you dont use the command line? because this isnt in one of those dos windows.


You might not be using it, but trust me when I say lots of other people do. Part of a good game design is to use some sort of Data Driven design. What that means is rathet than hard code in all your runtime settings, such as the width, height, etc.. you just load it from a file. However, in itself, that would still require hard coding in a filename to load. To get around that, you could juse let the user call your program with a parameter that contains the file to load, which would make it nearly all data driven!
0

Share this post


Link to post
Share on other sites
Quote:
Original post by dustydoodoo
so a simple SDL program for just creating a coloured window probably doesnt use it?


Not unless you make it [smile]
0

Share this post


Link to post
Share on other sites
it also alow u to drop flies in like for editors and compliers
it very powerful not just for dos programs it so important to programmers that
microsoft went ahead and add it to there main()(aka-WinMain(...))
in the WinMain(...) it should be the last field
0

Share this post


Link to post
Share on other sites
Please learn to use a dictionary instead of asking what every single word means.

As for command-line arguments: you may find them useful for avoiding hard-coding the names of resource files into your app. For example, if you have some SDL demo app and it draws a picture "foo.png", then instead of having that name in your program, you could set up the main() to read the file name as argv[1].

(By the way, the names of those parameters are not special; you can call them what you like, just like for any other function - what's important are the types: int and char*[]. The names 'argc' and 'argv' are just traditional, and meant to give you the warm fuzzy feeling that comes from following in the footsteps of 80s-era C hackers.)

Then, you could have people run your program from the command line, or spiffier yet, create a batch file, like:


rem this is file 'mydemo.bat'
rem on the next line, we put the command line that gets fed to DOS
@mydemo.exe foo.png
rem the '@' tells the terminal window not to echo the command line.
rem 'mydemo.exe' should of course be replaced with the name of your program
rem and 'foo.png' with the filename for the picture to display.


Then when your code runs, it passes argv[1] to the code that opens the file, and voila. Now, if you decide to change the name of the file, you don't have to go hunting down the hard-coded name in your source, but just fix it in the batch file - and you also don't have to recompile, and you also offer users the option to use their own pictures instead.

Of course, this is all Windows-specific with the .bat file stuff, but there are equivalents on other platforms.
0

Share this post


Link to post
Share on other sites
Thanks even more! and im sorry about asking all the meanings of all the words! my auntie always gets mad at me for asking so many questions, lol
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0