Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

134 Neutral

About ReKlipz

  • Rank
  1. Hey everyone, I was just wondering what is the best way to go about handling SDL events (for input). I've used the polling method before, where on each pass of the main game loop, you just loop through all of the backed up events using SDL_PollEvent, and handle them accordingly. Is this method the one most commonly used? I'd like to be able to create a system that will work for some sort of multiplayer FPS. Does anyone know of any good books/other resources which deal with this kind of thing, or can just respond with personal experience, or just help in general, lol. I was looking at the SDL_WaitEvent method, but I dont know how this could work without using threads, one for rendering, and one for handling the events and updating some sort of structure that the render/processing thread uses to do whatever it needs to based upon the input. Thanks!
  2. ReKlipz

    Enum - from string to GLenum

    nope, SDL also uses #define's [!-- edit --] AND enums... - so basically ignore this post, lol [-- edit --!]
  3. ReKlipz

    Enum - from string to GLenum

    mmk - thanks for the suggestions. and, as I have allready started on it, I guess I'll go with the if-else's... I dont really care about the ellegance of the code, but speed is an issue.. so I guess this will work... I noticed glGetString() and thought maybe i could do something with that, but it wasn't what i thought it was.. which is why I then made this post to see if there was a function that did what I though glGetString() would have done. But it seems there is none, so, a giant switch (or if-else's) it is. BTW jyk, thanks for your help on the camera problem I had, and if you like, I can toss ya a copy of our binary (or if your on Linux... a copy of the source so u can compile it and tell me if it works! lol) Thanks again everyone!
  4. Hey, a friend and I are writing a Quake III shader parser, and are having some trouble with the following: in the shader, there is a line as follows: blendFunc GL_ONE GL_ONE which would then be translated in to C++ as follows: glBlendFunc(GL_ONE, GL_ONE); The problem lies with the fact that the only way WE can think of converting the string version of GL_ONE ("GL_ONE" or any other enum read in from a file) to the actual enum is to make a giant switch statement, which is NOT going to happen... I was wondering how others have tackled this problem, any solutions are welcome! Thanks! ~ReKlipz [edit - typos fixed] [Edited by - ReKlipz on January 22, 2006 2:05:52 PM]
  5. ReKlipz


    And actually, it might be even easier to download the PNG library and use that (its only about 20 lines of code for me...) infact, here it is: bool captureScreen(const char *filename) { FILE *outFile; outFile = fopen(tmpFileName, "wb"); if(outFile == NULL) return false; png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if(!png_ptr) { fclose(outFile); return false; } png_infop info_ptr = png_create_info_struct(png_ptr); if(!info_ptr) { png_destroy_write_struct(&png_ptr, (png_infopp)NULL); fclose(outFile); return false; } if(setjmp(png_jmpbuf(png_ptr))) { png_destroy_read_struct(&png_ptr, &info_ptr, NULL); fclose(outFile); return false; } png_init_io(png_ptr, outFile); /* set the zlib compression level */ png_set_compression_level(png_ptr, Z_BEST_COMPRESSION); /* set other zlib parameters */ png_set_compression_mem_level(png_ptr, 8); png_set_compression_strategy(png_ptr, Z_DEFAULT_STRATEGY); png_set_compression_window_bits(png_ptr, 15); png_set_compression_method(png_ptr, 8); png_set_compression_buffer_size(png_ptr, 8192); png_set_IHDR(png_ptr, info_ptr, screenWidth, screenHeight, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); png_write_info(png_ptr, info_ptr); GLubyte *pixels = (GLubyte *)malloc(screenWidth * screenHeight * 3); if(!pixels) return false; glReadPixels(0, 0, screenWidth, screenHeight, GL_RGB, GL_UNSIGNED_BYTE, pixels); GLubyte** rowPtrs = new GLubyte*[screenHeight]; for(GLuint i = 0; i < screenHeight; i++) rowPtrs[screenHeight - i - 1] = &(pixels[i * screenWidth * 3]); png_write_image(png_ptr, rowPtrs); png_write_end(png_ptr, info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr); return true; } pretty much all of that came straight from the PNG manual... [Edited by - ReKlipz on January 16, 2006 12:10:17 AM]
  6. ReKlipz

    Resolution Enumeration & SDL

    Well, that was the glimpse of hope that I had found... The only problem i found while using it is that I dont know how to setup the PixelFormat... From what I got out of it... it only uses the BitsPerPixel part of it, and nothing else. I changed the BytesPerPixel to 8, and it still worked, changed the bitsperpixel to 64 and bytes to 8, and it said no modes... ill try it and tell you what i get from it thanks!
  7. I've been scouring the net for the past few days trying to find out the best way to enumerate Available display modes and color depths... but have found almost nothing worth while. I was hoping that you guys wouldnt mind sharing with me how you have accomplished this. Currently, I hard code a check for each 4x3 resolution for each color depth (16 24 and 32...) and use SDL_VideoModeOK() to see if it is ok. Any help would be appreciated! ~ReKlipz
  8. ReKlipz

    Draw with Vertex

    Or, if you just want a picture of a tree facing you, you could get even simpler You can draw whats called a billboard, with a texture of a tree on it... the Billboard is just a rectangle(2 trianlges) with a texture mapped to it, and when the camera changes(the angle at which you are looking at the tree), you just turn the rectangle to be always facing you... very simple, and very quick... although you will have to find out how to rotate the rectangle, but that'll be the hardest part...
  9. ReKlipz

    gluBuild2DMipMaps() problems...

    Well, I CAN do that, but I'm writing an engine, where even though no one else would really be using it(prob wont go public), I'd like it to be realisic, and not all the textures it gets will be ^2... in fact, the textures used by Quake III are not... so I feel I should support them, and why wouldn't you, if all it takes is a simple resize function... get what I mean? and as for the glTexImage2D(), If I want to make a level 3 mipmapped image(original img = 0, second smallest = 1 third smallest = 2, last = 3), how do i do that? like this?: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, texels) glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA8, w0, h0, 0, GL_BGRA, GL_UNSIGNED_BYTE, texels0) glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA8, w1, h1, 0, GL_BGRA, GL_UNSIGNED_BYTE, texels1) glTexImage2D(GL_TEXTURE_2D, 3, GL_RGBA8, w2, h2, 0, GL_BGRA, GL_UNSIGNED_BYTE, texels2) or do i somehow have all the imagedata in concession somehow and call this: glTexImage2D(GL_TEXTURE_2D, 3, GL_RGBA8, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, texels)?
  10. ReKlipz

    Texture Manager Info

    OK, thanks for all your help I should have this thing up n runnin by the weekend(I've got work all night tonight, and school at the moment...), and If you'd like, I could post my engine so far(although there technically wouldn't be anything visually different from how it is now, lol) I think this manager will be quite an improvement to our engine, I really appreciate your help. Thanks again! ~ReKlipz <--
  11. ReKlipz

    Texture Manager Info

    thanks for the info And I was wondering if just supplying a name was a good idea, I was thinking about MD5ing the data or creating some sort of hash, but thought it might take too long, and just not worry about it And for the part about the manager needing to know when to delete textures not being used, how would you know whether or not to delete it, I mean, lets say theres a model that uses texture blingbling.tga I load blingbling.tga into video memory, and get a texID, I pass the tex ID to the model instance for use when rendering, and then, when say the model gets destroyed, i call unLoadTex(texID here), and if noOne else has ties to the same texID, then I can safely delete it, correct? thats what you mean by removing textures not in use, not actually having the texture manager have lets say "AI", and remove it after 10 secs of not being bound... and on another note, (I'm using SDL to create the OGL context BTW) how do I find out the amount of video memory available, not only the total mem, but say I wanted to check it periodically throughout loading textures(just as an example, not that you would.., or wouldn't) and yet one more Question, is there anything wrong with using gluBuild2DMipMaps(), as opposed to generating the mipmaps on my own in the texture manager, and then using glTexImage2D()?(from what I understand, to make mipmaps in texImage2D(), you put the mipmaps in the data that you pass to texImage2D, and then tell it the number of mipmaps in the level param... this correct?) Thanks so much bpoint, that really helped straighten things out a bit... ~ReKlipz
  12. ReKlipz

    Texture Manager Info

    mmk So, this is what I'm thinking of doing: the texture manager may be a singleton(or just a seperate file with functions and storage vars declared, pretty much the same thing), will have the following functions: int loadTex(filename); pass in FileName, returns texID of texture, if allready loaded, returns the currently loaded texID bool unLoadTex(texID); bool unLoadAll(); and maybe bool unLoadTex(filename); should I assign my own texID's or let OpenGL do it for me? any advantage to doing it myself besides the control of assignment?
  13. OK, I've currently started creating a texture manager. The way it works is like so: You make a new mn_Texture struct which holds the width, height, format, texture id passed back by OGL, and the location of the img data itself(which winds up getting deleted neways...), and pass it to a loadTex() function along with a file name of a texture to load, this function automatically finds the extension, and calls the appropriate function to load that type, and then if that succeeds, it calls a function that has OGL create the texture, and stores the tex ID. My question is, this isnt quite so much a texture manager as it is a texture loader... What exactly would a texture manager do? If I pass the same filename to the loadTex function, it will load the texture twice into memory, and get another texID for it from OGL... Is a texture manager supposed to keep this from happening, and just return the allready made texID? I would like to know what your texture managers do, and what mine SHOULD do Thanks a bunch! ~ReKlipz
  14. ReKlipz

    gluBuild2DMipMaps() problems...

    Couldn't I just resize them using either the libpng(if the image is a png), or libjepg(if the image is a jpg), or use OGL to do it if it is something else(TGA)... also, if anyone knows where i can find how to properly use glTexImage2d().. in replacement of glubuildmipmaps.. great thanks goes out to you also, lol ~ReKlipz
  15. ReKlipz

    gluBuild2DMipMaps() problems...

    Quote:... answers to why the leak would cause the crash would be appreciated also(im fairly new to c++, this engine is my first endeavour with the language, but I have had some experience with DirectX 8 in VB, and that just wasn't cuttin' it, lol) ~ReKlipz bump
  • 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!