• Advertisement

Archived

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

Description of my problem

This topic is 5561 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
Advertisement
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] );

to

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

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

I assume texture[] is a UINT array.

if this works let me know.


Share this post


Link to post
Share on other sites
oh and you''ll also have to change all the occurences of texture[textcount] in the function to tID!

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

thanks

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 )
{
WNDCLASS wc;
HWND hWnd;
HDC hDC;
HGLRC hRC;
MSG msg;
BOOL bQuit = FALSE;

// 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",
WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE,
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 );
glClear( GL_COLOR_BUFFER_BIT );

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

glPushMatrix();
//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);
glEnd();
glPopMatrix();

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
how can your for loop work when the counter isn't even declared as a type?

// UINT texture[100];
//float theta = 0.0f;
You have these variables commented out?

texture[counter] = LoadTextureRAW( "[counter].raw", TRUE );
I have never seen this syntax "[coutner].raw? you should probably have:

texture[counter] = LoadTextureRAW( "texture[counter].raw", TRUE );


Signatures are lame!! =)

[edited by - Mars_999 on December 5, 2002 3:09:34 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by MARS_999
how can your for loop work when the counter isn''t even declared as a type?

// UINT texture[100];
//float theta = 0.0f;
You have these variables commented out?

texture[counter] = LoadTextureRAW( "[counter].raw", TRUE );
I have never seen this syntax "[coutner].raw? you should probably have:

texture[counter] = LoadTextureRAW( "texture[counter].raw", TRUE );


Signatures are lame!! =)

<SPAN CLASS=editedby>[edited by - Mars_999 on December 5, 2002 3:09:34 PM]</SPAN>



Oh... i declared // UINT texture[100]; as global variable.
and

texture[counter] = LoadTextureRAW( "counter.raw", TRUE );

since my files name are 1.raw, 2.raw .... 100.raw

Share this post


Link to post
Share on other sites
quote:
texture[counter] = LoadTextureRAW( "counter.raw", TRUE );

since my files name are 1.raw, 2.raw .... 100.raw


If this is the exact code you used, it couldn''t work, because you''re trying to load a texture called "counter.raw" each time. You need to convert the variable counter to a string and then concatenate ".raw" at the end.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Demosthenes
[quote] texture[counter] = LoadTextureRAW( "counter.raw", TRUE );

since my files name are 1.raw, 2.raw .... 100.raw


If this is the exact code you used, it couldn''t work, because you''re trying to load a texture called "counter.raw" each time. You need to convert the variable counter to a string and then concatenate ".raw" at the end.



...
#include <stdio.h>
...
char string[32];
...
// load our texture
for (counter=0; counter <6; counter ++)
{
sprintf(string,"%d.raw",counter);
texture[counter] = LoadTextureRAW( string, TRUE );
}


anyway... this is not the issue now. i have solved this irritating problem. thanks..

now i need to change my dataset which comes in .raw format to .tga format and use those files for my existing program.
It must be a better idea to get a existing converter program which i need help on getting than altering my tga.cpp and tga.h codes to load .raw format files.

Share this post


Link to post
Share on other sites
quote:
Original post by Demosthenes
[quote] texture[counter] = LoadTextureRAW( "counter.raw", TRUE );

since my files name are 1.raw, 2.raw .... 100.raw


If this is the exact code you used, it couldn''t work, because you''re trying to load a texture called "counter.raw" each time. You need to convert the variable counter to a string and then concatenate ".raw" at the end.



...
#include <stdio.h>
...
char string[32];
...
// load our texture
for (counter=0; counter <6; counter ++)
{
sprintf(string,"%d.raw",counter);
texture[counter] = LoadTextureRAW( string, TRUE );
}


anyway... this is not the issue now. i have solved this irritating problem. thanks..

now i need to change my dataset which comes in .raw format to .tga format and use those files for my existing program.
It must be a better idea to get a existing converter program which i need help on getting than altering my tga.cpp and tga.h codes to load .raw format files.

Share this post


Link to post
Share on other sites

  • Advertisement