• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

zippo

Texture Mapping Problem - Altering Lesson 6

7 posts in this topic

I took the code from Lesson 6 of the OpenGL tutorials found on NeHe and made a few alterations to a particular function so that I could load multiple textures (6) and then use them as sides to the cube created later on in the program. Basically, I took the LoadGLTextures function and changed it to run through a for loop and load each of the bitmaps. I made sure to change the TextureImage array to the number of bitmaps I would be loading. I then ran the function through a for loop and had it go through a switch statement to change the filename. Below is my code: int LoadGLTextures() // Load Bitmaps And Convert To Textures { int Status=FALSE; // Status Indicator AUX_RGBImageRec *TextureImage[6]; // Create Storage Space For The Texture memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL char FileName[] = "images/side1.bmp"; // Load The Bitmap, Check For Errors, If Bitmap''s Not Found Quit for(int i = 0;i<6;i++) { TextureImage=LoadBMP(FileName); Status=TRUE; // Set The Status To TRUE glGenTextures(1, &texture[i]); // Create The Texture // Typical Texture Generation Using Data From The Bitmap glBindTexture(GL_TEXTURE_2D, texture[i]); glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[i]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); if (TextureImage[i]) // If Texture Exists { if (TextureImage[i]->data) // If Texture Image Exists { free(TextureImage[i]->data); // Free The Texture Image Memory } free(TextureImage[i]); // Free The Image Structure } switch (i) { case 0: strcpy(FileName,"images/side2.bmp"); break; case 1: strcpy(FileName,"images/side3.bmp"); break; case 2: strcpy(FileName,"images/side4.bmp"); break; case 3: strcpy(FileName,"images/side5.bmp"); break; case 4: strcpy(FileName,"images/side6.bmp"); break; default: strcpy(FileName,"images/side6.bmp"); break; } } return Status; // Return The Status } That''s the function in its entirety. I compile it, and recieve no problems whatsoever. When I link it, however (using VC6), I recieve the following errors: error LNK2001: unresolved external symbol _main fatal error LNK1120: 1 unresolved externals After getting these errors when I try to link it, I now find a new folder in the "File View" of my program called "External Dependencies", with the header file "basetsd.h" in it. I''m awfully bewildered here. I''m really not sure what my problem is when I try to link it. Any advice or replies are more than welcome. Thanks! Z¡PPÕ
0

Share this post


Link to post
Share on other sites
did you use the project-file (*.dsw) from lesson6?

you have to make sure that you choose "win32 application" in VC when you create your project. if you''re using glut, you should choose "win32 console application"
0

Share this post


Link to post
Share on other sites
I just created a new project, being sure to make it "win32 console application", then added the source file, and still recieve the same error when linking. im stumped.

Z¡PPÕ
0

Share this post


Link to post
Share on other sites
Just noticed in the documentation on NeHe, and have changed it to a "win32 application". it gets by the linking now, no problem. but now i have to deal with an illegal operation error when the window tries to load up. =P

Z¡PPÕ
0

Share this post


Link to post
Share on other sites
Okay, ran it through the debugger. Seems to have a problem on the following line of code, excerted from my first post:

glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage->sizeX, TextureImage[i]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[i]->data);

You''ll notice on the first post, I had left out int i for the last 3 of the calls to TextureImage. I corrected this, but am still recieving an "Access Violation" error by the debugger for this line of code. Any thoughts? I''ll be working on it. Thanks!

Z¡PPÕ
0

Share this post


Link to post
Share on other sites
I may be wrong but I don''t think you can do it this way.
The access violation comes from the fact that you have just written one texture to memory and then you try and overwrite that same texture.
you can only call glGenTextures once
and you need to make space for all six textures not just for one that you overwirte each time.
why not try assigning a different value for each texture and then in the draw routine bind the texture to the correct plane
so we get
GLuint texture[6]; (space for all 6 textures)
load each of the six textures to a different number
after making an array for them
AUX_RGBImageRec textures[6]; //not sure if you can do this (I just had a different Aux_RGBIMAGEREC for each texture)
the do glGenTextures(6,texture)
then do the build texture part with different numbers for each texture
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, textures[1]->sizeX, textures[1]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, textures[1]->data);

hope this helps...
0

Share this post


Link to post
Share on other sites
I think it''s the memset function.

first you declare TextureImage as a array of pointers...
Thereby TextureImage becomes a pointer to the area where those six pointers are, but then you set (via memset ) TextureImage to NULL....Then upon access of TextureImage[ number ] you actually access memory at address 0....

PS. glGenTextures can be called as many times as you want ( it works for me )

0

Share this post


Link to post
Share on other sites
You''re right on the money with memset. I contacted Jeff Molofee, and he worked on the code for me. I can now see where I''ve made my mistakes. Memset now clears space for all 6 textures.
I run the LoadBMP function for each image seperately, and use them in an if statement for error checking, then run GenTextures with the parameters (6, &texture[0]). I''m a little lost why it''s &texture[0] and not &texture, but it''s no big deal, probably just an oversight by me. Then I run through a for loop and bind the textures, set the height, width and data, and all is well! Thanks immensely to Jeff Molofee for his help, and to everyone that''s replied to this post!

One step further,

zippo
0

Share this post


Link to post
Share on other sites