Jump to content
  • Advertisement

ReKlipz

Member
  • Content Count

    72
  • Joined

  • Last visited

Everything posted by ReKlipz

  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. 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]
  3. ReKlipz

    Enum - from string to GLenum

    nope, SDL also uses #define's [!-- edit --] AND enums... - so basically ignore this post, lol [-- edit --!]
  4. 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!
  5. ReKlipz

    screenshot

    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. OK, I'm currently adding texturing to Quake III maps that I have loaded... when I call gluBuild2DMipMaps with either of these 2 textures: textures/gothic_door/km_arena1columna2R.jpg textures/gothic_door/km_arena1columna2L.jpg it crashes... their dimensions are as follows: 66 x 640 for both I have ABSOLUTELY no idea as to why it crashes... IDK if its an internal file error, and my jpg loader doesnt recognize it(It should, it is libJPEG for christ sake), and the image loads in Photoshop just fine, so I'm sure its not the file. I read somewhere that glBuild2DMipMaps will automatically resize non ^2 textures to ^2 textures... is this correct? also, i believe there are other textures for other maps that are NOT ^2, and they work fine(I believe this is right, if I remember correctly...) yes, actually theres quite a bit of them, 320 x 768, 256 x 640 and more, and they all load fine If anyone has any clue as to what may be causing this problem, feel free to help! Thanks a bunch! ~ReKlipz PS, i can post the images themselves if someone wants to do testing with them, or if you have quake III, you can open the game00.pk3 file, and browse to the textures/gothic_door/km_arena1columna2R.jpg or textures/gothic_door/km_arena1columna2L.jpg and use that... thanks again!
  11. 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 <--
  12. 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
  13. 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
  14. 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?
  15. 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
  16. 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
  17. ReKlipz

    gluBuild2DMipMaps() problems...

    well, srcformat and internal format are both being set to GL_RGB... And now, for some weird reason, It works just fine, and loads the images... the only thing I changed was a memory leak in the TGA loader... but that shouldnt matter at all... but yet, when I comment out the free(colorbuffer) line that was the fix... It crashes... this is strange, but there is a TGA being loaded before it... So I guess it wasnt a problem with gluBuild2DMipMaps in itself, some memory error was the case, I did check to see that gluBuild2DMipMaps was returning 0, and if not, log the error, but it never got that far, it crashed inside of gluBuild2DMipMaps... bool CreateGLTexture(mn_Texture *texture) { glGenTextures(1, &texture->texID); glBindTexture(GL_TEXTURE_2D, texture->texID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gluBuild2DMipmaps(GL_TEXTURE_2D, texture->format, texture->width, texture->height, texture->format, GL_UNSIGNED_BYTE, texture->imageData); if(texture->imageData) free(texture->imageData); return true; } thanks again for all your help! 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 hade soem experience with DirectX 8 in VB, and that just wasnt cuttin it, lol) ~ReKlipz
  18. ReKlipz

    gluBuild2DMipMaps() problems...

    OK, I just found a page that talks about glTexImage2D() I am thinking about switching to use that... and using glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE) to generate mipmaps... the post said that: so as long as your driver supports OGL 1.4 (all Geforce and Radeons do with latest drivers), you can use it... (http://www.gamedev.net/community/forums/topic.asp?topic_id=252132), is this true? my question is, should I convert to use glTexImage2D, and if so, what should i pass in for the level parameter of glTexImage2D... thanks yet again! ~ReKlipz
  19. OK, heres the scoop: A friend and I have a partially working OpenGL engine that we've been working on currently it supports the following: Quake III BSP maps(doesnt have bezier done yet, and doesnt do textures fully right, doesnt have collision detection or anything) Doom III(Quake IV) MD5 models(can't deform the meshes or anims yet, but can play em) and thats about it for importing things like that... What we were thinking of doing for our physics engine was this: There is the main gravity source(earth's gravity) which always pulls you down(is lets say always 100 units below you...) and then we were thinking of adding multiple gravity sources support, so like an entity in the map could be like FUNC_GRAV or something, and it would pull stuff toward it... What we are currently stuck on is the actual moving of the models(objects) toward the gravity source, we can do it along an axis(2D), but were unable to find ANY sources that explain how to move toward a gravity source along a 3D path... does that make sense? If anyone can help it would be GREATLY appreciated. Thanks for any help in advance! ~ReKlipz
  20. ReKlipz

    Physics Engine Questions...

    OK, thanks for the help, I'll have to check it out and see what I can muster up... Rating ++ OK, now that was weird, I rated you somewhat helpful / friendly, and it made your rating go down... totally not what I wanted... I didn't do extremely, just cause it wasnt extremely... but it was helpful... IDK, sry bout that though...
  21. ReKlipz

    OpenGL SDL and OpenGL

    I'm currently using SDL for my OpenGL engine, the main reason being that I would eventually like to go crossPlatform(especially if VISTA does what it's said to do) SDL has a SDL part(its own 2D library), and it also provides functions to create an OpenGL context(cross platform too, on windows, linux, and others), and i believe the other parts of SDL are cross platform too(input sound, the works) SDL allows you to set up an OpenGL context(the OpenGL window), and OpenGL will take care of using hardware accelleration, depending on the current video card settings and what you pass to SDL to create it... you then use OpenGL in basically the exact same way you would as if you set up the OpenGL context using the windows functions.(you use the SDL_GL_SwapBuffers() command to swap buffers(back and front), as oppose to writing this yourself...) and that's that! simple, reliable, and crossplatform! ~ReKlipz
  22. OK, heres the deal I cannot for the life of me, get log4cpp to build using Dev-CPP I was hoping someone here could either a) show me how to compile it so that I can use it, or b) send me their binaries to that I can use them I am using Windows( XP Pro SP2 blah blah blah ) thank you so much for any help ~ReKlipz
  23. ReKlipz

    The Doom 3 Models?

    A friend and I have implemented MD5's in our game, we render 8 fatty's and a single bernie all in the middle of our screen, and they all run through an animation at the same time... and I've a Radeon 9600 256MB Pro(supposedly a pro...) and i get 60-70 FPS... but, i only apply the defuse map and not the normal maps or specular maps ATM, but, it should only drop a bit, not to a drastic 20-30 FPS
  24. hey, i gota question that looks like it may have been answered allready, but here goes: i need to be able to render lines over top of a mesh(render the joints) and have them just be on top of that mesh and not use glu, just the base GL.h lib... this possible and if so how?
  25. OK, just recently I added TGA and JPG support to my texture loader, and now have added PNG support, but theres a problem... When I load a PNG with transparency values(an alpha channel), and convert it to red byte, blue byte, green byte, alpha byte in mem for opengl, it works fine but the weird thing is that the libPNG for some odd reason adds a background to it, and merges anything that is semi transparent with the background, therefore I no longer have a 32bit image(well i do, just the rgb changed also, and the alpha went to full opaque), rendering PNG pretty much useless for 32bit textures... I was wondering if there was anyway around this, or if others have noticed it too I downloaded some openglpng library to load png's and it said it supported 32 bit, and it did the exact same thing.. thanks!
  • 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!