Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411712 Posts in 69402 Topics- by 58456 Members - Latest Member: FezzikTheGiant

May 21, 2024, 05:28:57 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)The grumpy old programmer room
Pages: 1 ... 111 112 [113] 114 115 ... 295
Print
Author Topic: The grumpy old programmer room  (Read 740633 times)
st33d
Guest
« Reply #2240 on: June 06, 2011, 12:57:12 AM »

I can only get an eternal loop when there is no space to break the condition (such as an empty string or one with only one word). Are you sure you're feeding it the right string?
Logged
st33d
Guest
« Reply #2241 on: June 07, 2011, 04:51:15 AM »

http://twitter.com/#!/FlashHasCrashed
Logged
mcc
Level 10
*****


glitch


View Profile WWW
« Reply #2242 on: June 07, 2011, 09:48:49 PM »

(0,0) is the bottom left corner of the screen.

NO, WAIT

(0,0) is the top left corner of the screen.
Logged

My projects:<br />Games: Jumpman Retro-futuristic platforming iJumpman iPhone version Drumcircle PC+smartphone music toy<br />More: RUN HELLO
Will Vale
Level 4
****



View Profile WWW
« Reply #2243 on: June 08, 2011, 02:01:49 AM »

(0,0) is the top left corner of the screen.

...for certain values of 'up'.
Logged
Triplefox
Level 9
****



View Profile WWW
« Reply #2244 on: June 08, 2011, 02:25:51 AM »

To make my MP3 song loop gaplessly in Flash, I implemented my own looper that incrementally extracts and caches the song in a bytearray during the SampleDataEvent, using the bytearray to emit the result - along with debug tuning controls to get the loop ends exact(which I resorted to after spending nearly an hour trying to tune it just by using whole passes of the song).

I don't know if I should be "happy I did it and it works and it could become very useful library code," or "grumpy that no better alternative presented itself." I tried to get the "encode the song as an MP4 video with no video" trick going but had little success. WHY is this API so bad? And why are there so many patents over these stupid formats? It would be so easy if I could just hook into ffmpeg's decoder or something.
Logged

mcc
Level 10
*****


glitch


View Profile WWW
« Reply #2245 on: June 08, 2011, 08:22:57 PM »

(0,0) is the top left corner of the screen.

...for certain values of 'up'.
"Up" means increasing magnitude on the y coordinate.

NO, WAIT

"Up" means decreasing magnitude on the y coordinate.
Logged

My projects:<br />Games: Jumpman Retro-futuristic platforming iJumpman iPhone version Drumcircle PC+smartphone music toy<br />More: RUN HELLO
wademcgillis
Guest
« Reply #2246 on: June 09, 2011, 09:24:46 AM »

Code:
---------------------------------- cGrid.h ------------------------------

#include <vector>
using namespace std;

template<class T>
class cGrid
{
private:
vector<vector<T>> grid_level;
unsigned int width, height;
void Initialize();
public:
cGrid<T>();
cGrid<T>(unsigned int startwidth, unsigned startheight);
unsigned int Width();
unsigned int Height();
void Resize(unsigned int width, unsigned int height, T val);
void Shift(unsigned int x, unsigned int y);
void Set(unsigned int x, unsigned int y, T val);
T Get(unsigned int x, unsigned int y);
};

---------------------------------- cGrid.cpp ------------------------------

#include "cGrid.h"

template<class T>
cGrid<T>::cGrid<T>()
{
width = 1;
height = 1;
Initialize();
}

template<class T>
cGrid<T>::cGrid<T>(unsigned int w, unsigned h)
{
width = w;
height = w;
Initialize();
}

template<class T>
void cGrid<T>::Initialize()
{
}

template<class T>
unsigned int cGrid<T>::Width()
{
return 0;
}

template<class T>
unsigned int cGrid<T>::Height()
{
return 0;
}

template<class T>
void cGrid<T>::Resize(unsigned int w, unsigned int h, T val)
{
}

template<class T>
void cGrid<T>::Shift(unsigned int x, unsigned int y)
{
}

template<class T>
void cGrid<T>::Set(unsigned int x, unsigned int y, T val)
{
}

template<class T>
T cGrid<T>::Get(unsigned int x, unsigned int y)
{
return NULL;
}

In main.cpp:

cGrid<unsigned char> gridLevel;

And then I get this

1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall cGrid<unsigned char>::cGrid<unsigned char>(void)" (??0?$cGrid@E@@QAE@XZ)


Do I have to make special classes for each type?

 Angry
« Last Edit: June 09, 2011, 10:37:04 AM by Glaiel-Gamer » Logged
jjd
Level 0
**


View Profile
« Reply #2247 on: June 09, 2011, 09:32:44 AM »

Too many <T> is your definitions. Use,

template <typename T>
cGrid<T>::cGrid()
{
}
« Last Edit: June 09, 2011, 10:42:06 AM by jjd » Logged
Nix
Guest
« Reply #2248 on: June 09, 2011, 09:48:05 AM »

Huh? please use this when sharing code
Logged
Glaiel-Gamer
Guest
« Reply #2249 on: June 09, 2011, 10:37:26 AM »

Huh? please use this when sharing code

or code tags
Logged
BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #2250 on: June 09, 2011, 12:57:17 PM »

Do I have to make special classes for each type?
No, you don't. But you do have to be careful with templates, which are annoying in C++.

You must either explicitly instantiate your templates, or ensure the entirety of the template is in the header. I recommend the second. Make sure you mark all the methods with inline, or else you'll get multiply-defined linker errors.
Logged
Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW
« Reply #2251 on: June 09, 2011, 01:01:13 PM »

Do I have to make special classes for each type?
No, you don't. But you do have to be careful with templates, which are annoying in C++.

You must either explicitly instantiate your templates, or ensure the entirety of the template is in the header. I recommend the second. Make sure you mark all the methods with inline, or else you'll get multiply-defined linker errors.

templates are allowed to be defined more than once, you don't need inline for them.
Logged



What would John Carmack do?
Rob Lach
Level 10
*****



View Profile WWW
« Reply #2252 on: June 09, 2011, 11:34:27 PM »

(0,0) is the top left corner of the screen.

...for certain values of 'up'.
"Up" means increasing magnitude on the y coordinate.

NO, WAIT

"Up" means decreasing magnitude on the y coordinate.

Don't even start on Z
Logged

wademcgillis
Guest
« Reply #2253 on: June 10, 2011, 06:35:11 AM »

I'll just use 2D arrays. I'm more comfortable using them.
GomezSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB Cracked
Logged
increpare
Guest
« Reply #2254 on: June 10, 2011, 07:04:37 AM »

I'll just use 2D arrays. I'm more comfortable using them.
Gomez       Hand Knife Right Evil Hand Fork LeftSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB CrackedSMB Cracked

:O
Logged
J. Kyle Pittman
Level 6
*


PostCount++;


View Profile WWW
« Reply #2255 on: June 10, 2011, 08:07:46 AM »

(0,0) is the top left corner of the screen.

...for certain values of 'up'.
"Up" means increasing magnitude on the y coordinate.

NO, WAIT

"Up" means decreasing magnitude on the y coordinate.

Don't even start on Z

Z is always up. Always.

Except when it's not.
Logged

mcc
Level 10
*****


glitch


View Profile WWW
« Reply #2256 on: June 11, 2011, 02:03:16 PM »

I wish it were possible to get the current refresh rate of the monitor. is that possible?
Logged

My projects:<br />Games: Jumpman Retro-futuristic platforming iJumpman iPhone version Drumcircle PC+smartphone music toy<br />More: RUN HELLO
Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW
« Reply #2257 on: June 11, 2011, 02:04:19 PM »

I wish it were possible to get the current refresh rate of the monitor. is that possible?

Yes, what OS?
Logged



What would John Carmack do?
mcc
Level 10
*****


glitch


View Profile WWW
« Reply #2258 on: June 11, 2011, 02:04:46 PM »

I wish it were possible to get the current refresh rate of the monitor. is that possible?

Yes, what OS?

All of them

... That last part may be where the trickiness comes in :|
Logged

My projects:<br />Games: Jumpman Retro-futuristic platforming iJumpman iPhone version Drumcircle PC+smartphone music toy<br />More: RUN HELLO
Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW
« Reply #2259 on: June 11, 2011, 02:12:27 PM »

Here are the functions I use, which get the current display mode, which includes the refresh rate:

Windows:
Code:
#include <windows.h>

void get_current_mode(unsigned *width, unsigned *height, short *hz)
{
    DEVMODE mode = {.dmSize = sizeof(DEVMODE), .dmDriverExtra = 0};

    EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &mode);

    // Store the current display settings.
    *width = mode.dmPelsWidth;
    *height = mode.dmPelsHeight;
    *hz = mode.dmDisplayFrequency;
}

Linux:

Code:
#include <X11/extensions/Xrandr.h>
#include <gdk/gdkx.h>

void get_current_mode(unsigned *width, unsigned *height, short *hz)
{
    // Get the current configuration.
    XRRScreenConfiguration *config = XRRGetScreenInfo(gdk_x11_get_default_xdisplay(),
                                                      gdk_x11_get_default_root_xwindow());
    int size_count;
    // Obtain the dimesions.
    XRRScreenSize *sizes = XRRConfigSizes(config, &size_count);

    // Store the results.
    *width = sizes->width;
    *height = sizes->height;
    *hz = XRRConfigCurrentRate(config);

    XRRFreeScreenConfigInfo(config);
}

Mac:
Code:
#include <CoreFoundation/CoreFoundation.h>

void get_current_mode(unsigned *width, unsigned *height, short *hz)
{
    // Get the current display mode.
    CGDisplayModeRef mode = CGDisplayCopyDisplayMode(CGMainDisplayID());
   
    // Copy the relevant data.
    *width = CGDisplayModeGetWidth(mode);
    *height = CGDisplayModeGetHeight(mode);
    *hz = CGDisplayModeGetRefreshRate(mode);
   
    CGDisplayModeRelease(mode);
}

I think I got the right headers in there.  My Linux code relies on Gtk, but it shouldn't be hard to swap in the raw X stuff.  All code is C.
Logged



What would John Carmack do?
Pages: 1 ... 111 112 [113] 114 115 ... 295
Print
Jump to:  

Theme orange-lt created by panic