Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


s33d

Member Since 24 Jun 2012
Offline Last Active Private

Posts I've Made

In Topic: Mipmapping Issues

30 August 2012 - 02:00 PM

Yeah, that's why I'm so stumped. It makes 0 sense.
This is my main function:
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;
}
As you can see, loadImg is called just once (a ctrl-f confirms this) and it's commented out here. the loadImg function itself:
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);
}
I'm going to try reinstalling GLEW, maybe there's something wrong with the lib I have.

In Topic: Library linking with Eclipse CDT

25 August 2012 - 09:37 AM

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?


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...

In Topic: Building the SDK

21 August 2012 - 07:46 AM

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.

In Topic: Making a Space Flight Sim!

26 June 2012 - 10:49 AM

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.

In Topic: Making a Space Flight Sim!

25 June 2012 - 06:36 AM

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.

PARTNERS