Skip to main content
gamedev.net
🔒 Locked

Help on using texture mapping using classes

Started by Do0d Jan 6, 2001 at 7:13 AM 6 replies 700+ views
Original Post
Do0d
Do0d
Well ive recently converted one of Nehe''s tutorials using classes to display textremapped fonts it all worked until i decided to move the textrure loading code from the main .cpp file into another class now my font class cant find the texture class beacuse it isnt in the main.cpp file any ideas as to how i might get my font classs to be able to see my textures class or is there a better way to do this?
RealityMonster
RealityMonster
even I have been conerting NeHe''s code to classes. Classes kickASS!. regarding your problem, if your texture class header is Texture.h, include the header in your font class file and ou shld be able to use it. Just a thought but wouldnt it be better to make the Font class totally independent with its own tex loading routine so tht there are no dependencies like this?

Geocyte
Geocyte
I recently started coding with classes and this is how I arranged them: I don''t like globals so I have a main class which includes the initialise, execute and terminate functions for the application - an object of this class is my only global variable and the only global functions are the windows callback and winmain. Public data members of this class behave very much like they are global and this is where I stored my textures, so any function can access them via main.texture[0]- the main class also contains the texture loading functions. I then have a seperate textureObject class which contains data and functions for texturing a triangle e.g.

class textureObject {
private:
unsigned int textureCount;
unsigned int* textureImageID;
vector* xTexCoords;
vector* yTexCoords;

// also each texture needs blending parameters.
}
textureCount defines how many textures are in this group, a pointer to an array of ID numbers indicates which textures they are. A ''vector'' is a class containing an array of four floats. Each texture in the group is associated with two vectors - one holds the X texCoords for each point on the triangle, the other holds the Y texCoords. Anything might need access to a texture image so it makes sense to me either to keep them global or have them stored in an object which is. If you wanted to, however, you could always store your textures in their own class then pass your font function a pointer to your array of textures and access them that way, but that sort of thing always seems silly to me, even though it could be said to be better coding practice. I prefer direct access.




Geocyte Has Committed Suicide.
Geocyte Has Committed Suicide.
RealityMonster
RealityMonster
very much like how i went about it. However i couldnt/dint want to ''class''ify the main win32 nightmare. So i have a main cpp file with lots of global objects. Same effect but not too elegant. Well as soon as i grasp win32 properly...
I see you have a texture ''management'' class. I opted for a more basic Texture class for a single texture but i was thinking of building the management class on top of this.

My Primitive class has the xyz vector and the uv coords.

Classes are soooo cool!. So easy to structure a program , maintain and reuse code .... i could just go on!
Do0d
Do0d
Thanx guys
but umm ive found a way around it
it was all bout the file being able to see the initiased class so i had to add

extern CScreenText *ScreenText;

so that the class was aware of the other one
and i was also seeing if there was a better way of doing it
anyways
umm the reson i done the font and texture loading thing seperate is so that the font class can be used anywhere
with anyones code
all that it needs is a texture to be applied to it when it gets built
so now all ive got to do is expand the texture loading class for different types of textures and then pass the textures along to other classes which require the textures
thats the way i thought of it
im still a complete beginner at both OpenGL and VC++. So far learinng this oGL stuff has helped me more with coding then anything else
anyways thanx again i really appriciated it
zeotron
zeotron
Hi guys,
I have made a basic framework for opengl that is C++/Classes which includes texture, input, sound, logging, a timer, and writing text to the screen. It seems like the stuff you guys are looking for. You can download it at my website http://welcome.to/zacksmith/
I hope this helps.

Zack

A moment enjoyed is not wasted.
-Gamers.com
A moment enjoyed is not wasted. -Gamers.com
Do0d
Do0d
kewl thanx ill check it out
europa
europa
You also might want to check out Tachyon @ http://www.particlestreamstudios,com/tachyon.html. Tachyon is a C++ class library that encapsulates the basic OpenGL and widows functions. It also supports the most common image file formats and 3ds models. Check it out.

---
Visit Particle Stream Studios - Home of Europa, Tachyon and winSkin
---Visit InterfaceFX - Home of Europa, Tachyon and winSkin

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.