Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 133 134 [135] 136 137 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 907001 times)

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2010 on: March 20, 2012, 10:34:23 pm »

Quote
audio-only bullet hell
D8
You insane bastard.
Spoiler (click to show/hide)
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2011 on: March 20, 2012, 11:49:29 pm »

Hrm... So it looks like the keyword I'm looking for is "HRTF" Head Related Transfer Function. Essentially, it models how sound gets distorted due to that thing in between the ears, allowing you to get the really good 3D sound. Unfortunately, I seem to be having a rather hard time finding a free/open source library that will do it for me.
Logged

DJ

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2012 on: March 21, 2012, 01:46:50 pm »

So I'm trying to figure out how to make my own DLLs and it's not going so well.

I've got a class called Sprite defined in a header in a DLL project. I have wrote the default constructor as Sprite(); in the h file and Sprite::Sprite() { animation = NULL; } in the cpp file.

I make a new solution called Pong in which I've imported the whole Sprite thing following instructions I found on the net. I can declare an instance of Sprite just fine, but when I try Sprite *test = new Sprite(); it tells me that no proper default constructor is available. What gives? Is there some kind of a checklist I can go through to verify I've set up all the linker options properly?
Logged
Urist, President has immigrated to your fortress!
Urist, President mandates the Dwarven Bill of Rights.

Cue magma.
Ah, the Magma Carta...

MadocComadrin

  • Bay Watcher
  • A mysterious laboratory goblin!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2013 on: March 21, 2012, 02:21:42 pm »

Would someone be willing to go over creating libraries in general for C++: Shared and Static, the do's and don'ts, etc?
Logged

malloc

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2014 on: March 21, 2012, 02:45:39 pm »

@DJ & MadocComadrin
http://msdn.microsoft.com/en-us/library/ms235636(v=vs.80).aspx
Dlls add quite a bit of complexity to the workflow, as you are going to write some boilerplate code to make it work. The advantage is that you can, if done correctly, split the program up in very nice and manageable modular chunks.
As far as I understand, dlls are actually by default executed in another thread too, but it won't give you any significant performance boost. (Someone please correct me if I am wrong on this bit.)

As for do's and do not's, I don't actually know if there are any. They work pretty much the same way as any other code, so I guess same rules apply. DLL's can be shared between multiple programs, and act like a mix between a standalone program and a library, libraries are statically linked and compiled into the program.

Sorry if I am a bit vague about the actual creation of DLLs and Libraries. The MSDN page explains it pretty well, and there is not real shortcut way of doing it.
Logged

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2015 on: March 21, 2012, 03:47:01 pm »

Quote
As far as I understand, dlls are actually by default executed in another thread too, but it won't give you any significant performance boost. (Someone please correct me if I am wrong on this bit.)

This may be different on some operating systems, but it was my impression that the DLL code was either copied into the process's address space or copied to a single location in memory, where the code would jump to it out of the original process when needed.  It would jump back when done.

This is why there are issues with reentrancy and thread safety with DLLs: if the DLL code stores internal state and gets linked to two processes that do stuff, bad things can happen.

Of course, I could be completely off here since I've never even written a DLL.  I just studied OS theory a bit without much practical application of it.
Logged
Through pain, I find wisdom.

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2016 on: March 21, 2012, 05:13:50 pm »

This thread is temporarily also the happy thread for this post:

I went to a UIL (state-wide league for academics and sports) academic competition yesterday, where I competed in Computer Science. It was the first of the three levels of "serious" competition, District (a group of 9-ish schools), Regionals (a group of 9-ish districts), and State (all the schools in the state). The results:

My written test score (1st): 192
2nd place score: 150
(Scoring: +6 for correct answers, -2 for incorrect answers, no points gained or lost for skipped questions. 40 questions total.)

My school's team programming score (1st): 410
2nd place score: 60
(Scoring: +60 for correct programs, -10 for each incorrect submission on programs that are eventually submitted correctly, no points gained or lost on programs that are never submitted correctly. 12 programs total.)

My school's overall score (1st): Just under 700
2nd place score: Just over 300

All in all, it was a good day. Regionals are next, on April 20th.

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2017 on: March 21, 2012, 05:50:31 pm »

This post would be shorter if I'd found an emoticon for *picks up jaw from floor*.
Logged

kaenneth

  • Bay Watcher
  • Catching fish
    • View Profile
    • Terrible Web Site
Re: if self.isCoder(): post() #Programming Thread
« Reply #2018 on: March 21, 2012, 07:45:15 pm »

Quote
As far as I understand, dlls are actually by default executed in another thread too, but it won't give you any significant performance boost. (Someone please correct me if I am wrong on this bit.)

This may be different on some operating systems, but it was my impression that the DLL code was either copied into the process's address space or copied to a single location in memory, where the code would jump to it out of the original process when needed.  It would jump back when done.

This is why there are issues with reentrancy and thread safety with DLLs: if the DLL code stores internal state and gets linked to two processes that do stuff, bad things can happen.

Of course, I could be completely off here since I've never even written a DLL.  I just studied OS theory a bit without much practical application of it.

A .DLL gets mapped into a processes address space, whereupon the functions defined in it become available.

Generally code does not modify itself so it was considered safe for the OS to use 'copy on write' to use one real copy in RAM to serve multiple processes; however, nowdays with more RAM available, more address collisions, and 'ASLR' (see below) each process may have it's own unique copy.

In windows when a .DLL is loaded, if it can't have it's default address, Windows can quickly modify the tables at the beginning of the module to relocate it; that is, a .DLL may have been written to assume it's loaded at A0000000; but another .DLL was already loaded at A0000000, Windows puts the .DLL at B0000000 and goes through all the jumps to A0005678, A0008200, A000FF10 ... changing them to B0005678, B0008200, B000FF10 ... there usually isn't too many of them, since most jumps are relative (like 20 instructions forward, or 17 back, etc)

ASLR is part of a security method where even if the default address is available, windows relocates the .DLL randomly anyway; that's because some exploits could force, for example, a jump to A0005678, and cause the code there to run, but if it's at AB005678, AF005678, 97005678... the exploit will fail; it'll still crash the process, but at least it won't format your boot drive. For anything possibly exposed to external data, it's worth the cost of shuffling things around.

When a .DLL is loaded and unloaded, specifically when a process or a thread starts or stops using it, predefined functions can be called http://msdn.microsoft.com/en-us/library/windows/desktop/ms682583%28v=vs.85%29.aspx

It's really up to the .DLL if it was coded to support multithreading; if it only allocates a chunk of memory when the process attaches, it'll (probably) only support one thread, if it allocates memory as each thread spawns, it's probably designed to be multi-threaded. .DLL's are no more or less thread-safe than any other executable; however, you are generally only as safe as your weakest linked library.
Logged
Quote from: Karnewarrior
Jeeze. Any time I want to be sigged I may as well just post in this thread.
Quote from: Darvi
That is an application of trigonometry that never occurred to me.
Quote from: PTTG??
I'm getting cake.
Don't tell anyone that you can see their shadows. If they hear you telling anyone, if you let them know that you know of them, they will get you.

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2019 on: March 22, 2012, 12:30:54 am »

C is giving me grief again. I could use some help, please :/
Spoiler (click to show/hide)
Supposedly, the stuff in the main() function and up is correct, since that is what the example has. Output currently looks like this:
Code: [Select]
You may enter up to 50 integers:
How many would you like to enter? 10

Enter your numbers:

Your numbers reversed are:


Press any key to continue...

ETA: I have tried placing pointers in various places to call readNum, but I get errors in the for() loops about i and readNum being incompatible or something like that.
« Last Edit: March 22, 2012, 12:36:34 am by Sirus »
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

Mini

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2020 on: March 22, 2012, 12:47:51 am »

What exactly is the problem? Is it not reversing the numbers? Is it not letting you put in numbers?
Logged

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2021 on: March 22, 2012, 12:49:07 am »

What exactly is the problem? Is it not reversing the numbers? Is it not letting you put in numbers?
Yes. After choosing how many integers for the array to hold, it simply prints those text lines and ends.
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

eerr

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2022 on: March 22, 2012, 01:08:29 am »

What exactly is the problem? Is it not reversing the numbers? Is it not letting you put in numbers?
Yes. After choosing how many integers for the array to hold, it simply prints those text lines and ends.

Getnum has a default return value of Zero.
Logged

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2023 on: March 22, 2012, 01:10:50 am »

What exactly is the problem? Is it not reversing the numbers? Is it not letting you put in numbers?
Yes. After choosing how many integers for the array to hold, it simply prints those text lines and ends.

Getnum has a default return value of Zero.
Should I have it return readNum? I get the same results from doing that.
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

fergus

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2024 on: March 22, 2012, 01:24:05 am »

What exactly is the problem? Is it not reversing the numbers? Is it not letting you put in numbers?
Yes. After choosing how many integers for the array to hold, it simply prints those text lines and ends.

Getnum has a default return value of Zero.
Should I have it return readNum? I get the same results from doing that.
You should, or the rest of the code won't have access to it.

Also, what's with this?
Code: [Select]
void getArray(int list[], int size, int readNum, int numbers[MAX_SIZE])
[...]
void printArray(int list[], int size, int readNum, int numbers[MAX_SIZE])
The list and size variables don't seem to do anything and the rest of the code suggests it should be:
Code: [Select]
void getArray(int numbers[MAX_SIZE], int readNum)
[...]
void printArray(int numbers[MAX_SIZE], int readNum)

You also don't need to declare numbers[MAX_SIZE] in getNum()
Logged
BY THE GODS! THIS QUOTE MADE MY SIG BOX HAVE A SCROLL BAR! HAPPY DAYS INDEED!
BY THE GODS! YOU HAVE TOO MANY SIGS!
Pages: 1 ... 133 134 [135] 136 137 ... 796