|
I am doing a map editor for a game.
The level is 1024x1024 tiles big, with each tile being 16 pixels with default zoom.
I am drawing the tiles by checking if each 64x64 tile portion of the map is visible(CDC::RectVisible) and if it is, I go through all the tiles and paint the ones that are visible(CDC::RectVisible again).
I BitBlt the tiles from a CDC that contains them all.
Then I just use lines to draw a grid over the 64x64 tile square.
Tilesets are generated at start for all zooms, so they're already avilable when drawing.
Now this works OK(45ms drawing. Hey, I use 350mhz ) with 100% zoom,
but with 25% zoom it is quite slow(110ms, altough it feels even slower)
Both are for totally empty map btw!
250ms for full map with 100%
1060ms for full map with 25%
What could I optimize here? Or am I doing something majorly wrong with drawing it?
|
|
|
|
|
Make sure both your tiles and your off-screen bitmap is in video memory. If not, blitting will be slow.
The easiest way to ensure this I believe is to CreateCompatibleBitmap(GetDC(0), ...);
|
|
|
|
|
hello
if "i","j" are double
i=1.2345678
j=2.345678
cout<
|
|
|
|
|
printf("%.2f\n", i*j); - I believe that should do the trick!
With time we live, with money we spend!
Joel Holdsworth.
|
|
|
|
|
If I prefer use cout rather than printf
how can I do???
THX!!!
|
|
|
|
|
char szTemp[256];
sprintf(szTemp, "%.2f\n", i*j);
cout << szTemp;
-Dominik
|
|
|
|
|
You need to use an iomanip function. Unfortunately the VC 6 STL "documentation" is unhelpful, but something like:
cout << setprecision(2) << i*j; should work. The horrible docs and the complexity of using iomanips is why printf() is favored for this type of output.
--Mike--
If it doesn't move and it should: WD-40. If it moves and it shouldn't: duct tape.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Michael Dunn wrote:
You need to use an iomanip function. Unfortunately the VC 6 STL "documentation" is unhelpful
I didn't know that the iomanip header file was part of the STL.
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
#include <iostream>
#include <iomanip>
int main(int argc, char* argv[]) {
double i = 1.2345678;
double j = 2.345678;
std::cout << std::fixed << std::setprecision(2)
<< i * j << std::endl;
}
|
|
|
|
|
hi
i need a brief tutorial about this Class.
thnx
|
|
|
|
|
Hi friends!!!
I've created a server application and want to get its "uptime". What i want is that whenever server starts, it gets the system time and store in variable/s.
Now i want my client to send request to get the server uptime. Whenever the request arrive at server, it checks the time when request arrive and subtract previously recorded time from it and send the difference back to the client. Obviously the time difference will be server's uptime.
But i want the server's uptime to be in the format of (days:hours:minutes:seconds). How can i do so ????
|
|
|
|
|
Hi,
You can just use the CTime class to get that information. Then convert what you have into a string adding the ':' where you want it. Here's one example of how I use it to get the current date and store it in a CString.
CTime time = CTime::GetCurrentTime();
int month = time.GetMonth();
int day = time.GetDay();
int year = time.GetYear();
char tempMonth[50], tempDay[50], tempYear[50];
_itoa(month, tempMonth, 10);
_itoa(day, tempDay, 10);
_itoa(year, tempYear, 10);
CString sDate, sCurMonth, sCurYear;
CString sMonth, sDay, sYear;
sMonth = tempMonth;
sDay = tempDay;
sYear = tempYear;
sDate = sMonth + "/" + sDay + "/" + sYear;
Hope that helps you or at least points you in the right direction. Not sure on subtracting the time though.
Mike
|
|
|
|
|
See CTimeSpan . You'll want to use its Format() method.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I want to make a program that uses an interface like the one found on Norton SystemWorks and Firewall. It will have to be able to open and save files, though. How should I make it? Should I use SDI or dialog, and what kinds of controls are those that give it the different pages? Thanks.
|
|
|
|
|
Hi all,
Is it possible for a program to get its own filename and path during run-time? Without calling the current directory function, because the current directory doesn’t necessarily have to be the same as the program directory. If so, then with what command or API function?
Let us presume a program already knows its own filename and path, either gotten it during run-time or has it as a constant. Now is it possible for the program to alter its own executable program file? I am sure that it won’t get write access but I can’t understand why, when the program is running from the memory it shouldn’t affect it-self during run-time and therefore shouldn’t affect the OS. Is there a function that could give access for altering an executed program file, that is or isn’t the calling programs own executable file?
Please forgive me for any typos...
Aidman » over and out
|
|
|
|
|
|
Thanks Michael!
But what about editing the executable?
Aidman » over and out
|
|
|
|
|
GetModuleFileName(NULL, &szFilepath, sizeof(szFilePath);
I have not looked at the FAQ but I assume it is in there. An FAQ is always a good starting point.
|
|
|
|
|
huh?
I meant... what about the altering the data in the executable it-self?
Is it possible for a program to alter its own executable program file or another already executed program's executable file??? hope you understod the question
Please reply anyone
|
|
|
|
|
Yes you can alter the data in an EXE file, providing that you can open it for writing.
|
|
|
|
|
|
Thanks Dominik!
This article is great, exactly what a needed, thanks again!
Aidman » over and out
|
|
|
|
|
CFileFinder finder("Appname.exe");
finder.FindFile();
CString path=finder.GetFileFolder();
-Steven
By reading this message you are held fully responsible for any of the mispelln's or grammer, issues, found on, codeproject.com.
For those who were wondering, actual (Linux) Penguins were harmed in creating this message.
|
|
|
|
|
hi,
when i'm trying to create a ChooseColor dialog my app just crash and generated an unhandled exception.... then i've tryied to cretae a open filename dialog through GetOpenFileName and it worked. this is weird for me since both functions use commdlg.h and comdlg32.lib. i've initaliazed a very simple CHOOSECOLOR struct for my test :
static CHOOSECOLOR cc = {
sizeof(CHOOSECOLOR),
0,
0,
0,
0,
0,
0,
0,
0
};
any hint ?? thanks
haust
|
|
|
|
|
ok,
forget it. i've just discovered (from an exemple on code project ) that the lpCustColors member from the CHOOSECOLOR struct _must_ be valid.... i _thought_ that is was _optional_, it was _not_
well, i guess i've learnt something once more 2day....
|
|
|
|