Jump to content
  • Advertisement

Galapaegos

Member
  • Content Count

    192
  • Joined

  • Last visited

Community Reputation

277 Neutral

About Galapaegos

  • Rank
    Member
  1. Galapaegos

    recording / replaying

    Paic, You could always save those inputs and timestamp them when they occur, then play them back in a different thread playing those inputs at their specified offseted time. When you seek, you can replay through all the events as fast as possible and not perform any rendering. I don't know how many assumptions you can make, but there might be some to help speed up seeking. -brad
  2. Galapaegos

    Blending Textures for terrain.

    Hi Seoushi, I've been reading up on this topic also. The method that I plan to use is to start with an alphamap for each layer within the terrain-blend. You'll want use the alpha from the alpha map, but use the color from the real texture, and then composite the different layers together to produce your image. [souce] //alpha map glActiveTextureARB(GL_TEXTURE0); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE0); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); //layer glActiveTextureARB(GL_TEXTURE1); //add your color stuff here [/source] You'll want to check out glTexEnv for more info on all the different things you can do. -brad
  3. Galapaegos

    glew glBlend* crash

    Thanks MARS_999, Yeah I'm only initializing glew once. I've come across a different issue, so I'm hoping that once I figure that out I'll be in the clear with this glew issue. -brad
  4. griffin2000, Have you tried ignoring libraries? It usually lists the library where the duplicate symbol is coming from, so just try ignoring until you find the right combination? -brad
  5. Hi, I'm experiencing a very odd bug on the Windows platform with an nvidia card (91.47). I've been experimenting with some windowing libraries, FLTK and wxWidgets. We have our own volume rendering library which links against GLEW. When I write a simple FLTK application performing volume rendering, I don't have any problems. When I do the same in wxWidgets, GLEW doesn't initialize itself properly. It crashes when glBlendEquation and glBlendColor are called, giving me an address of 0. The glewGetProcAddress is failing, but I have no idea why? Also, the glewInit should be called in the right location (in my OnPaint message, I'm having it initialize itself if its the first time drawing. Anyone have any ideas for me? Thanks! -brad
  6. Are you subclassing the controls properly? When they are created, you need to save out the old WNDPROC, and then have your user-defined WNDPROC call CallWindowProc on the old WNDPROC. -brad
  7. Galapaegos

    Goblin Tinkerer

    Can anyone say Iron Kingdoms? Goblins are named 'gobbers', and many of them are crazy mechaniks. -brad
  8. @ap: I prefer using callbacks, so my thread class has a 'setCB' function that I pass in the function. As for critical sections, my class basically calls the win32 stuff (ie InitCriticalSection in the constructor, EnterCriticalSection in a function called 'lock', LeaveCriticalSection in a function called 'unlock', then destructor calls DeleteCriticalSection). I haven't had a need for a real semaphore at the moment, but it would be based off the critical section class. @webwraith: Personally, I would stick the input in with the gui thread unless you really have to use a separate thread, or plan to use DirectInput. The problem is that you would need to intercept the 'WM_KEYDOWN' messages being sent to your windows, and that would not flow with the next sentence I'm about to say: Always make sure all your windows are run from the same thread, otherwise you'd have multiple message pump loops and that gets too confusing. If you still want to use a separate thread, I'd go the route of DirectInput for handling input. Keep in mind, you'll want to create an event system or some such, to provide communication back and forth from the thread handling input and the thread handling your engine. Your general structure is essentially the same thing I'm describing. void handle_input () { //lock input_mutex //set input changes that have been made //unlock input_mutex } int main (...) { //create window //create input thread while (1) { //lock input_mutex //get input changes //unlock input_mutex //perform whatever you need to do } } Hope that clears things up -brad
  9. webwraith, Theres a few concepts in there I hope you have, which is basically the threading section and critical data section. To use the class, you pass a function pointer to the class that you want to be in your thread. Let me give you an example: struct { //define scene to render } renderstruct; class Render : public CThread { public: //fill in the gaps to make this work Render (renderstruct *s); ThreadProc () { //insert thread stuff while (rendering) { //lock renderstruct render stuff //unlock renderstuff } } }; class MainEngine { public: //fill in more gaps void run (); private: Render *r; }; MainEngine::MainEngine() { r->Begin (); } MainEngine::~MainEngine() { r->End (); } void MainEngine::run () { //possibly message loop? //changing values for renderstruct, so //lock renderstruct //make changes //unlock renderstruct } The thing thats missing is whats called a critical section (windows only) or a mutex, which is described in the 2nd article. To sum up what it does, it basically tells the one thread that something is accessing this chunk of memory, so wait until its unlocked and then it accesses that chunk of memory. Now I hope this example has given you a feel of the kind of flow that one must use in multithreading. There isn't a straight answer to structure, so you'll need to be a bit more specific or just play around some. -brad
  10. Galapaegos

    Embedded Console in Win32 App

    shanelaffond13, Try this You'll need to redirect stdin, stdout, and stderr to get it working properly. *Edit - Nevermind, didn't read your whole post throughly. Yeah, you probably want to use an edit box. -brad
  11. Hi Dybbuk, I think you are looking for something like this: here -brad
  12. Galapaegos

    Problem loading .DLL in C++/CLI

    Perferati, The library should be in the directory that contains your executable. If its still failing, try running
  13. Galapaegos

    zlib issue

    Also, I thought I should mention return values. I have been watching the return values and the z_stream.msg attribute closely. After I have sent all the input to the deflate function, I recieve the -5 signal telling me to switch the flush from Z_NO_FLUSH to Z_FINISH, and the msg is "buffer error". Both functions do this, so it doesn't sound like my code is messing up? I receive the return code '1' for both functions, even though the one ends prematurely. The msg attribute doesn't update, so I assume everything went well? Any thoughts/ideas? -brad
  14. Galapaegos

    zlib issue

    I'm using chunks of 4096 bytes to send to the zlib api first. Both functions return the same bytes back out. I've followed both loops until they reach the point when they differ, and it happens in the 2nd for loop. The second to last chunk is where the functions receive different output from the deflate function. Both functions receive the same amount of input, and I'd assume they would receive the same output, no? -brad
  15. Galapaegos

    zlib issue

    Hi Folks, Our file format uses zlib to compress/decompress files. Essentially, I'm trying to write a new compress/decompress routine to add my own progress meter. I have two test functions, one that loads a file and compresses it reading via 'fread/fwrite' calls, and another function that compresses by using memcpy. The memory mapping function doesn't return the same size as the other method. I need to get the memory mapping function to work, since this is the situation that is happening in my loading function. Here are the two functions for reference: file: FILE *fin = fopen (arg.c_str (), "rb"); FILE *fout = fopen (out.c_str (), "wb"); //z_stream z_stream stream; memset (&stream, 0, sizeof (stream)); int err = deflateInit (&stream, 6); if (err != Z_OK) printf ("zlib:%s\n", stream.msg); int input_length = MAGIC_NUMBER; unsigned char input_buffer [MAGIC_NUMBER]; int output_length = MAGIC_NUMBER; unsigned char output_buffer [MAGIC_NUMBER]; stream.next_in = input_buffer; stream.next_out = output_buffer; stream.avail_in = fread (input_buffer, 1, input_length, fin); stream.avail_out = MAGIC_NUMBER; int read = 1, bytescompressed = MAGIC_NUMBER, decompressed = 0; for (; ;) { if (stream.avail_in == 0) { stream.avail_in = fread (input_buffer, 1, input_length, fin); stream.next_in = input_buffer; read ++; } err = deflate (&stream, Z_NO_FLUSH); unsigned long count = output_length - stream.avail_out; if (count) { if (fwrite (output_buffer, 1, count, fout) != count) { err = Z_ERRNO; return err; } decompressed += count; stream.next_out = output_buffer; stream.avail_out = output_length; } if (err != Z_OK) break; } for (; ;) { err = deflate (&stream, Z_FINISH); unsigned int count = output_length - stream.avail_out; if (count) { if (fwrite (output_buffer, 1, count, fout) != count) { err = Z_ERRNO; return err; } decompressed += count; stream.next_out = output_buffer; stream.avail_out = output_length; } if (err != Z_OK) break; } deflateEnd (&stream); if ((err != Z_OK) && (err != Z_STREAM_END)) { printf ("zlib:%i, %s\n", err, stream.msg); inflateEnd (&stream); return err; } printf ("decompressed:%i\n", decompressed); fclose (fin); fclose (fout); memory mapped: FILE *fin = fopen (arg.c_str (), "rb"); FILE *fout = fopen (out.c_str (), "wb"); int length = filelength (fileno (fin)); int destLength = length*1.001 + 12; unsigned char *src = new unsigned char [length]; unsigned char *dst = new unsigned char [destLength]; fread (src, 1, length, fin); //z_stream z_stream stream; memset (&stream, 0, sizeof (stream)); int err = deflateInit (&stream, 6); if (err != Z_OK) printf ("zlib:%s\n", stream.msg); int input_length = MAGIC_NUMBER; unsigned char input_buffer [MAGIC_NUMBER]; int output_length = MAGIC_NUMBER; unsigned char output_buffer [MAGIC_NUMBER]; memset (input_buffer, 0, MAGIC_NUMBER); memset (output_buffer, 0, MAGIC_NUMBER); stream.next_in = input_buffer; stream.next_out = output_buffer; memcpy (input_buffer, src, MAGIC_NUMBER); stream.avail_in = MAGIC_NUMBER; stream.avail_out = MAGIC_NUMBER; int read = 1, bytescompressed = MAGIC_NUMBER, decompressed = 0; for (; ;) { if (stream.avail_in == 0) { memset (input_buffer, 0, MAGIC_NUMBER); if ((read+1)*MAGIC_NUMBER < length) { memcpy (input_buffer, src + read*MAGIC_NUMBER, MAGIC_NUMBER); stream.avail_in = MAGIC_NUMBER; read++; bytescompressed += MAGIC_NUMBER; } else if (bytescompressed == length) { stream.avail_in = 0; stream.next_in = input_buffer; read ++; } else { int size = length - read*MAGIC_NUMBER; memcpy (input_buffer, src + size, MAGIC_NUMBER); bytescompressed += size; stream.avail_in = size; read ++; } stream.next_in = input_buffer; } err = deflate (&stream, Z_NO_FLUSH); unsigned long count = output_length - stream.avail_out; if (count) { memcpy ((unsigned char*)dst + decompressed, output_buffer, count); decompressed += count; stream.next_out = output_buffer; stream.avail_out = output_length; memset (output_buffer, 0, MAGIC_NUMBER); } if (err != Z_OK) break; } for (; ;) { err = deflate (&stream, Z_FINISH); unsigned int count = output_length - stream.avail_out; if (count) { memcpy ((unsigned char*)dst + decompressed, output_buffer, count); decompressed += count; stream.next_out = output_buffer; stream.avail_out = output_length; memset (input_buffer, 0, MAGIC_NUMBER); } if (err != Z_OK) break; } deflateEnd (&stream); if ((err != Z_OK) && (err != Z_STREAM_END)) { printf ("zlib:%i, %s\n", err, stream.msg); inflateEnd (&stream); return err; } fwrite (dst, 1, decompressed, fout); fclose (fin); fclose (fout); For my test, I used a random pdf file to compress/decompress. Using the file method, the original file is 36393, and compressed its 29750. Working on the file in memory, the compressed version comes out as 28521. The last if functions 'err' returns 1, which means that Z_STREAM_END, but its not producing the same results as the other method? Any ideas, suggestions? Thanks for the help! -brad
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!