• What do you need help with? Version 5
    5,752 replies, posted
And another thing, to delete glResources the context that they were created in needs to still be open right? So my question is, with an sf::Window does closing the window destroy the context? how I did it: [cpp] in main: create window create game and pass window as reference run game, in run game: check if window is open: if window close flag or esc is pressed: close window delete game [/cpp] How I now do it: [cpp] in main: create window create game and pass window as reference run game, in run game: create true bool mRunning while mRunning: if window close flag or esc is pressed: mRunning = false delete game close window [/cpp]
[QUOTE=Richy19;37562047]---[/QUOTE] All shadow. This is assuming that you have a light that is in that rectangular shape, of course. And that there are no other lights in that outside area. Could try blending it a bit so it doesn't look weird.
So, I'm supposed to iterate through a raw (24bpp) BGR buffer in this order: [IMG]https://dl.dropbox.com/u/27714141/fsv.png[/IMG] I'm also supposed to read each individual block in the same order (read pixels from bottom to top); and to quote the original paper: [quote]Blocks have width and height that range from 16 to 256 in multiples of 16. Block height is not required to match block width. The block size must not change except at a keyframe. Blocks are ordered from the bottom left of the image to the top right, in rows. A fixed layout of blocks exists for any given combination of block size and image size. To determine the number of blocks in a row of the grid, divide the image width by the block width. If the result is not an integer, the end of each row has one partial block, which contains only the number of pixels necessary to fill the remaining width of the image. The same logic applies to the image height, block height, number of rows in the grid, and partial blocks in the final row. It is important to understand the partial-block algorithm to create correct blocks, since the pixels within a partial block are extracted with implicit knowledge of the width and height of the block. The following is an example of blocking. The image in this example is 120 x 80 pixels, and the block size is 32 x 32.[/quote] How would you go about it? I lose all sanity when I stare at my 4th nested loop; and I can't help thinking there must be a better way to iterate them.
[QUOTE=voodooattack;37569855]So, I'm supposed to iterate through a raw (24bpp) BGR buffer in this order: [IMG]https://dl.dropbox.com/u/27714141/fsv.png[/IMG] I'm also supposed to read each individual block in the same order (read pixels from bottom to top); and to quote the original paper: How would you go about it? I lose all sanity when I stare at my 4th nested loop; and I can't help thinking there must be a better way to iterate them.[/QUOTE] Shouldn't it just be 2 loops, on for rows, then columns?
[QUOTE=Topgamer7;37570073]Shouldn't it just be 2 loops, on for rows, then columns?[/QUOTE] You have to extract the individual blocks, reconstruct the subimage from each cell, flip it upside down, reverse the endianess, and then compress them with zlib. What I have right now: [csharp] for (int row = yblocks; row >= 0; --row) { for (int col = 0; col < xblocks; col++) { MemoryOutputStream buffer = new MemoryOutputStream(new uint8[]{}, realloc, free); ConverterOutputStream zbuffer = new ConverterOutputStream(buffer, new ZlibCompressor(ZlibCompressorFormat.ZLIB, 0)); uint8[] block; slice_pixel_block(inbuf.data, row, col, width, height, block_width, block_height, out block); zbuffer.write( block ); zbuffer.close(); int16 size = (int16)buffer.get_data_size(); writer.put_int16_be(size); if (size > 0) writer.put_data(buffer.get_data(), size); } }[/csharp] And my retarded implementation of slice_pixel_block (crashes at row 0, cell 0): [csharp] void slice_pixel_block(uint8[] buffer, int row, int col, int width, int height, int blockw, int blockh, out uint8[] result) { int xblocks = width / blockw, yblocks = height / blockh; int wpart = (width % xblocks), hpart = (height % yblocks); int bw = col == xblocks - 1 && wpart > 0 ? wpart : blockw; int bh = row == 0 && hpart > 0 ? hpart : blockh; result = new uint8[bw * bh]; //dbg(@"$width $height $row $col $wpart $hpart $bw $bh "); int yoffset = row * blockh * width + hpart * width; int xoffset = col * blockw - wpart; int offset = yoffset + xoffset; int z = 0; for (int i = (blockh - hpart); i > 0; i--) for (int j = 0; j < bw; j++) { result[z++] = buffer[offset + i * width + j]; } }[/csharp]
[QUOTE=voodooattack;37569855]So, I'm supposed to iterate through a raw (24bpp) BGR buffer in this order: [IMG]https://dl.dropbox.com/u/27714141/fsv.png[/IMG] I'm also supposed to read each individual block in the same order (read pixels from bottom to top); and to quote the original paper: How would you go about it? I lose all sanity when I stare at my 4th nested loop; and I can't help thinking there must be a better way to iterate them.[/QUOTE] [cpp]#define MAP_IDX_TO_BLOCKS(i, w, h, bw, bh, bx, by, sx, sy) \ { \ const unsigned int block_cx = (w) / (bw) + (((w) % (bw) == 0) ? 0 : 1), \ block_cy = (h) / (bh) + (((h) % (bh) == 0) ? 0 : 1), \ block_sz = (bw) * (bh), \ row_sz = (w) * (bh); \ unsigned int row_i = (i) / row_sz, \ row_rem = (i) - row_i * row_sz, \ block_i = row_rem / block_sz, \ block_rem = row_rem - block_i * block_sz; \ unsigned int cw = (bw), \ ch = (bh); \ \ (by) = block_cy - row_i - 1; \ if ((by) == 0) \ { \ ch = (h) % (bh); \ if (ch == 0) ch = (bh); \ \ block_i = row_rem / ((bw) * ch); \ block_rem = row_rem - block_i * (bw) * ch; \ } \ (bx) = block_i; \ \ if ((bx) == block_cx - 1) \ cw = (w) % (bw); \ if (cw == 0) cw = (bw); \ \ (sy) = block_rem / cw; \ (sx) = block_rem - (sy) * cw; \ } for (i = 0; i < (image_width * image_height); i++) { MAP_IDX_TO_BLOCKS(i, image_width, image_height, block_width, block_height, block_x, block_y, sub_x, sub_y); /* block_x, block_y now contain which block is being iterated * sub_x, sub_y hold the position of the pixel inside the block */ }[/cpp] don't even ask why it's #defined [editline]7th September 2012[/editline] except it doesn't iterate from the bottom up with the sub-indices but whatever, the idea is to map a single index into your target coordinates, whatever they may be
My MinGW does not have network libraries like socket, etc. Where can I find to download? I also tried to find in the deep web (heck, no).
[QUOTE=ThePuska;37570553][cpp]#define MAP_IDX_TO_BLOCKS(i, w, h, bw, bh, bx, by, sx, sy) \ { \ const unsigned int block_cx = (w) / (bw) + (((w) % (bw) == 0) ? 0 : 1), \ block_cy = (h) / (bh) + (((h) % (bh) == 0) ? 0 : 1), \ block_sz = (bw) * (bh), \ row_sz = (w) * (bh); \ unsigned int row_i = (i) / row_sz, \ row_rem = (i) - row_i * row_sz, \ block_i = row_rem / block_sz, \ block_rem = row_rem - block_i * block_sz; \ unsigned int cw = (bw), \ ch = (bh); \ \ (by) = block_cy - row_i - 1; \ if ((by) == 0) \ { \ ch = (h) % (bh); \ if (ch == 0) ch = (bh); \ \ block_i = row_rem / ((bw) * ch); \ block_rem = row_rem - block_i * (bw) * ch; \ } \ (bx) = block_i; \ \ if ((bx) == block_cx - 1) \ cw = (w) % (bw); \ if (cw == 0) cw = (bw); \ \ (sy) = block_rem / cw; \ (sx) = block_rem - (sy) * cw; \ } for (i = 0; i < (image_width * image_height); i++) { MAP_IDX_TO_BLOCKS(i, image_width, image_height, block_width, block_height, block_x, block_y, sub_x, sub_y); /* block_x, block_y now contain which block is being iterated * sub_x, sub_y hold the position of the pixel inside the block */ }[/cpp] don't even ask why it's #defined [editline]7th September 2012[/editline] except it doesn't iterate from the bottom up with the sub-indices but whatever, the idea is to map a single index into your target coordinates, whatever they may be[/QUOTE] Thanks! I can take it from here. All I really have to do is set it up so that I have a 2D array of streams for each block, then write them all at the end. I'll try it out and come back with (hopefully good) results. Thanks again.
Nope, not as easy as I initially thought, I converted the #define statement into a function and it worked perfectly, but due to the nature of the loop itself I can't get it to write the blocks in bottom up as intended, so it looks like I'm stuck with the way I was already using.. enumerate over rows and columns.. I'm tearing my hairs out over this problem, arghhh.
[QUOTE=ThePuska;37570553]don't even ask why it's #defined[/QUOTE] The best code used is truly the code you don't understand. [editline]7th September 2012[/editline] [QUOTE=Cesar Augusto;37571008]My MinGW does not have network libraries like socket, etc. Where can I find to download? I also tried to find in the deep web (heck, no).[/QUOTE] What errors do you specifically have?
[QUOTE=Cesar Augusto;37571008]My MinGW does not have network libraries like socket, etc. Where can I find to download? I also tried to find in the deep web (heck, no).[/QUOTE] Yes, it does. Winsock2.
Winsock2 for windows (as I know). I would like to have POSIX socket.h
The sockets APIs are practically interchangeable between Winsock and POSIX. [editline]7th September 2012[/editline] [quote]Winsock follows the Windows Open System Architecture (WOSA) model; it defines a standard service provider interface (SPI) between the application programming interface (API), with its exported functions and the protocol stacks. It uses the sockets paradigm that was first popularized by Berkeley Software Distribution (BSD) UNIX.[/quote]
The only differences are that you have to initialise Winsock and that you have to use closesocket() instead of close()
Is it worth trying to create a Component Base Entity System in Lua / Love2D? I've been reading about it and it seems really interesting.
[QUOTE=esalaka;37575979]The only differences are that you have to initialise Winsock and that you have to use closesocket() instead of close()[/QUOTE] Yeah, basically vendor lock in. Edit: It's a joke.
Okay, so I got this weird-ass problem. I am making my character move, with an animation, I've got one .png file with the animations. [img]http://puu.sh/12V4r[/img] It works fine when I start it up, I can walk around without issue. Now, when I try to sprint, it suddenly bugs out, and becomes a brown stripe. [img]http://puu.sh/12V6S[/img] When I sprint, I increase my animationspeed, maybe that's it, but it seems to fuck up at random points. The code for my animation: [url]http://pastebin.com/tkDfMxNN[/url] Help would be nice!
My best guess would be you are overshooting totalFrames. You should probably be using a >= check instead of just ==.
Thank you very much, that worked.
[cpp]/** * Name: Leon Ling * Section: 1 * Program: Lab 1 * Date: September 7, 2012 * Description: In one or two sentences, what the program does. */ import java.util.Scanner; public class Lab1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); double[] arr1 = new double[50]; double[] arr2 = new double[50]; int counter = 0; double maxValue = 0; System.out.print("Enter data points, separated by whitespace."); System.out.println(); while (input.hasNextDouble()) { arr1[counter] = input.nextDouble(); counter++; } for (int i = 0; i < arr1.length; i++){ arr2[i] = arr1[i]; } for (int i = 0; i < arr1.length; i++){ if(arr1[i] > maxValue){ maxValue = arr1[i]; } } for (int i = 0; i < arr2.length; i++){ arr2[i]/maxValue; } System.out.print(arr2[2]); } } [/cpp] I need to divide the individual elements of the array by the maximum value of the arrays, which is maxValue. Anyone know what I'm doing wrong, and how to fix it? Thanks.
[QUOTE=Leonmyster;37582371][cpp] for (int i = 0; i < arr2.length; i++){ arr2[i]/maxValue; }[/cpp] I need to divide the individual elements of the array by the maximum value of the arrays, which is maxValue. Anyone know what I'm doing wrong, and how to fix it? Thanks.[/QUOTE] You divide but don't assign. Use "arr2[i] /= maxValue;" or "arr2[i] = arr2[i] / maxValue;"
For some reason people running 2.3.3 are having issues with my game. It uses 2 texture files, and switches between them for text and textures. However, the switch does not occur so they just have garbled pieces of textures instead of text. How can I fix this?
[cpp]/** * Name: Leon Ling * Section: 1 * Program: Lab 1 * Date: September 7, 2012 * Description: In one or two sentences, what the program does. */ import java.util.Scanner; public class Lab1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); double[] arr1 = new double[50]; double[] arr2 = new double[50]; int counter = 0; double maxValue = 0; System.out.print("Enter data points, separated by whitespace."); System.out.println(); while (input.hasNextDouble()) { arr1[counter] = input.nextDouble(); counter++; } for (int i = 0; i < arr2.length; i++){ arr2[i] = arr1[i]; } for (int i = 0; i < arr1.length; i++){ if(arr1[i] > maxValue){ maxValue = arr1[i]; } } for (int i = 0; i < arr2.length; i++){ arr2[i] = arr2[i]/maxValue; } System.out.println("Scaled form of 'Sample Interaction Data':"); for (int i = 0; i < arr2.length; i++){ System.out.printf("%.2f", arr2[i]); System.out.println(); } } } [/cpp] Okay...another issue. So now I'm trying to print out the numbers, but when I do, I get this... Enter data points, separated by whitespace. 50 40 30 20 10 0 f Scaled form of 'Sample Interaction Data': 1.00 0.80 0.60 0.40 0.20 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 ... 0.00 I figured it's because Java initializes the elements of the array, but is there anyway to fix this?
Either use an "if" statement to avoid printing zeroes (although this will skip legitimate zeroes), or keep a counter of how many items the user enters, or use an Arraylist or other container instead of a primitive array so that there aren't any extra elements. EDIT: I see that you do keep a counter. Just replace this line: [code]for (int i = 0; i < arr2.length; i++){[/code] with this: [code]for (int i = 0; i < counter; i++){[/code] Bingo bango.
[QUOTE=WTF Nuke;37582597]For some reason people running 2.3.3 are having issues with my game. It uses 2 texture files, and switches between them for text and textures. However, the switch does not occur so they just have garbled pieces of textures instead of text. How can I fix this?[/QUOTE] Needs more details than this. There are a billion things that could be going wrong here.
[QUOTE=ECrownofFire;37583261]Needs more details than this. There are a billion things that could be going wrong here.[/QUOTE] I realized how vague I was now, sorry. Basically I bind the two textures using [cpp] GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataHandle);[/cpp] Then, to change the textures I use [cpp]GLES20.glUniform1i(mTextureUniformHandle, 0);[/cpp] However, changing the uniform in between draw calls doesn't seem to work on 2.3.3 phones. It might not work on higher versions, but this is the version I know doesn't work and the other versions that I have tried do work (they were all 4.0+).
Fixed, that was really god damn close.
Do I need some specific library if I want to compute integers with 1024 digits?
[QUOTE=Chezburger;37586978]Do I need some specific library if I want to compute integers with 1024 digits?[/QUOTE] libgmp
Thanks!
Sorry, you need to Log In to post a reply to this thread.