PDA

View Full Version : texture un-paste



beginnertom
03-01-2010, 06:53 AM
hi.
i had draws a square . a very simple square with green color.
i want to put it into a picture .but i failed ,here is my code.
could you help me fix my mistake .thank you.

#include <GL/glut.h>
#include <stdlib.h>
#include "stdio.h"
#include "math.h"
#include "rgb.h"
RGBImageRec *earthImage = NULL;

GLuint texture;

void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH);

glEnable(GL_TEXTURE_2D);
earthImage = rgbImageLoad("water2.bmp");
if (earthImage == NULL)
{exit(1);}
glGenTextures(1, &amp;texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D,0,3,earthImage->sizeX,earthImage->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE,earthImage->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);


glEnable(GL_TEXTURE_2D);

glEnable(GL_DEPTH_TEST);
}

float x[4][2]={{-1,-1},{1,-1},{1,1},{-1,1}};
void display(void)
{

glEnable(GL_TEXTURE_2D);

glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glTranslatef(0,0,-10);
glBindTexture(GL_TEXTURE_2D, texture);
glPushMatrix ();

glColor3f(0,1,0);


glBegin(GL_QUADS);

glTexCoord2f(0.0f, 0.0f);
glVertex2fv(x[0]);

glTexCoord2f(1, 0);
glVertex2fv(x[1]);

glTexCoord2f(1.0f, 1.0f);
glVertex2fv(x[2]);

glTexCoord2f(0, 1.0f);
glVertex2fv(x[3]);

glEnd();
glPopMatrix();
glFlush();
glutSwapBuffers();



}

void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
gluPerspective(30.0, (GLfloat) w/(GLfloat) h, 1, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}


void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 27:
exit(0);
break;
}
glutPostRedisplay();
}

int main(int argc, char** argv)
{
glutInit(&amp;argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);

glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}

beginnertom
03-02-2010, 07:05 AM
here i found some fun .paste blow it
.
In computing, an image scanner is a device that optically scans images (printed text, handwriting, or an object) and converts it to a digital image which is transferred to a computer. Among other formats, flat, drum, and film scanners exist, and most of them support RGB color. They can be considered the successors of early telephotography input devices, which were able to send consecutive scan lines as analog amplitude modulation signals through standard telephonic lines to appropriate receivers; such systems were in use in press since the 1920s to the mid 1990s. Color telephotographs were sent as three separated RGB filtered images consecutively.

Currently available scanners typically use charge-coupled device (CCD) or contact image sensor (CIS) as the image sensor, whereas older drum scanners use a photomultiplier tube as the image sensor. Early color film scanners used a halogen lamp and a three-color filter wheel, so three exposures were needed to scan a single color image. Due to heating problems, the worst of them being the potential destruction of the scanned film, this technology was later replaced by non-heating light sources such as color LEDs.

beginnertom
03-02-2010, 07:15 AM
http://hellotom3389.blog.com/files/2010/02/green.jpg

beginnertom
03-03-2010, 09:46 PM
sometime help always make me happy.i just vote for my topic

beginnertom
03-03-2010, 09:52 PM
when i had downloaded a coder .first things is to compile it.if it not .second things is to ask other.scalerf light .yes i dont understand . ask for help it always help you understand what you download but i suggest you first compile it .
not comile not work.as you see i am a really beginner