• Content count

  • Joined

  • Last visited

Community Reputation

120 Neutral

About s33d

  • Rank
  1. Mipmapping Issues

    Yeah, that's why I'm so stumped. It makes 0 sense. This is my main function: [CODE] int main(int argc, char **argv) { printf("Main entry.\n"); //initialize GLUT glutInit(&argc, argv); //display mode: color index/RGB, 1x/2x buffering glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH); //window size (width, height) glutInitWindowSize(300,400); glutInitWindowPosition(0,0); glutCreateWindow("Main Window"); //assign a clear color (R,G,B,alpha) glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //shading technique glShadeModel(GL_SMOOTH); //viewport glViewport(0,0,300,400); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0,(300/400),1.0,1000.0); glEnable(GL_DEPTH_TEST); // We enable the depth test (also called z buffer) glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); // Polygon rasterization mode (polygon filled) // //enable and load texture // glEnable(GL_TEXTURE_2D); // pyramid.texture_id = loadImg("C:\\00-raiser.bmp"); // if(pyramid.texture_id == -1){ // MessageBox(NULL,"Image not found.", "Error", MB_OK | MB_ICONERROR); // exit (0); // } //required functions glutDisplayFunc(sSimDisp); glutReshapeFunc(sSimResh); glutIdleFunc(sSimDisp); glutKeyboardFunc(keyboard); glutSpecialFunc(keyboard_s); printf("main OK, now looping.\n"); //let GLUT do things glutMainLoop(); // system("cls"); //loop forever return 0; } [/CODE] As you can see, loadImg is called just once (a ctrl-f confirms this) and it's commented out here. the loadImg function itself: [CODE] int loadImg(char *filename){ //pointer to memory for image storage unsigned char *texture; int index = 0; int index1 = 0; //pointer to file opened with "fopen" FILE* file_ptr; //mem allocation info scooped off of bitmap file BITMAPFILEHEADER fileheader; //size info scooped from bitmap BITMAPINFOHEADER infoheader; RGBTRIPLE rgb; //increment texture index for tracking texture_index++; //open file as binary, if non-existent return "-1" if((file_ptr = fopen(filename, "rb")) == NULL){ return(-1); } //read the file header fread(&fileheader, sizeof(infoheader), 1, file_ptr); fseek(file_ptr, sizeof(fileheader), SEEK_SET); //read the info header fread(&infoheader, sizeof(infoheader), 1, file_ptr); //allocate memory for image (width x height x color depth) and clean it out texture = (byte*) malloc(infoheader.biWidth * infoheader.biHeight * 4); memset(texture, 0, infoheader.biWidth * infoheader.biHeight * 4); //parse through every pixel for (index=0; index < infoheader.biWidth*infoheader.biHeight; index++){ //load a single pixel fread(&rgb, sizeof(rgb), 1, file_ptr); //store the rgb data (R, G, B, Alpha) texture[index1 + 0] = rgb.rgbtRed; texture[index1 + 1] = rgb.rgbtGreen; texture[index1 + 2] = rgb.rgbtBlue; texture[index1 + 3] = 255; //next pixel index1 += 4; } fclose(file_ptr); //just in case GLuint error = glGetError(); glGenTextures(1, &texture_index); //give texture an id glBindTexture(GL_TEXTURE_2D, texture_index); //The next commands sets the texture parameters glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // If the u,v coordinates overflow the range 0,1 the image is repeated glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // The magnification function ("linear" produces better results) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); //The minifying function error = glGetError(); //need this explained glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, infoheader.biWidth, infoheader.biHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture); error = glGetError(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 4); //need this explained // glGenerateMipmap(GL_TEXTURE_2D); error = glGetError(); //free up the texture loading memory free(texture); //return the texture id return(texture_index); } [/CODE] I'm going to try reinstalling GLEW, maybe there's something wrong with the lib I have.
  2. [CODE]glGenerateMipmap()[/CODE] doesn't play well with my application. When the call is present, it crashes before my window pops up. The function where I have it is never called (I did this for debugging), but it still causes a crash. I know it's to blame because when I comment it out, everything works fine. I heard there were issues with this call and ATI cards, but that's not my issue--again, the function with the line in it is never called, so I don't know why it's acting up (also no idea how to debug it--any breakpoint set there is never reached). It compiles correctly, so I'm pretty sure I have my libraries set up properly.
  3. [quote name='BitMaster' timestamp='1345814246' post='4972971'] In general the use of glut is discouraged because it is unmaintained and old. freeglut is a reasonable alternative and should provide all the needed symbols. I'm not familiar enough with Eclipse and C++ to debug the issue, but it should work on principle. Did you compile freeglut yourself or did you try the precompiled version? [/quote] Compiled it myself. I have a few tutorials that use it, so I know it works. They have all the libraries in a subfolder though...
  4. So I've got the SDK working and I'm trying to draw the basic triangle. [CODE] #include <gl/glut.h> void drawSub(void){ //color, dimensions, type glColor3f(0.0,0.0,0.0); //vertex, dimensions, type glVertex3f(-0.5,-0.5,-3.0); glColor3f(1.0,0.0,0.0); glVertex3f(0.5,-0.5,-3.0); glColor3f(0.0,0.0,1.0); glVertex3f(0.5,0.5,-3.0); } void sSimResh(int x, int y){ if (y == 0 || x == 0) return; //Nothing is visible then, so return //Set a new projection matrix glMatrixMode(GL_PROJECTION); glLoadIdentity(); //Angle of view:40 degrees //Near clipping plane distance: 0.5 //Far clipping plane distance: 20.0 gluPerspective(40.0,(GLdouble)x/(GLdouble)y,0.5,20.0); glMatrixMode(GL_MODELVIEW); glViewport(0,0,x,y); //Use the whole window for rendering } void sSimDisp(void){ //clear the color buffer glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); //start drawing stuff glBegin(GL_POLYGON); drawSub(); //close rendering stuff glEnd(); glFlush(); } int main(int argc, char **argv) { //initialize GLUT glutInit(&argc, argv); //display mode: color index/RGB, 1x/2x buffering glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE); //window size glutInitWindowSize(300,400); glutCreateWindow("Main Window"); //assign a clear color (R,G,B,alpha) glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //required functions glutDisplayFunc(sSimDisp); glutReshapeFunc(sSimResh); //let GLUT do things glutMainLoop(); //loop forever return 0; } [/CODE] All fine and good. In the linker section of the project, I have (under -l): glu32, user32, freeglut and opengl32. Eclipse doesn't tell me it's having any problems finding said libraries, so I assumed I was good to roll (includes checked out fine too). Despite this, i'm getting linker errors (undefined reference to `_imp__glutMainLoop@0' etc). I know my choice of IDE is less than ideal, but I use it for everything else from Java to Python, so I really don't want to install another one, though I hear the whole OpenGL deal is much smoother on VS. I'm hoping it's something I'm doing wrong as opposed to the source code needing fixing like it did earlier when I tried to build the SDK...
  5. Building the SDK

    The tutorials I use require the sdk, and I agree wholeheartedly with the tools the sdk provides. I know what the error means--it's just that I'm having a hard time believing that they screwed up integer typing, especially since a Google search shows nobody else has had this problem. The only fix I see involves editing the code which I would like to avoid at all costs--changing a single variable type could cause all sorts of cascading issues, and I would rather not deal with that.
  6. I'm trying to build the Unofficial SDK (in Windows) so I can start playing around. I was able to use premake to generate the makefiles, but running make itself is giving me issues. First, just running "make" in the gl_sdk directory does me 0 good. It says "cc" is not a recognized command, so I force it to gcc by typing "make MINGW=1 CC=gcc". That starts the build well enough, but I get this error once the glimg build starts, stopping the entire process: [quote]In file included from ../glload/include/glload/gl_4_2_comp.hpp:5, from ../glload/include/glload/gl_all.hpp:8, from source/TextureGenerator.cpp:7: ../glload/include/glload/_int_gl_exts.hpp:3037: error: integer constant is too large for "long"type[/quote] I'm pretty sure I must have done something wrong, unless whoever made the sdk really screwed up the C++ file.
  7. Making a Space Flight Sim!

    Thanks a billion! Great advice. I really like that hierarchical coordinate system idea. I'm not worried for artwork, we have quite a few doodles we're already working into models. What I do worry about more is visual effects though.Stuff like radiosity, HDRR, bloom, and after-image can really make the images pop, but, if they're anything like effects in music, doing it right would take a lot of time because of the ridiculous number of combinations you can work.
  8. Making a Space Flight Sim!

    Thanks for the response! Shortest first: I intend to allow any sort of peripherals--I have a custom cockpit thing I use for Mechwarrior I know I'll use personally, but most of my team has joypads. "Space Kraken" brings up the issue of PhysX--I think it looks good because it has soft-body dynamics as well (if I'm not mistaking it with something else). I think I agree with you on the C++ though--it's pretty much as close as you can get to workhorse C while keeping objects (let's act like objective C doesn't exist because I hate it). Ogre3D looks pretty neat, but how good is the wounding? I want to smash a lot of stuff and I know good particle effects are more or less par the course nowadays, but wounding is still a little rare.
  9. I've been tossing the idea around in my head for a couple months of making a space flight simulator. Before asking for help, I want to give a little of my background to establish the kind of advice I need. I'm an electrical engineer, particularly one of those who codes more than most. I have a good grasp on C, which basically means I can code in anything inside that umbrella--C#, C++ and my Java is excellent because of the lots of android programming I do as a hobby. I know a little python and perl and a few assembly languages. Another of my hobbies is producing music/DJing, so I have all that mess more or less sorted out in terms of equipment and software. I know a crapload of physics too, especially electromagnetic stuff (obviously). I have all the Autodesk stuff I need for making models and texturing. As far as my actual game programming experience goes, I made a thing in flash a million years ago and used some of the weaker game creation suites (like RPG maker) for some quick jokes. I drew up some sketches and some theoretical models for some sweet propulsion and weapon systems, I'm more or less ready to go. As far as my research shows, I need this major stuff: -Renderer -Physics engine -a lot of scripting -peripherals! (like joy pads) -or alternatively a complete game engine that has everything I need. Something like this ([url="http://www.shatters.net/celestia/documentation.html"]http://www.shatters.net/celestia/documentation.html[/url]) captures the fundamentals of what I want to do: realistic space travel, including the modelling of distant objects, orbits, gravity etc. A lot of different engine/renderer combinations look alluring, but I'm not sure which direction to go in because of the nature of the type of combat I'm thinking about incorporating. I want to use a lot of directed energy weapons and have realistic EM wave propagation and assorted effects, which means a lot of vectors with complex calculations everywhere all the time. In plain English, I need something really fast and really flexible that can have a lot of math shoved into it. I have a few friends working me on this too, so don't refrain from advice that points me down a labor intensive route. At this point, I want some opinions on what tools I should use. From there, I'll do a warm-up project to familiarize myself with the workflow then take on the big one.