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

Fooberman

Loading Textures

9 posts in this topic

I''m trying to build a texture using a bitmap i loaded from a resource script in VC++, my code looks like this: BITMAP tex; loadBmpResource(IDB_STEEL, &tex); glTexImage2D(GL_TEXTURE_2D, 0, 3, tex.bmWidth, tex.bmHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, tex.bmBits); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glEnable(GL_TEXTURE_2D); /* drawing code goes here */ the thing is... the texture doesn''t show up on the cube i draw, i think it has a problem with the bmBits field in the BITMAP struct, but i can''t see why not. A little help here... Fooberman~
0

Share this post


Link to post
Share on other sites
Two possible solutions off the top of my head:

1.) Are you binding your textures (glBindTexture(GL_TEXTURE_2D, texture_id[0])

2.) Are you using glTexCoord2f() when drawing?

~Thek
0

Share this post


Link to post
Share on other sites
Yeah, i''m callign texture coordinates, and i''m not storing it in a texture object thing, so i dont'' need to bind it (it''s the only one). I have functions in there that will read in a bmp file and build the texture and put it in a texture object, and it works fine, except that is not what i want to do. I want to use the images i have in the resource script.
0

Share this post


Link to post
Share on other sites
First of all, I don''t think that you would want to load your bitmaps from an rc file. Second, I don''t think you can in OpenGL. It will save a lot of headaches if you just use texture objects and manually code the bitmap loading. This is near effortless if you use glaux, but some have a moral objection to it. whatever is easiest for you
0

Share this post


Link to post
Share on other sites
Bitmaps must be of size 64x64, 128x128, 256x256 etc. for OpenGL to use it. Check your image size, it must be powers of 2 ie. 2,4,8,16,32,64,128...etc. Had the same problem a few days ago...
0

Share this post


Link to post
Share on other sites
I have the following code to get a texture to sphere map from a resource file.

//----------------------------------------------------------------------------------------------------
// LoadBitmapResource:
//
// Loads a bitmap straight from resources
//----------------------------------------------------------------------------------------------------
BYTE* LoadBitmapResource(int iResource, int* iTextureWidth, int* iTextureHeight)
{
// Find the bitmap resource
HINSTANCE hInstance = GetModuleHandle(NULL);
HANDLE hBitmap = LoadBitmap(hInstance, MAKEINTRESOURCE(iResource));

// Get the details
BITMAPINFO bmInfo;
GetObject(hBitmap, sizeof(BITMAPINFO), &bmInfo);
DeleteObject(hBitmap);

// Reload and save a the data
hBitmap = LoadResource(hInstance, FindResource(hInstance,MAKEINTRESOURCE(iResource), RT_BITMAP));
BYTE* pTextureImage = (BYTE*)LockResource(hBitmap);
// Shift the pointer on to the image data itself
pTextureImage += sizeof(BITMAPINFO)-1;

// Save the bitmap dimensions
*iTextureWidth = bmInfo.bmiHeader.biWidth;
*iTextureHeight = bmInfo.bmiHeader.biHeight;

return pTextureImage;
}


//----------------------------------------------------------------------------------------------------
// LoadTexture:
//
// Loads bitmaps and converts them to textures
//----------------------------------------------------------------------------------------------------
bool LoadTexture(int iResource, GLuint* piTexture)
{
// Set up a return value and image storage
bool fSuccessful = false;

// Set the data to catch the bmp resource details
BYTE* pTextureImage = NULL;
int iTextureWidth;
int iTextureHeight;

if (pTextureImage = LoadBitmapResource(iResource, &iTextureWidth, &iTextureHeight))
{
glGenTextures(1, piTexture);

// Create Linear Filtered Texture
glBindTexture(GL_TEXTURE_2D, *piTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, iTextureWidth, iTextureHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, pTextureImage);

// Mark the success
fSuccessful = true;
}

return fSuccessful;
}


This works for me. I am only doing simple demos so I much prefer to have bmps in resource so I can have a stand alone exe/scr etc.

The full example in which this is used is on my site www.knownoffender.btinternet.co.uk - in the transparentblock demo in the openGL bit. All source is there. Hope this helps.
0

Share this post


Link to post
Share on other sites
Thanks, that helps, now i can see what i''m doing differently. I did get it to work, sorta. Instead of calling glTexImage2D i call the equivalent function that makes mipmap textures, and it works. I think maybe there''s a bug somewhere, compiler, dll file, something, cause they take the two functions take the same data, right?

Chris~
0

Share this post


Link to post
Share on other sites
It looks like your are having the same problem as the "glTexImage2D gives ''invalid value'' error" thread.
0

Share this post


Link to post
Share on other sites