Texturing

Started by
6 comments, last by Ali_nz 17 years, 11 months ago
Hi guys, Pretty much a newbie here so bear with me. I will try to explain what I am trying to do as best as I can. I am in OpenGL and VC++ Express. I am trying to create a instrument used in a airplane called a Artifical Horizon - or the glass cockpit version is called a PFD. Picture at: http://www.flypfc.com/project%20magenta/jpegs/PFD%20BOEING%20ENH.jpg I have created a 640x480 window - although it can be resized. I have put a quad in the window. The top half of the quad represents 180 degress and the bottom half represents 180 degrees. Now I have successfuly done the following: * Created a quad 36 heigh x 1 wide (36 because ultimately its divided into 360 degrees) * Textured the quad *Applied a mask so that only about 30 degrees worth is shown at one time one of the problems i have run into is that where the blue and brown meets (see pic) their is a 1 pixel wide white line running between them. I created a bmp 256 wide and 4096 heigh - a huge texture. I figured that if I created the texture any smaller the stretching would make the 1 px wide white line bigger than 1 px - or am I missing something here? Also I find that the 1 pixel wide white line tends to get aliasing - is their a way to fix aliasing on textures? What program would be good for making textures? I have been using PShop, but its not very good for exact placement of thin lines. I was also googling on this subject the other day and saw something about Ortho2d where you can make the coordinates directly relate to pixels? This might be good for this project? Cheers -Al
Advertisement
I can't see any specific need to use texturing to do the drawing, not from that image anyway. Its all vectors and polygons.
Orthographic projection just means that no perspective is applied to points before rasterizing them. Normally in perspective projection the x and y coordinates are divided by the z coordinate, which has the effect of making objects further away appear smaller on the screen.
Screen pixels do not necessarily map directly to screen pixels in orthographic projection, as all normal transforms can still be applied (scaling, rotation etc).
I would definitly be using orthographic projection to draw a 2D interface like this though.
To get rid of the aliasing on textures make sure you have the correct filtering set.
If you use vector drawing in you program to draw the interface you can apply antialiasing directly to the polygons and lines. I think it wouldn't probably look clearer, use less memory, and maybe run faster.
Its only a small detail, but what about the rounded edges of the blue/brown - surely you need a mask to do that?

-Al
Not really, you can draw curves using lines and cos+sin, but i would use a texture for all the bits in that image that are black (i.e the background). Then you can use it as a mask and make it different textures depending on what type of plane the user is flying (wood, steel, black plastic etc).
Right. Do you have a good tutorial somewhere on drawing this kinda of thing?

Cheers

-Al
Sorry which type of thing, curves, masking textures or just cockpit displays in general?
If you mean curves then:
    // draw curved corners    degInc = 90.0f/(float)segments;    // top right 0 deg to 90 deg    glBegin(GL_TRIANGLE_FAN);        glVertex2f(xCenter, yCenter);        for(i=0, deg=0.0f; i<=segments; i++, deg+=degInc)        {            x = xCenter + cos(DEG_TO_RAD(deg)) * radius;            y = yCenter - sin(DEG_TO_RAD(deg)) * radius;            glVertex2f(x, y);        }    glEnd();

Masking textures, i really just mean use the alpha channel.
My guess for drawing the artifical horizon would be that you need to find out 2 values for the plane: the inclination (pitch) and the roll. Once you have those you can setup your code to firstly transform vertically by the inclination, then rotate by the roll, and draw the horizon and inclination starting from the middle of the display and going upwards (in local coordinated).
Thanks bluntman,

Trying out a basic version of it with vectors now :-)

-Al
Hmmm, any idea why this doesnt work:


int DrawGLScene(GLvoid)									// Here's Where We Do All The Drawing{	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear Screen And Depth Buffer	glLoadIdentity();									// Reset The Current Modelview Matrix	glTranslatef(0.0f,0.0f,-5.0f);						glBegin(GL_QUADS);								// Draw A Quad		glColor3f(0.0f, 0.6f, 0.796f);		glVertex3f(-1.5f, 18.0f, 0.0f);				// Top Left		glVertex3f( 1.5f, 18.0f, 0.0f);				// Top Right		glVertex3f( 1.5f, 0.0f, 0.0f);				// Bottom Right		glVertex3f(-1.5f, 0.0f, 0.0f);				// Bottom Left		glColor3f(0.694f, 0.4f, 0.0f);		glVertex3f(-1.5f, -18.0f, 0.0f);			// Top Left		glVertex3f( 1.5f, -18.0f, 0.0f);			// Top Right		glVertex3f( 1.5f, 0.0f, 0.0f);				// Bottom Right		glVertex3f(-1.5f, 0.0f, 0.0f);				// Bottom Left	glEnd();	glBegin(GL_LINES);		glColor3f(1.0f, 1.0f, 1.0f);		glVertex3f(-1.5f, 0.0f, 0.0f);		glVertex3f(1.5f, 0.0f, 0.0f);		glVertex3f(-0.6f, 1.0f, 0.0f);		glVertex3f(0.6f, 1.0f, 0.0f);	glEnd();	glEnable(GL_BLEND);								// Enable Blending	glDisable(GL_DEPTH_TEST);						// Disable Depth Testing	glBlendFunc(GL_DST_COLOR,GL_ZERO);				// Blend Screen Color With Zero (Black)	glBindTexture(GL_TEXTURE_2D, texture[1]);							// Move Right 3 Units	glBegin(GL_QUADS);													// Draw A Quad		glTexCoord2f(0.0f, 1.0f); glVertex3f(-2.0f, 2.0f, 0.0f);		// Top Left		glTexCoord2f(1.0f, 1.0f); glVertex3f( 2.0f, 2.0f, 0.0f);		// Top Right		glTexCoord2f(1.0f, 0.0f); glVertex3f( 2.0f,-2.0f, 0.0f);		// Bottom Right		glTexCoord2f(0.0f, 0.0f); glVertex3f(-2.0f,-2.0f, 0.0f);		// Bottom Left	glEnd();		glDisable(GL_BLEND);	return TRUE;										// Keep Going}



I just get a black screen.

It worked with the textures, but if I try to apply the bmp mask to a colored quad as opposed to a textured quad it doesnt work????

-Al

This topic is closed to new replies.

Advertisement