Jump to content
  • Advertisement


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


Description of my problem

This topic is 5648 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Resources: 80 to 100 .raw images files The Tasks: Multi texture them onto a quad, With tranparency. Set a finite width for each image displayed (they must be in order) Rotate it in 360 degrees top down and sides. I got a routine to load a raw file... i tried to change it to load multiple raw files but it didn''t work. It gives error when executed the .exe file. GLuint LoadTextureRAW( const char * filename, int wrap ) { GLuint texture[100]; int width, height; BYTE * data; FILE * file; // open texture data file = fopen( filename, "rb" ); if ( file == NULL ) return 0; // allocate buffer width = 512; height = 512; data = malloc( width * height * 3 ); // read texture data fread( data, width * height * 3, 1, file ); fclose( file ); // allocate a texture name glGenTextures( 100, &texture[textcount] ); // select our current texture glBindTexture( GL_TEXTURE_2D, texture[textcount] ); // select modulate to mix texture with color for shading glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); // when texture area is small, bilinear filter the closest MIP map glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST ); // when texture area is large, bilinear filter the first MIP map glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); // if wrap is true, the texture wraps over at the edges (repeat) // ... false, the texture ends at the edges (clamp) glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap ? GL_REPEAT : GL_CLAMP ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap ? GL_REPEAT : GL_CLAMP ); // build our texture MIP maps gluBuild2DMipmaps( GL_TEXTURE_2D, 3, width, height, GL_RGB, GL_UNSIGNED_BYTE, data ); // free buffer free( data ); return texture[textcount]; } any advice?

Share this post

Link to post
Share on other sites
It also looks like you are generating space for 100 textures each time you load one.

Try changing the lines

// allocate a texture name
glGenTextures( 100, &texture[textcount] );


// allocate a texture name
glGentextures(1, &tID);
return tID;

then when you call the function type:
texture[textcount] = LoadTextureRAW(filename, wrap);

I assume texture[] is a UINT array.

if this works let me know.

Share this post

Link to post
Share on other sites
It gives me the error below, when i already have included the lib of glu32.lib glaux.lib opengl32.lib glut32.lib

gltexture.obj : error LNK2001: unresolved external symbol _glGenTexture
Debug/fffff.exe : fatal error LNK1120: 1 unresolved externals

Share this post

Link to post
Share on other sites
You have the header files listed in your #includes<> and also added the .lib files to your project? I dont'' use the linker I add files to my project in MSVC++6 and let the IDE do the linking.

Signatures are lame!! =)

Share this post

Link to post
Share on other sites
yup i done that...
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <stdio.h>

And under project-> settings-> glu32.lib glut32.lib glaux.lib opengl32.lib

Share this post

Link to post
Share on other sites
solved it...
my declaration above is GLuint.
that result in the error...


will be trying out now Bobby_D... keep u posted when i am done

Share this post

Link to post
Share on other sites
For Some reason, my display always ends with a white screen.
Is there anything wrong which explain why i got a white screen display after running the program?

below is the display code.

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int iCmdShow )
HWND hWnd;
MSG msg;

// UINT texture[100];
//float theta = 0.0f;

// register window class
wc.style = CS_OWNDC;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
wc.lpszMenuName = NULL;
wc.lpszClassName = "GLSample";
RegisterClass( &wc );

// create main window
hWnd = CreateWindow(
"GLSample", "3D Model",
0, 0, 512, 512,
NULL, NULL, hInstance, NULL );

// enable OpenGL for the window
EnableOpenGL( hWnd, &hDC, &hRC );

// load our texture
for (counter=0; counter <6; counter ++){
texture[counter] = LoadTextureRAW( "[counter].raw", TRUE );
//texture[counter] = LoadTextureRAW( "texture.raw", TRUE );
//counter ++;
// program main loop
while ( !bQuit ) {

// check for messages
if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) {

// handle or dispatch messages
if ( msg.message == WM_QUIT ) {
bQuit = TRUE;
} else {
TranslateMessage( &msg );
DispatchMessage( &msg );

} else {

// OpenGL animation code goes here

glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );

// setup texture mapping
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, texture[counter] );

//glRotatef( theta, 0.0f, 0.0f, 1.0f );
glBegin( GL_QUADS );
glTexCoord2d(0.0,0.0); glVertex3d(-1.0,-1.0,0.2);
glTexCoord2d(1.0,0.0); glVertex3d(+1.0,-1.0,0.2);
glTexCoord2d(1.0,1.0); glVertex3d(+1.0,+1.0,0.2);
glTexCoord2d(0.0,1.0); glVertex3d(-1.0,+1.0,0.2);

SwapBuffers( hDC );

// theta += 1.0f;



// free the texture
FreeTexture( texture[counter] );

// shutdown OpenGL
DisableOpenGL( hWnd, hDC, hRC );

// destroy the window explicitly
DestroyWindow( hWnd );

return msg.wParam;


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!