I've been stuck on this problem for a while, no one seems to want or can help :-\. I'm back now to working on it. I've made progress from nothing showing to something showing
. But not everything shows and the fact that I got something to show up was no more than trial and error.
This code is not in its natural form, I'm splicing it together to make one loop.
| 1 | vector<uint> m_Map; |
| 2 | ... |
| 3 | |
| 4 | const uint ScreenRows = (SCREEN_H / m_Tiles->GetTileHeight()); |
| 5 | const uint ScreenCols = (SCREEN_W / m_Tiles->GetTileWidth()); |
| 6 | int Column = 0; |
| 7 | int Row = 0; |
| 8 | |
| 9 | int Xpixel = 0; |
| 10 | int Ypixel = 0; |
| 11 | |
| 12 | int CurScreenRow = 0; |
| 13 | int CurScreenCol = 0; |
| 14 | |
| 15 | uint TileNumber = 0; |
| 16 | |
| 17 | // Cycle through and draw each tile at its location on the screen |
| 18 | while(Row < m_Height && Ypixel < m_Height * m_Tiles->GetTileHeight() && CurScreenRow < ScreenRows) |
| 19 | { |
| 20 | while(Column < m_Width && Xpixel < m_Width * m_Tiles->GetTileWidth() && CurScreenCol < ScreenCols) |
| 21 | { |
| 22 | TileNumber = m_Map.at((Row * m_Width + Column) * Layer); |
| 23 | m_Tiles->Draw(TileNumber, Xpixel, Ypixel, 1.0f); |
| 24 | Column++; |
| 25 | CurScreenCol++; |
| 26 | Xpixel += m_Tiles->GetTileWidth(); |
| 27 | } |
| 28 | Xpixel = 0; |
| 29 | CurScreenCol = 0; |
| 30 | Column = Xpos; |
| 31 | Ypixel += m_Tiles->GetTileHeight(); |
| 32 | Row++; |
| 33 | CurScreenRow++; |
| 34 | } |
Aw screw it I don't feel like copying cTile->Draw into that loop here it is:
| 1 | bool cTile::Draw(uint TileNum, uint Xpos, uint Ypos, float Scale) |
| 2 | { |
| 3 | if(!m_TileSet.IsValid()) |
| 4 | { |
| 5 | cLogFile::Add("Tileset not valid"); |
| 6 | return false; |
| 7 | } |
| 8 | float tileXpos = 0; |
| 9 | float tileYpos = 0; |
| 10 | |
| 11 | tileXpos = (float)((TileNum % m_Cols) * m_TileWidth); |
| 12 | tileYpos = (float)((TileNum / m_Cols) * m_TileHeight); |
| 13 | |
| 14 | m_TileSet.BlitStretched((float)Xpos - tileXpos, (float)Ypos - tileYpos, (float)m_TileWidth * 2.0, (float)m_TileHeight * 2.0, Clipped(tileXpos, tileYpos, m_TileWidth, m_TileHeight)); |
| 15 | |
| 16 | return true; |
| 17 | } |
I am having to draw it double the size to get it to be the correct 1:1 scale size. And not all of the tiles draw correctly. I have sent output of the data to a log file and everything seems fine... I don't understand why some will draw now and others will not. Does BlitStretched stretch first then do the clipping based on the newly stretched image? Are my offsets in the drawing coords wrong? It seems weird that some tiles show up and others do not. What is most weird is that I have to multiply by 2 to get a normal sized tile. m-Height/Width are the correct value.
Here's what this looks like when drawing with just Blit()
{"name":"correctnz1.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/0\/e061904fec5b3c5098ac68c47e2d8c7f.png","w":646,"h":505,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/0\/e061904fec5b3c5098ac68c47e2d8c7f"}
Here's what this looks like when drawing with the loop above BlitStretched()
{"name":"wrongee9.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/3\/1390a2b7e472f0d39cca36c4feb8ca1a.png","w":646,"h":505,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/3\/1390a2b7e472f0d39cca36c4feb8ca1a"}
Somehow, I think the issue is with Clipped in this case. Could you attach the whole project so that I could take a look?
Alright, the full project is attached to the original post.
OK, I found the issue! Now stretching and clipping will work together. Though the stretching affects the original image, not the clipped part, so if you want double the normal size, you should pass double the size of the tiles-image.
Ok well how do I get this fixed version? I'm on the trunk directory of your SVN site. How do I grab everything at once and replace my old stuff?
EDIT: I'm guessing their is some kind of CVS like tool to get the new ones. I guess I can just manually look for the files that were updated a few hours ago.
You can grab a snapshot from my signature.
Matthew: You may use TortoiseSVN to get stuff from any SVN depot.
Whats that status on OL working on windows?
I have setup everything for MSVC 7.1 with project files for OL and all dependencies. Works like a charm. Most sources are from SVN resp. CVS though.
Whats that status on OL working on windows?
Well, I have only Windows myself. I guess you mean MSVC
I'm using mingw and I can't get OL to compile, boat loads of compiler errors.
Juvinious fixed some build stuff yesterday, maybe it works now? At least it does for me, and I'm using MingW as well.
Dustin Dettmer: Well if you are using the Dev-C++ IDE then you just grab OpenLayer and it grabs everything it depends on. Go to file->new->Project Then under the MultiMedia tab there is a nice little OpenLayer project template :-D. Let the compiling begin
Sounds great but I'll need the source to do any real OL development
Either get the nightly snapshot or get the source from SVN directly.
Alright, well I got the scaling to work at a scale of 1 and I think I'm having a bit of a logistics problem when it comes to tiling these tiles at a scaled transformation. I'm probably using the Scale too much or not enough, I know I must be using it in the wrong way. I think I'm close though. So any help on the correct formula for scale tiling?
| 1 | // TileNum - The tiles representation in the array |
| 2 | // Xpos && Ypos - The X and Y Coords in pixels. |
| 3 | // Scale - the scale at which to draw the image |
| 4 | bool cTile::Draw(uint TileNum, uint Xpos, uint Ypos, float Scale) |
| 5 | { |
| 6 | // Just use the other method that draws normally |
| 7 | if(Scale == 1.0) |
| 8 | { |
| 9 | Draw(TileNum, Xpos, Ypos); |
| 10 | return true; |
| 11 | } |
| 12 | if(!m_TileSet.IsValid()) |
| 13 | { |
| 14 | cLogFile::Add("Tileset not valid"); |
| 15 | return false; |
| 16 | } |
| 17 | // these are the x and y coords of the tile inside the bitmap |
| 18 | float tileXpos = 0; |
| 19 | float tileYpos = 0; |
| 20 | |
| 21 | tileXpos = (float)((TileNum % m_Cols) * m_TileWidth); |
| 22 | tileYpos = (float)((TileNum / m_Cols) * m_TileHeight); |
| 23 | |
| 24 | // this is x and y coords that the tile should be drawn at |
| 25 | float newX; |
| 26 | float newY; |
| 27 | |
| 28 | newX = ((float)Xpos * Scale - tileXpos); |
| 29 | newY = ((float)Ypos * Scale - tileYpos); |
| 30 | |
| 31 | // the width and height that should be used to draw the tile |
| 32 | float newWidth; |
| 33 | float newHeight; |
| 34 | |
| 35 | newWidth = (float)m_TileSet.Width() * Scale; |
| 36 | newHeight = (float)m_TileSet.Height() * Scale; |
| 37 | |
| 38 | |
| 39 | m_TileSet.BlitStretched(newX, newY, newWidth, newHeight, Clipped(tileXpos, tileYpos, m_TileWidth * Scale, m_TileHeight * Scale)); |
| 40 | |
| 41 | return true; |
| 42 | } |
I'm using mingw and I can't get OL to compile, boat loads of compiler errors.
Could you post those errors and how you are compiling?
mkdir OpenLayer
svn co http://svn.berlios.de/svnroot/repos/openlayer/trunk OpenLayer
cmd window:
| 1 | C:\Program Files\Apoint 2.0\OpenLayer> buildme.bat |
| 2 | |
| 3 | Can't find freetype do you have it installed? |
| 4 | Please specify where its located: |
| 5 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 6 | ist in the directory) |
| 7 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 8 | |
| 9 | |
| 10 | Can't find freetype do you have it installed? |
| 11 | Please specify where its located: |
| 12 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 13 | ist in the directory) |
| 14 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 15 | |
| 16 | |
| 17 | Can't find freetype do you have it installed? |
| 18 | Please specify where its located: |
| 19 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 20 | ist in the directory) |
| 21 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 22 | |
| 23 | |
| 24 | Can't find freetype do you have it installed? |
| 25 | Please specify where its located: |
| 26 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 27 | ist in the directory) |
| 28 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 29 | |
| 30 | |
| 31 | Can't find freetype do you have it installed? |
| 32 | Please specify where its located: |
| 33 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 34 | ist in the directory) |
| 35 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 36 | |
| 37 | |
| 38 | Can't find freetype do you have it installed? |
| 39 | Please specify where its located: |
| 40 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 41 | ist in the directory) |
| 42 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 43 | |
| 44 | |
| 45 | Can't find freetype do you have it installed? |
| 46 | Please specify where its located: |
| 47 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 48 | ist in the directory) |
| 49 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 50 | |
| 51 | |
| 52 | Can't find freetype do you have it installed? |
| 53 | Please specify where its located: |
| 54 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 55 | ist in the directory) |
| 56 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 57 | |
| 58 | |
| 59 | Can't find freetype do you have it installed? |
| 60 | Please specify where its located: |
| 61 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 62 | ist in the directory) |
| 63 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 64 | |
| 65 | |
| 66 | Can't find freetype do you have it installed? |
| 67 | Please specify where its located: |
| 68 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 69 | ist in the directory) |
| 70 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 71 | |
| 72 | |
| 73 | Can't find freetype do you have it installed? |
| 74 | Please specify where its located: |
| 75 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 76 | ist in the directory) |
| 77 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 78 | |
| 79 | |
| 80 | Can't find freetype do you have it installed? |
| 81 | Please specify where its located: |
| 82 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 83 | ist in the directory) |
| 84 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 85 | |
| 86 | |
| 87 | Can't find freetype do you have it installed? |
| 88 | Please specify where its located: |
| 89 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 90 | ist in the directory) |
| 91 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 92 | |
| 93 | |
| 94 | Can't find freetype do you have it installed? |
| 95 | Please specify where its located: |
| 96 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 97 | ist in the directory) |
| 98 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 99 | |
| 100 | |
| 101 | Can't find freetype do you have it installed? |
| 102 | Please specify where its located: |
| 103 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 104 | ist in the directory) |
| 105 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 106 | |
| 107 | |
| 108 | Can't find freetype do you have it installed? |
| 109 | Please specify where its located: |
| 110 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 111 | ist in the directory) |
| 112 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 113 | |
| 114 | |
| 115 | Can't find freetype do you have it installed? |
| 116 | Please specify where its located: |
| 117 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 118 | ist in the directory) |
| 119 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 120 | |
| 121 | |
| 122 | Can't find freetype do you have it installed? |
| 123 | Please specify where its located: |
| 124 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 125 | ist in the directory) |
| 126 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 127 | |
| 128 | |
| 129 | Can't find freetype do you have it installed? |
| 130 | Please specify where its located: |
| 131 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 132 | ist in the directory) |
| 133 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 134 | |
| 135 | |
| 136 | Can't find freetype do you have it installed? |
| 137 | Please specify where its located: |
| 138 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 139 | ist in the directory) |
| 140 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 141 | |
| 142 | |
| 143 | Can't find freetype do you have it installed? |
| 144 | Please specify where its located: |
| 145 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 146 | ist in the directory) |
| 147 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 148 | |
| 149 | |
| 150 | Can't find freetype do you have it installed? |
| 151 | Please specify where its located: |
| 152 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 153 | ist in the directory) |
| 154 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 155 | |
| 156 | |
| 157 | Can't find freetype do you have it installed? |
| 158 | Please specify where its located: |
| 159 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 160 | ist in the directory) |
| 161 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 162 | |
| 163 | |
| 164 | Can't find freetype do you have it installed? |
| 165 | Please specify where its located: |
| 166 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 167 | ist in the directory) |
| 168 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 169 | |
| 170 | |
| 171 | Can't find freetype do you have it installed? |
| 172 | Please specify where its located: |
| 173 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 174 | ist in the directory) |
| 175 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 176 | |
| 177 | |
| 178 | Can't find freetype do you have it installed? |
| 179 | Please specify where its located: |
| 180 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 181 | ist in the directory) |
| 182 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 183 | |
| 184 | |
| 185 | Can't find freetype do you have it installed? |
| 186 | Please specify where its located: |
| 187 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 188 | ist in the directory) |
| 189 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 190 | |
| 191 | |
| 192 | Can't find freetype do you have it installed? |
| 193 | Please specify where its located: |
| 194 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 195 | ist in the directory) |
| 196 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 197 | |
| 198 | |
| 199 | Can't find freetype do you have it installed? |
| 200 | Please specify where its located: |
| 201 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 202 | ist in the directory) |
| 203 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 204 | |
| 205 | |
| 206 | Can't find freetype do you have it installed? |
| 207 | Please specify where its located: |
| 208 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 209 | ist in the directory) |
| 210 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 211 | |
| 212 | |
| 213 | Can't find freetype do you have it installed? |
| 214 | Please specify where its located: |
| 215 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 216 | ist in the directory) |
| 217 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 218 | |
| 219 | |
| 220 | Can't find freetype do you have it installed? |
| 221 | Please specify where its located: |
| 222 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 223 | ist in the directory) |
| 224 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 225 | |
| 226 | |
| 227 | Can't find freetype do you have it installed? |
| 228 | Please specify where its located: |
| 229 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 230 | ist in the directory) |
| 231 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 232 | |
| 233 | |
| 234 | Can't find freetype do you have it installed? |
| 235 | Please specify where its located: |
| 236 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 237 | ist in the directory) |
| 238 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 239 | |
| 240 | |
| 241 | Can't find freetype do you have it installed? |
| 242 | Please specify where its located: |
| 243 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 244 | ist in the directory) |
| 245 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 246 | |
| 247 | |
| 248 | Can't find freetype do you have it installed? |
| 249 | Please specify where its located: |
| 250 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 251 | ist in the directory) |
| 252 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 253 | |
| 254 | |
| 255 | Can't find freetype do you have it installed? |
| 256 | Please specify where its located: |
| 257 | example: c:/mingw (make sure lib/libfreetype.a and include/freetype2/freetype ex |
| 258 | ist in the directory) |
| 259 | Enter ignore to disable ttf support or exit if you don't have it and quit setup. |
| 260 | |
| 261 | C:\dev-cpp |
| 262 | Do you wish to drop TTF support? [y/N] |
| 263 | |
| 264 | Do you wish to use FreeType directly and drop GlyphKeeper? [y/N] |
| 265 | y |
| 266 | Do you wish to drop PNG support? [y/N] |
| 267 | |
| 268 | Do you wish to drop old API Support? [y/N] |
| 269 | y |
| 270 | Do you wish to drop State Changes? [y/N] |
| 271 | |
| 272 | - Creating required directories - |
| 273 | Creating directory obj/... |
| 274 | Creating directory dep/... |
| 275 | Creating directory lib/... |
| 276 | - Starting compilation - |
| 277 | Compiling src/Animation.cpp... |
| 278 | src/Animation.cpp:1:25: Animation.hpp: No such file or directory |
| 279 | src/Animation.cpp:3: error: expected namespace-name before ';' token |
| 280 | src/Animation.cpp:3: error: `<type error>' is not a namespace |
| 281 | src/Animation.cpp:8: error: `Animation' has not been declared |
| 282 | src/Animation.cpp:8: error: `string' was not declared in this scope |
| 283 | src/Animation.cpp:8: error: `string' was not declared in this scope |
| 284 | src/Animation.cpp:8: error: expected primary-expression before "int" |
| 285 | src/Animation.cpp:8: error: initializer expression list treated as compound expr |
| 286 | ession |
| 287 | src/Animation.cpp:8: error: expected `,' or `;' before '{' token |
| 288 | src/Animation.cpp:20: error: `Animation' has not been declared |
| 289 | src/Animation.cpp: In function `bool Update(float)': |
| 290 | src/Animation.cpp:21: error: `currentFrame' undeclared (first use this function) |
| 291 | |
| 292 | src/Animation.cpp:21: error: (Each undeclared identifier is reported only once f |
| 293 | or each function it appears in.) |
| 294 | src/Animation.cpp:21: error: `framesPerTick' undeclared (first use this function |
| 295 | ) |
| 296 | src/Animation.cpp:22: error: `frames' undeclared (first use this function) |
| 297 | src/Animation.cpp: At global scope: |
| 298 | src/Animation.cpp:31: error: expected init-declarator before '&' token |
| 299 | src/Animation.cpp:31: error: expected `,' or `;' before '&' token |
| 300 | |
| 301 | C:\Program Files\Apoint 2.0\OpenLayer> |
DDustin:
Ok this is the obvious reason why I am deprecating cbuild and replacing the build system with cmake.
I assume you are using mingw and have make? If you don't mind trying again, could you grab this and install it?
Then in a cmd window in the directory in which you checked out the source do:
mkdir temp cd temp cmakesetup ../
From there you'll get a setup window, choose MinGW makefiles and then hit configure. You might want to fix anything that appears in red and set CMAKE_INSTALL_PREFIX to where you want openlayer to install to, ie c:/mingw. If everything is fine you should be able to just hit ok which then it'll have generated makefiles and drop you back to the cmd line. All you have to do then is 'make' and then 'make install'.
My Question still hasn't been answered :-P I got 1 tile to scale horizontally (not vertically too
) by 3 times its original size, but then the rest don't scale. Or maybe my eyers are being deceptive. Any help with the above code would be nice. The code thats 4-5 posts up from this one.