void CCRenderer::setup(const bool lighting, const bool clear) { if( !createContext() || !loadShaders() ) { return; } createFrameBuffer(); // Screen dimensions setupScreenSizeParams(); lightingEnabled = lighting; clearScreenRequired = clear; updatingOrientation = 0; }
bool GLSLWaveformRendererSignal::onInit() { m_loadedWaveform = 0; if (!m_frameShaderProgram) m_frameShaderProgram = new QGLShaderProgram(); if (!loadShaders()) { return false; } createGeometry(); if (!loadTexture()) { return false; } return true; }
void GLWidget::initializeGL() { initializeOpenGLFunctions(); qDebug() << format(); glDisable(GL_MULTISAMPLE); glDisable(GL_BLEND); glDisable(GL_DEPTH_TEST); glDisable(GL_STENCIL_TEST); glDisable(GL_SCISSOR_TEST); glClearColor(0.0, 0.0, 0.0, 1.0); data.program = glCreateProgram(); loadShaders(fileList[data.currentFile]); updateTitle(); }
void grass_tech::init(){ //load and compile shaders loadShaders(); //link all shaders together initShaderProgram(); //get the variables from the shaders initShaderLocations(); tex = new Texture("../bin/terrain/grass.png", GL_TEXTURE_2D); pathTex = new Texture("../bin/terrain/path3.jpg", GL_TEXTURE_2D); //create the VAO glUseProgram(program); }
void PlayState::init() { // Set up the shaders loadShaders(); // Initialize our sprite batch m_spriteBatch.init(); // Set up the camera m_camera.init(1024, 768); // Zoom out the camera by 2x const float CAMERA_SCALE = 1.0f; m_camera.setScale(CAMERA_SCALE); initLevel(); }
void init(void) { // vertex buffer object, used for uploading the geometry // Reference to shader program m = LoadModel("bunny.obj"); dumpInfo(); glutTimerFunc(1, &OnTimer, 0); // GL inits glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glClearColor(0.1,0.5,0.5,0); glEnable(GL_DEPTH_TEST); printError("GL inits"); // Load and compile shader program = loadShaders("lab1-6.vert", "lab1-6.frag"); printError("init shader"); // Upload geometry to the GPU: glGenVertexArrays(1, &bunnyVertexArrayObjID); glGenBuffers(1, &bunnyVertexBufferObjID); glGenBuffers(1, &bunnyIndexBufferObjID); glGenBuffers(1, &bunnyNormalBufferObjID); glBindVertexArray(bunnyVertexArrayObjID); // VBO for vertex data glBindBuffer(GL_ARRAY_BUFFER, bunnyVertexBufferObjID); glBufferData(GL_ARRAY_BUFFER, m->numVertices*3*sizeof(GLfloat), m->vertexArray, GL_STATIC_DRAW); glVertexAttribPointer(glGetAttribLocation(program, "in_Position"), 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(glGetAttribLocation(program, "in_Position")); // VBO for normal data glBindBuffer(GL_ARRAY_BUFFER, bunnyNormalBufferObjID); glBufferData(GL_ARRAY_BUFFER, m->numVertices*3*sizeof(GLfloat), m->normalArray, GL_STATIC_DRAW); glVertexAttribPointer(glGetAttribLocation(program, "in_Normal"), 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(glGetAttribLocation(program, "in_Normal")); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bunnyIndexBufferObjID); glBufferData(GL_ELEMENT_ARRAY_BUFFER, m->numIndices*sizeof(GLuint), m->indexArray, GL_STATIC_DRAW); // End of upload of geometry printError("init arrays"); }
bool GlslProgram :: loadShaders ( const char * vertexFileName, const char * fragmentFileName ) { ok = false; Data * vertexData = getFile ( vertexFileName ); if ( vertexData == NULL ) { log += "Cannot open \""; log += vertexFileName; log += "\""; } else if ( !vertexData -> isOk () || vertexData -> isEmpty () ) { log += "Error loading vertex shader"; delete vertexData; vertexData = NULL; } Data * fragmentData = getFile ( fragmentFileName ); if ( fragmentData == NULL ) { log += "Cannot open \""; log += fragmentFileName; log += "\""; } else if ( !fragmentData -> isOk () || fragmentData -> isEmpty () ) { log += "Error loading fragment shader"; delete fragmentData; fragmentData = NULL; } bool result = loadShaders ( vertexData, fragmentData ); delete vertexData; delete fragmentData; return result; }
void SPED3_freeglutWindow::initializeGL() { if (firstTime) { firstTime = false; loadShaders(); glGenVertexArrays(1, &vao); glBindVertexArray(vao); glGenBuffers(1, &vertexBufferObject); glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObject); glBufferData(GL_ARRAY_BUFFER, sizeof(float)*4*SPED3::MAX_VERTICES*2, vertexData, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); } }
void init(void) { // two vertex buffer objects, used for uploading the unsigned int vertexBufferObjID; unsigned int texCoordBufferObjID; // Reference to shader program GLuint program; // GL inits glClearColor(0.2,0.2,0.5,0); glEnable(GL_DEPTH_TEST); printError("GL inits"); // Load and compile shader program = loadShaders("textured.vert", "textured.frag"); glUseProgram(program); printError("init shader"); // Upload geometry to the GPU: // Allocate and activate Vertex Array Object glGenVertexArrays(1, &vertexArrayObjID); glBindVertexArray(vertexArrayObjID); // Allocate Vertex Buffer Objects glGenBuffers(1, &vertexBufferObjID); glGenBuffers(1, &texCoordBufferObjID); // VBO for vertex data glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjID); glBufferData(GL_ARRAY_BUFFER, 18*sizeof(GLfloat), vertices, GL_STATIC_DRAW); glVertexAttribPointer(glGetAttribLocation(program, "inPosition"), 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(glGetAttribLocation(program, "inPosition")); // VBO for texCoord data glBindBuffer(GL_ARRAY_BUFFER, texCoordBufferObjID); glBufferData(GL_ARRAY_BUFFER, 12*sizeof(GLfloat), texcoord, GL_STATIC_DRAW); glVertexAttribPointer(glGetAttribLocation(program, "inTexCoord"), 2, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(glGetAttribLocation(program, "inTexCoord")); glUniform1i(glGetUniformLocation(program, "tex"), 0); // Texture unit 0 LoadTGATextureSimple("maskros512.tga", &tex); // 5c // End of upload of geometry printError("init arrays"); }
void init(void) { // two vertex buffer objects, used for uploading the unsigned int vertexBufferObjID; unsigned int colorBufferObjID; dumpInfo(); // GL inits glClearColor(0.2,0.2,0.5,0); glEnable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); printError("GL inits"); // Load and compile shader program = loadShaders("colorcube.vert", "colorcube.frag"); printError("init shader"); // Upload geometry to the GPU: // Allocate and activate Vertex Array Object glGenVertexArrays(1, &vertexArrayObjID); glBindVertexArray(vertexArrayObjID); // Allocate Vertex Buffer Objects glGenBuffers(1, &vertexBufferObjID); glGenBuffers(1, &colorBufferObjID); // VBO for vertex data glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjID); glBufferData(GL_ARRAY_BUFFER, 36*3*sizeof(GLfloat), vertices, GL_STATIC_DRAW); glVertexAttribPointer(glGetAttribLocation(program, "in_Position"), 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(glGetAttribLocation(program, "in_Position")); // VBO for color data glBindBuffer(GL_ARRAY_BUFFER, colorBufferObjID); glBufferData(GL_ARRAY_BUFFER, 36*3*sizeof(GLfloat), colors, GL_STATIC_DRAW); glVertexAttribPointer(glGetAttribLocation(program, "in_Color"), 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(glGetAttribLocation(program, "in_Color")); glUniformMatrix4fv(glGetUniformLocation(program, "translationMatrix"), 1, GL_TRUE, translationMatrix); glUniformMatrix4fv(glGetUniformLocation(program, "rotationMatrix"), 1, GL_TRUE, rotationMatrix); glUniformMatrix4fv(glGetUniformLocation(program, "projMatrix"), 1, GL_TRUE, projectionMatrix); // End of upload of geometry printError("init arrays"); }
void DVWindow::initializeGL() { QOpenGLExtraFunctions* f = context()->extraFunctions(); qDebug("GL Vendor: \"%s\", Renderer: \"%s\".", f->glGetString(GL_VENDOR), f->glGetString(GL_RENDERER)); loadShaders(); loadPlugins(); QQmlComponent rootComponent(qmlEngine); rootComponent.loadUrl(QUrl(QStringLiteral("qrc:/qml/Window.qml"))); /* Wait for it to load... */ while(rootComponent.isLoading()); /* The program can't run if there was an error. */ if (rootComponent.isError()) qFatal(qPrintable(rootComponent.errorString())); qmlRoot = qobject_cast<QQuickItem*>(rootComponent.create()); /* Critical error! abort! abort! */ if (qmlRoot == nullptr) qFatal(qPrintable(rootComponent.errorString())); /* This is the root item, make it so. */ qmlRoot->setParentItem(qmlWindow->contentItem()); player = qmlRoot->findChild<QtAV::AVPlayer*>(); if (player == nullptr) qFatal("Unable to find AVPlayer!"); /* Init to this window's OpenGL context. */ qmlRenderControl->initialize(context()); /* The setGeometry() and setState() calls may try to set the qmlRoot geometry, * which means this needs to be done after QML is all set up. */ if (settings.childGroups().contains("Window")) { /* Restore window state from the stored geometry. */ settings.beginGroup("Window"); setGeometry(settings.value("Geometry").toRect()); setWindowState(Qt::WindowState(settings.value("State").toInt())); settings.endGroup(); } }
//-------------------------------------------------------------- void testApp::keyPressed(int key) { if(key=='r')loadShaders(); switch (key) { case OF_KEY_F1: aaType=0; break; case OF_KEY_F2: aaType=1; break; case OF_KEY_F3: aaType=2; break; default: break; } }
void update(double time, double dt) { if(glfwGetKey(GLFW_KEY_LEFT)) yAxisRotation -= 0.78f * dt; if(glfwGetKey(GLFW_KEY_RIGHT)) yAxisRotation += 0.78f * dt; if(glfwGetKey(GLFW_KEY_UP)) xAxisRotation += 0.78f * dt; if(glfwGetKey(GLFW_KEY_DOWN)) xAxisRotation -= 0.78f * dt; if(glfwGetKey('R') && !reloading) { reloading = true; if(!loadShaders()) shutdown("Failed to load shaders"); } else if(!glfwGetKey('R') && reloading) { reloading = false; } }
void init(void) { p = SetVector(20, 20, 0); l = SetVector(0,0,-1); v = SetVector(0,1,0); // GL inits glClearColor(0.2,0.2,0.5,0); glEnable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); printError("GL inits"); projectionMatrix = frustum(-0.1, 0.1, -0.1, 0.1, 0.2, 50.0); // Load and compile shader program = loadShaders("terrain4.vert", "terrain4.frag"); glUseProgram(program); printError("init shader"); glUniformMatrix4fv(glGetUniformLocation(program, "projMatrix"), 1, GL_TRUE, projectionMatrix.m); LoadTGATextureSimple("maskros512.tga", &tex1); LoadTGATextureSimple("dirt.tga", &tex2); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, tex1); glUniform1i(glGetUniformLocation(program, "texUnit0"), 0); // Texture unit 0 glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, tex2); glUniform1i(glGetUniformLocation(program, "texUnit1"), 1); // Load terrain data LoadTGATextureData("fft-terrain.tga", &ttex); tm = GenerateTerrain(&ttex); TextureData *texturePointer = &ttex; texWidth = texturePointer->width; printError("init terrain"); // Load objects sphere = LoadModelPlus("groundsphere.obj"); }
JNIEXPORT void JNICALL Java_dugu9sword_esplayer_VideoTextureSurfaceRenderer_nativeSetupGraphics( JNIEnv* env, jobject obj, jint w, jint h) { width = w; height = h; /* * 把java端的textures数组取过来 */ jclass clazz = env->GetObjectClass(obj); jfieldID f_textures = env->GetFieldID(clazz, "textures", "[I"); jintArray jia_textures = (jintArray) env->GetObjectField( obj, f_textures); textures = (unsigned int*)env->GetIntArrayElements(jia_textures, 0); setupTexture(env, obj); loadShaders(env, obj); }
void init (void) { shaderProgram = loadShaders(vertexShaderFile,fragmentShaderFile); glUseProgram(shaderProgram); // generate VAOs and VBOs glGenVertexArrays( nShapes, vao ); glGenBuffers( nShapes, buffer ); // load the buffers from the model files for (int i = 0; i < nShapes; i++) { boundingRadius[i] = loadModelBuffer(modelFile[i], nVertices[i], vao[i], buffer[i], shaderProgram, Position[i], Color[i], Normal[i], "vPosition", "vColor", "vNormal"); scale[i] = glm::vec3( modelSize[i] * 1.0f /boundingRadius[i]); // set scale for models given bounding radius } MVP = glGetUniformLocation(shaderProgram, "ModelViewProjection"); // inital view eye = glm::vec3(0.0f, 30000.0f, 20000.0f); at = glm::vec3(0); up = glm::vec3(0.0f, 1.0f, 0.0f); viewMatrix = glm::lookAt(eye, at, up); // set render state values glEnable(GL_DEPTH_TEST); glClearColor(0.02f, 0.02f, 0.025f, 1.0f); //RGBA // create shape for(int i = 0; i < nShapes; i++) { shape[i] = new Shape3D(i); shape[i]->setScale(scale[i]); } printf("%d Shapes created \n", nShapes); lastTime = glutGet(GLUT_ELAPSED_TIME); ///////////////////////////////////// }
void onKey(int key, int action) { if (action) { switch (key) { case 'Q': rim_color[0] += 0.1f; break; case 'W': rim_color[1] += 0.1f; break; case 'E': rim_color[2] += 0.1f; break; case 'R': rim_power *= 1.5f; break; case 'A': rim_color[0] -= 0.1f; break; case 'S': rim_color[1] -= 0.1f; break; case 'D': rim_color[2] -= 0.1f; break; case 'F': rim_power /= 1.5f; break; case 'Z': rim_enable = !rim_enable; break; case 'P': paused = !paused; break; case 'L': loadShaders(); break; } } }
void init(void) { // two vertex buffer objects, used for uploading the unsigned int vertexBufferObjID; unsigned int colorBufferObjID; dumpInfo(); // GL inits glClearColor(0.0,0.3,0.3,0); glEnable(GL_DEPTH_TEST); printError("GL inits"); // Load and compile shader program = loadShaders("lab1-5.vert", "lab1-5.frag"); printError("init shader"); // Upload geometry to the GPU: // Allocate and activate Vertex Array Object glGenVertexArrays(2, &vertexArrayObjID); glBindVertexArray(vertexArrayObjID); // Allocate Vertex Buffer Objects glGenBuffers(1, &vertexBufferObjID); glGenBuffers(1, &colorBufferObjID); // VBO for vertex data glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjID); glBufferData(GL_ARRAY_BUFFER, 108*sizeof(GLfloat), vertices, GL_STATIC_DRAW); glVertexAttribPointer(glGetAttribLocation(program, "in_Position"), 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(glGetAttribLocation(program, "in_Position")); // VBO for color data glBindBuffer(GL_ARRAY_BUFFER, colorBufferObjID); glBufferData(GL_ARRAY_BUFFER, 108*sizeof(GLfloat), colors, GL_STATIC_DRAW); glVertexAttribPointer(glGetAttribLocation(program, "in_Color"), 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(glGetAttribLocation(program, "in_Color")); // End of upload of geometry printError("init arrays"); }
void Sphere::init() { //glGenVertexArrays(1, &vertexArrayID); //glBindVertexArray(vertexArrayID); // Create and compile our GLSL program from the shaders programID = loadShaders("SimpleTransform.vertexshader", "SingleColor.fragmentshader"); // Get a handle for our "MVP" uniform matrixID = glGetUniformLocation(programID, "MVP"); colorID = glGetUniformLocation(programID, "uColor"); glGenBuffers(1, &vertexbuffer); glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer); glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(Vector3), vertices.data(), GL_STATIC_DRAW); glGenBuffers(1, &elementbuffer); glBindBuffer(GL_ARRAY_BUFFER, elementbuffer); glBufferData(GL_ARRAY_BUFFER, indices.size() * sizeof(short), indices.data(), GL_STATIC_DRAW); }
// Run from screen.c on init. FIXME: do some kind of FreeShaders on failure. bool pie_LoadShaders() { GLuint program; // Try to load some shaders shaderProgram[SHADER_NONE] = 0; // TCMask shader debug(LOG_3D, "Loading shader: SHADER_COMPONENT"); if (!loadShaders(&program, "", "shaders/tcmask.vert", "shaders/tcmask.frag")) { assert(false); return false; } shaderProgram[SHADER_COMPONENT] = program; currentShaderMode = SHADER_NONE; return true; }
bool SceneRenderer::load(const ModelManager *modelManager, const LightManager *lightManager, const Camera *camera) { assert(modelManager); this->modelManager = modelManager; assert(lightManager); this->lightManager = lightManager; if (!Error::checkMemory(gBuffer = new GBuffer())) return false; if (!gBuffer->load(1280, 720)) return false; if (!Error::checkMemory(ssaoBuffer = new SSAOBuffer())) return false; if (!ssaoBuffer->load(1280, 720)) return false; assert(camera); if (!loadShaders()) return false; if (!loadShaderPrograms(camera)) return false; return true; }
void init(void) { // two vertex buffer objects, used for uploading the unsigned int vertexBufferObjID; unsigned int colorBufferObjID; // Reference to shader program GLuint program; dumpInfo(); // GL inits glClearColor(0.0,1.0,0.0,0); //glEnable(GL_DEPTH_TEST); printError("GL inits"); // Load and compile shader program = loadShaders("lab1-2.vert", "lab1-2.frag"); printError("init shader"); // Upload geometry to the GPU: // Allocate and activate Vertex Array Object glGenVertexArrays(1, &vertexArrayObjID); glBindVertexArray(vertexArrayObjID); // Allocate Vertex Buffer Objects glGenBuffers(1, &vertexBufferObjID); // VBO for vertex data glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjID); glBufferData(GL_ARRAY_BUFFER, 9*sizeof(GLfloat), vertices, GL_STATIC_DRAW); glVertexAttribPointer(glGetAttribLocation(program, "in_Position"), 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(glGetAttribLocation(program, "in_Position")); // End of upload of geometry // Upload the Matrices glUniformMatrix4fv(glGetUniformLocation(program, "myTransMat"), 1, GL_TRUE, myTransMat); glUniformMatrix4fv(glGetUniformLocation(program, "myRotMat"), 1, GL_TRUE, myRotMat); printError("init arrays"); }
void init(void) { // vertex buffer object, used for uploading the geometry unsigned int vertexBufferObjID; // Reference to shader program GLuint program; dumpInfo(); // GL inits glClearColor(1,0.2,0.5,0); glDisable(GL_DEPTH_TEST); printError("GL inits"); // Load and compile shader program = loadShaders("lab1-1.vert", "lab1-1.frag"); printError("init shader"); // **Egen kod** GLint location = glGetUniformLocation(program, "color_"); glUniform4fv(location, 1, color); // Upload geometry to the GPU: // Allocate and activate Vertex Array Object glGenVertexArrays(1, &vertexArrayObjID); glBindVertexArray(vertexArrayObjID); // Allocate Vertex Buffer Objects glGenBuffers(1, &vertexBufferObjID); // VBO for vertex data glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjID); glBufferData(GL_ARRAY_BUFFER, 9*sizeof(GLfloat), vertices, GL_STATIC_DRAW); glVertexAttribPointer(glGetAttribLocation(program, "in_Position"), 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(glGetAttribLocation(program, "in_Position")); // End of upload of geometry printError("init arrays"); }
///////////////////////////////////////// // M A I N // int main(int argc, char **argv) { glutInit(&argc, argv); glutInitWindowSize(512, 512); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInitContextVersion(3, 2); // Might not be needed in Linux glutCreateWindow("Them bones, them bones"); glutDisplayFunc(DisplayWindow); glutTimerFunc(20, &OnTimer, 0); glutKeyboardFunc( keyboardFunc ); glutReshapeFunc(reshape); // Set up depth buffer glEnable(GL_DEPTH_TEST); // initiering #ifdef WIN32 glewInit(); #endif BuildCylinder(); setupBones(); initBoneWeights(); // Build Model from cylinder data cylinderModel = LoadDataToModel( (GLfloat*) g_vertsRes, (GLfloat*) g_normalsRes, (GLfloat*) g_boneWeightVis, // texCoords NULL, // (GLfloat*) g_boneWeights, // colors (GLuint*) g_poly, // indices kMaxRow*kMaxCorners, kMaxg_poly * 3); g_shader = loadShaders("shader.vert" , "shader.frag"); glutMainLoop(); return 0; }
void keyboard(unsigned char key,int x, int y) { Point3D diff; float scale = 0.4; if(key == 'w') { VectorSub(&look_at, &position, &diff); Normalize(&diff); ScalarMult(&diff, scale, &diff); VectorAdd(&look_at, &diff, &look_at); VectorAdd(&position, &diff, &position); } else if(key == 's') { VectorSub(&position, &look_at, &diff); Normalize(&diff); ScalarMult(&diff, scale, &diff); VectorAdd(&look_at, &diff, &look_at); VectorAdd(&position, &diff, &position); } else if(key == 'd') { Point3D y; y.x = 0; y.z = 0; y.y = 1; VectorSub(&position, &look_at, &diff); CrossProduct(&y, &diff, &diff); Normalize(&diff); ScalarMult(&diff, scale, &diff); VectorAdd(&look_at, &diff, &look_at); VectorAdd(&position, &diff, &position); } else if(key == 'a') { Point3D y; y.x = 0; y.z = 0; y.y = 1; VectorSub(&position, &look_at, &diff); CrossProduct(&diff, &y, &diff); Normalize(&diff); ScalarMult(&diff, scale, &diff); VectorAdd(&look_at, &diff, &look_at); VectorAdd(&position, &diff, &position); } else if(key == 'x') { windspeed -= .05; } else if(key == 'c') { windspeed += .05; } else if(key == 'r') { programs[WINDMILL_PROGRAM] = loadShaders("lab3-3.vert", "lab3-3.frag"); printf("Recompiled shaders\n"); } }
void Renderer::init(int width, int height) { width_ = width; height_ = height; aspect_ = static_cast<float>(width)/height; // OpenGL settings. glClearColor(1.0f, 1.0f, 1.0f, 1.0f); glClearDepth(1.0f); glDepthFunc(GL_LESS); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); loadShaders(); setupScreenQuad(); setupFBOs(); useProgram("shadows"); glUniform1f(uniformHandle("density"), 2.0f); glUniform1f(uniformHandle("decay_rate"), 0.98f); glUniform1f(uniformHandle("constant_factor"), 0.85f); glUniform1f(uniformHandle("scale_factor"), 1.0f/160.0f); }
void init(void) { /* GL inits*/ glClearColor(0.2,0.2,0.5,0); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glCullFace(GL_TRUE); glActiveTexture(GL_TEXTURE0); printError("GL inits"); xModify = 0.0; zModify = 0.0; xValue = 0.0; zValue = -2.0; yLookAt = 0.0; xLookAt = 0.0; /* Load and compile shader*/ program = loadShaders("lab3-1.vert", "lab3-1.frag"); glUseProgram(program); printError("init shader"); /* Upload geometry to the GPU:*/ bunny = LoadModelPlus("bunnyplus.obj"); cow = LoadModelPlus("cow.obj"); windmillBalcony = LoadModelPlus("windmill-balcony.obj"); windmillRoof = LoadModelPlus("windmill-roof.obj"); windmillWalls = LoadModelPlus("windmill-walls.obj"); blade = LoadModelPlus("blade.obj"); LoadTGATextureSimple("maskros512.tga", &myTex); glBindTexture(GL_TEXTURE_2D, myTex); glUniform1i(glGetUniformLocation(program, "texUnit"), 0); // Texture unit 0 /* End of upload of geometry*/ glUniformMatrix4fv(glGetUniformLocation(program, "projMatrix"), 1, GL_TRUE, projMatrix); printError("init arrays"); }
void init(void) { dumpInfo(); mill = LoadModelPlus( "windmill/windmill-walls.obj"); blade = LoadModelPlus( "windmill/blade.obj"); balcony = LoadModelPlus( "windmill/windmill-balcony.obj"); roof = LoadModelPlus( "windmill/windmill-roof.obj"); // GL inits glClearColor(0.0,0.3,0.3,0); glEnable(GL_DEPTH_TEST); printError("GL inits"); // Load and compile shader program = loadShaders("lab3-2.vert", "lab3-2.frag"); printError("init shader"); glUniformMatrix4fv(glGetUniformLocation(program, "projectionMatrix"), 1, GL_TRUE, projectionMatrix); // Load texture //LoadTGATextureSimple("bilskissred.tga", &myBilTex); printError("init arrays"); // Init up vector up.x = 0; up.y = 1; up.z = 0; cam_pos.x = 0; cam_pos.y = 5; cam_pos.z = 0; obj_pos.x = 0; obj_pos.y = 5; obj_pos.z = -30; initKeymapManager(); }
//-------------------------------------------------------------- void testApp::setup() { //disable MSAA ofDisableAntiAliasing(); texInput_.allocate(1024,768,GL_RGBA,false); ofImage img ; img.loadImage("test.png"); texInput_.loadData(img.getPixelsRef()); ofFbo::Settings defaultSetting; defaultSetting.numSamples=0; defaultSetting.textureTarget=GL_TEXTURE_2D; defaultSetting.height=768; defaultSetting.internalformat=GL_RGBA; defaultSetting.useDepth=false; defaultSetting.useStencil=false; defaultSetting.width=1024; defaultSetting.wrapModeHorizontal=GL_CLAMP_TO_EDGE; defaultSetting.wrapModeVertical=GL_CLAMP_TO_EDGE; defaultSetting.numSamples=false; fboRender_.allocate(defaultSetting); //Setup AA... aaType=0;//smaa fboAA_.allocate(defaultSetting); fboSmaaWk_.allocate(defaultSetting); texSmaaArea_.allocate(AREATEX_WIDTH,AREATEX_HEIGHT,GL_RG8,false); texSmaaArea_.loadData(areaTexBytes,AREATEX_WIDTH,AREATEX_HEIGHT,GL_RG); texSmaaArea_.setTextureMinMagFilter(GL_LINEAR,GL_LINEAR); texSmaaSearch_.allocate(SEARCHTEX_WIDTH,SEARCHTEX_HEIGHT,GL_R8,false); texSmaaSearch_.loadData(searchTexBytes,SEARCHTEX_WIDTH,SEARCHTEX_HEIGHT,GL_RED); texSmaaSearch_.setTextureMinMagFilter(GL_NEAREST,GL_NEAREST); loadShaders(); }
void init_ground(void) { programs[GROUND_PROGRAM] = loadShaders("billboard.vert", "billboard.frag"); printError("init ground-1"); LoadTGATextureSimple("grass.tga", &billboards[GROUND_TEXTURE]); printError("init ground0"); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); GLuint vertexBufferID, indexBufferID, texCoordBufferID; printError("init ground1"); glGenVertexArrays(1, &groundVertexArrayObjectID); glGenBuffers(1, &vertexBufferID); glGenBuffers(1, &indexBufferID); glGenBuffers(1, &texCoordBufferID); glBindVertexArray(groundVertexArrayObjectID); printError("init ground2"); // VBO for vertex data glBindBuffer(GL_ARRAY_BUFFER, vertexBufferID); glBufferData(GL_ARRAY_BUFFER, sizeof(groundGlyphPosition), groundGlyphPosition, GL_STATIC_DRAW); glVertexAttribPointer(glGetAttribLocation(programs[GROUND_PROGRAM], "inPosition"), 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(glGetAttribLocation(programs[GROUND_PROGRAM], "inPosition")); printError("init ground3"); glBindBuffer(GL_ARRAY_BUFFER, texCoordBufferID); printError("init ground4"); glBufferData(GL_ARRAY_BUFFER, sizeof(groundTexturePos), groundTexturePos, GL_STATIC_DRAW); glVertexAttribPointer(glGetAttribLocation(programs[GROUND_PROGRAM], "inTexCoord"), 2, GL_FLOAT, GL_FALSE, 0, NULL); glEnableVertexAttribArray(glGetAttribLocation(programs[GROUND_PROGRAM], "inTexCoord")); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBufferID); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(groundGlyphIndices), groundGlyphIndices, GL_STATIC_DRAW); printError("init ground"); }