Preparing to add texture to quad
This commit is contained in:
@@ -67,7 +67,7 @@ void DrawTexture(int x, int y, GLuint textureid,int textw,int texth) {
|
||||
glTexCoord2d(1.0,1.0); glVertex2f(1, 1);
|
||||
glTexCoord2d(0.0,1.0); glVertex2f(-1, 1);
|
||||
glEnd();
|
||||
glDisable(GL_TEXTURE_2D );
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
GLuint LoadShaders(const char * vertex_file_path,const char * fragment_file_path){
|
||||
@@ -214,12 +214,14 @@ int main(int argc, char* args[]) {
|
||||
// INIT
|
||||
|
||||
tex_jpe=LoadTexture("../img/tests/test.jpeg",&textw,&texth);
|
||||
tex_jpg=LoadTexture("../img/tests/test.jpg",&textw,&texth);
|
||||
tex_png=LoadTexture("../img/tests/test.png",&textw,&texth);
|
||||
tex_bmp=LoadTexture("../img/tests/test.bmp",&textw,&texth);
|
||||
//tex_jpg=LoadTexture("../img/tests/test.jpg",&textw,&texth);
|
||||
//tex_png=LoadTexture("../img/tests/test.png",&textw,&texth);
|
||||
//tex_bmp=LoadTexture("../img/tests/test.bmp",&textw,&texth);
|
||||
|
||||
GLuint programID = LoadShaders("trimap.vertexshader", "trimap.fragmentshader");
|
||||
printf("%d", programID);
|
||||
GLint textureLocation = glGetUniformLocationARB(programID, "texture");
|
||||
glUniform1iARB(textureLocation, tex_jpe);
|
||||
|
||||
// INIT END
|
||||
/* Loop until the user closes the window */
|
||||
@@ -229,17 +231,24 @@ int main(int argc, char* args[]) {
|
||||
timer = 0;
|
||||
/* Render here */
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glUseProgram(programID);
|
||||
|
||||
// RENDER
|
||||
if (timer<200)
|
||||
/*if (timer<200)
|
||||
DrawTexture(50,50,tex_jpe,textw,texth);
|
||||
else if (timer<400)
|
||||
DrawTexture(50,50,tex_jpg,textw,texth);
|
||||
else if (timer<600)
|
||||
DrawTexture(50,50,tex_png,textw,texth);
|
||||
else
|
||||
DrawTexture(50,50,tex_bmp,textw,texth);
|
||||
DrawTexture(50,50,tex_bmp,textw,texth);*/
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2d(0.0,0.0); glVertex2f(-1, -1);
|
||||
glTexCoord2d(1.0,0.0); glVertex2f(1, -1);
|
||||
glTexCoord2d(1.0,1.0); glVertex2f(1, 0);
|
||||
glTexCoord2d(0.0,1.0); glVertex2f(-1, 0);
|
||||
glEnd();
|
||||
|
||||
// RENDER END
|
||||
/* Swap front and back buffers */
|
||||
|
||||
Reference in New Issue
Block a user