#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <GL/glew.h>
#include <GL/glut.h>
GLuint v,f,f2,p;
float lpos[4] = {1,0.5,1,0};
GLint loc;
GLint uvloc;
GLint samp;
GLint sach;
GLuint textureId;
GLuint rboId;
GLuint fboId;
bool fboUsed;
float vertices[8] = {-2,2, 2,2, -2,-2, 2,-2};
float heights[4] = {2,2,-2,-2};
float uvm[8]={0,0,0,1,1,0,1,1};
char *textFileRead(char *fn) {
FILE *fp;
char *content = NULL;
int count=0;
if (fn != NULL) {
fp = fopen(fn,"rt");
if (fp != NULL) {
fseek(fp, 0, SEEK_END);
count = ftell(fp);
rewind(fp);
if (count > 0) {
content = (char *)malloc(sizeof(char) * (count+1));
count = fread(content,sizeof(char),count,fp);
content[count] = '\0';
}
fclose(fp);
}
}
return content;
}
int textFileWrite(char *fn, char *s) {
FILE *fp;
int status = 0;
if (fn != NULL) {
fp = fopen(fn,"w");
if (fp != NULL) {
if (fwrite(s,sizeof(char),strlen(s),fp) == strlen(s))
status = 1;
fclose(fp);
}
}
return(status);
}
void changeSize(int w, int h) {
// Prevent a divide by zero, when window is too short
// (you cant make a window of zero width).
if(h == 0)
h = 1;
float ratio = 1.0* w / h;
// Reset the coordinate system before modifying
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// Set the viewport to be the entire window
glViewport(0, 0, w, h);
// Set the correct perspective.
gluPerspective(45,ratio,1,1000);
glMatrixMode(GL_MODELVIEW);
gluLookAt(0.0,5.0,0.0,
0.0,0.0,0.0,
1.0f,0.0f,0.0f);
}
float a =
OpenGL FBO渲染到纹理实例
最新推荐文章于 2025-05-27 15:57:25 发布