void MainWindow::setup() { camera.setPosition(vec3(0,5,13.0f)); camera.setViewDirection(vec3(0,-0.6f,-1)); renderer = new RendererHelper(); renderer->lightPosition = vec3(0,4,6); renderer->diffusionIntensity = 0.5f; renderer->specularColor = vec4(1.0f, 1.0f, 1.0f, 1.0f); renderer->specularExponent = 10; renderer->overridingObjectColor = vec3(0.5f,0.5f,0.5f); renderer->ambientLight = vec3(0.7f, 0.7f, 0.7f); renderer->eyePosition; setupGeometry(); setupTransforms(); renderer->addShader("../Resources/Shaders/LightingTextureAlphaNormalVertexShader.glsl", "../Resources/Shaders/LightingTextureAlphaNormalFragmentShader.glsl",RendererHelper::ShaderType::SHADER_LIGHTING_TEXTURE, "textureLightingShader"); renderer->addShader("../Resources/Shaders/LightingNoiseVertexShader.glsl", "../Resources/Shaders/LightingNoiseFragmentShader.glsl",RendererHelper::ShaderType::SHADER_LIGHTING_TEXTURE, "lightingNoiseShader"); renderer->addShader("../Resources/Shaders/PassThroughVertexShader.glsl", "../Resources/Shaders/PassThroughFragmentShader.glsl",RendererHelper::ShaderType::SHADER_PASSTHROUGH, "passThroughShader"); setupTextures(); setupRenderables(); dMenu->addVec3Slider("tab", &(renderer->lightPosition),-20,20,-20,20,-20,20,"light"); /*dMenu->addFloatSlider("tab", &heightMin, -1, 0, "Height Min"); dMenu->addFloatSlider("tab", &heightMax, 0,1, "Height Max"); dMenu->addFloatSlider("tab", &heightIncrement, 0.01f, 1, "Increment"); dMenu->addFloatSlider("tab", &burnThreshold, 0.0f, 1, "burnThreshold");*/ }
StarsGeode::StarsGeode(const char* brightStarsFilePath) : osg::Geode() , m_program(new osg::Program) , m_vShader(new osg::Shader(osg::Shader::VERTEX)) , m_gShader(new osg::Shader(osg::Shader::GEOMETRY)) , m_fShader(new osg::Shader(osg::Shader::FRAGMENT)) , u_R(NULL) , u_q(NULL) , u_noise1(NULL) , u_color(NULL) , u_glareIntensity(NULL) , u_glareScale(NULL) , u_apparentMagnitude(NULL) , u_scattering(NULL) , u_scintillations(NULL) , u_scale(NULL) { setName("Stars"); osg::StateSet* stateSet = getOrCreateStateSet(); setupNode(stateSet, brightStarsFilePath); setupUniforms(stateSet); setupShader(stateSet); setupTextures(stateSet); };
SurvivalMode::SurvivalMode() { setup(); setupObjects(); setupTextures(); setupBall(); setupEnemies(); }
int main() { IwGxInit(); IwGxSetColClear(0, 0, 0xff, 0xff); IwResManagerInit(); Iw2DInit(); setupTextures(); registerInput(); const int textWidth = s3eDebugGetInt(S3E_DEBUG_FONT_SIZE_WIDTH); const int textHeight = s3eDebugGetInt(S3E_DEBUG_FONT_SIZE_HEIGHT); const int width = s3eSurfaceGetInt(S3E_SURFACE_WIDTH); const int height = s3eSurfaceGetInt(S3E_SURFACE_HEIGHT); sprintf(g_debugButtonEvent, "ButtonEvent:"); sprintf(g_debugKeyEvent, "KeyEvent:"); sprintf(g_debugMotionEvent, "MotionEvent:"); sprintf(g_debugTouchEvent, "TouchEvent:"); sprintf(g_debugTouchMotionEvent, "TouchMotionEvent:"); while (!s3eDeviceCheckQuitRequest()) { render(); // Yield until unyield is called or a quit request is recieved s3eDeviceYield(S3E_DEVICE_YIELD_FOREVER); } destroyTextures(); Iw2DTerminate(); IwResManagerTerminate(); IwGxTerminate(); return 0; }
// Render the mesh void Mesh::DrawInstanced(GLuint shader, int amount) { setupTextures(shader); // Draw mesh glBindVertexArray(this->VAO); glDrawElementsInstanced(GL_TRIANGLES, this->indices.size(), GL_UNSIGNED_INT, 0, amount); glBindVertexArray(0); deactivateTextures(); }
void CombinedNavRenderer::draw() { QColor color = model()->data( model()->index( (int)Fn::Global::BACKGROUND_COLOR_COMBINED, 0 ) ).value<QColor>(); glClearColor( color.redF(), color.greenF(), color.blueF(), 1.0 ); //qDebug() << "combined draw"; glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); setupTextures(); adjustRatios(); GLFunctions::getShader( "slice" )->bind(); // Set modelview-projection matrix GLFunctions::getShader( "slice" )->setUniformValue( "mvp_matrix", m_mvpMatrix ); GLFunctions::getShader( "slice" )->setUniformValue( "u_renderMode", 0 ); initGeometry(); // Tell OpenGL which VBOs to use glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, vboIds[ 0 ] ); glBindBuffer( GL_ARRAY_BUFFER, vboIds[ 1 ] ); setShaderVars(); // Draw cube geometry using indices from VBO 0 glDrawElements( GL_TRIANGLES, 18, GL_UNSIGNED_SHORT, 0 ); bool renderCrosshairs = model()->data( model()->index( (int)Fn::Global::RENDER_CROSSHAIRS, 0 ) ).toBool(); if ( renderCrosshairs ) { GLFunctions::getShader( "crosshair" )->bind(); GLFunctions::getShader( "crosshair" )->setUniformValue( "mvp_matrix", m_mvpMatrix ); QColor ccolor = model()->data( model()->index( (int)Fn::Global::CROSSHAIR_COLOR, 0 ) ).value<QColor>(); GLFunctions::getShader( "crosshair" )->setUniformValue( "u_color", ccolor.redF(), ccolor.greenF(), ccolor.blueF(), 1.0 ); // Tell OpenGL which VBOs to use glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, vboIds[ 2 ] ); glBindBuffer( GL_ARRAY_BUFFER, vboIds[ 3 ] ); // Tell OpenGL programmable pipeline how to locate vertex position data int vertexLocation = GLFunctions::getShader( "crosshair" )->attributeLocation( "a_position" ); GLFunctions::getShader( "crosshair" )->enableAttributeArray( vertexLocation ); glVertexAttribPointer( vertexLocation, 3, GL_FLOAT, GL_FALSE, sizeof( VertexData ), 0 ); glDrawElements( GL_LINES, 12, GL_UNSIGNED_SHORT, 0 ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); } }
void RedBuilding::configure() { setAxiom("{BSFER}"); //addRule('E', "FE"); // Next normal floor addRule('E', "LFE"); // Ledge, then floor //addRule('E', "R-FE"); // Setbacks setInitialDirection(Vector(0,0,1)); Random generator; setMaxHeight(generator.generateInteger(20, 30) * 2.5 * OgreCity::meter); setupTextures(); }
StGLRootWidget::StGLRootWidget(const StHandle<StResourceManager>& theResMgr) : StGLWidget(NULL, 0, 0, StGLCorner(ST_VCORNER_TOP, ST_HCORNER_LEFT)), myShareArray(new StGLSharePointer*[10]), myShareSize(10), myResMgr(theResMgr), myScrDispX(0.0f), myLensDist(0.0f), myScrDispXPx(0), myMenuProgram(new StGLMenuProgram()), myTextProgram(new StGLTextProgram()), myTextBorderProgram(new StGLTextBorderProgram()), myIsMobile(false), myScaleGlX(1.0), myScaleGlY(1.0), myScaleGUI(1.0f), myResolution(72), cursorZo(0.0, 0.0), myFocusWidget(NULL), myIsMenuPressed(false), myMenuIconSize(IconSize_16), myClickThreshold(3) { // unify access StGLWidget::myRoot = this; myViewport[0] = 0; myViewport[1] = 0; myViewport[2] = 1; myViewport[3] = 1; // allocate shared resources array for(size_t aResId = 0; aResId < myShareSize; ++aResId) { myShareArray[aResId] = new StGLSharePointer(); } myGlFontMgr = new StGLFontManager(myResolution); myColors[Color_Menu] = StGLVec4(0.855f, 0.855f, 0.855f, 1.0f); myColors[Color_MenuHighlighted] = StGLVec4(0.765f, 0.765f, 0.765f, 1.0f); myColors[Color_MenuClicked] = StGLVec4(0.500f, 0.500f, 0.500f, 1.0f); myColors[Color_MenuText] = StGLVec4(0.000f, 0.000f, 0.000f, 1.0f); myColors[Color_MenuIcon] = StGLVec4(0.000f, 0.000f, 0.000f, 0.8f); myColors[Color_MessageBox] = StGLVec4(0.060f, 0.060f, 0.060f, 1.0f); myColors[Color_MessageText] = StGLVec4(1.000f, 1.000f, 1.000f, 1.0f); myColors[Color_ScrollBar] = StGLVec4(0.765f, 0.765f, 0.765f, 0.8f); myColors[Color_IconActive] = StGLVec4(1.000f, 1.000f, 1.000f, 1.0f); setupTextures(); }
void StGLRootWidget::setScale(const GLfloat theScale, const ScaleAdjust theScaleAdjust) { GLfloat aScale = theScale; switch(theScaleAdjust) { case ScaleAdjust_Small: aScale *= 0.8f; break; case ScaleAdjust_Big: aScale *= 1.2f; break; default: case ScaleAdjust_Normal: break; } if(stAreEqual(myScaleGUI, aScale, 0.001f)) { return; } myScaleGUI = aScale; myResolution = (unsigned int )(72.0f * aScale + 0.1f); myGlFontMgr->setResolution(myResolution); myMenuIconSize = scaleIcon(16); myClickThreshold = scale(3); setupTextures(); }
GameplayModeScene::GameplayModeScene() { setup(); setupObjects(); setupTextures(); }
bool YUV420PGrabber::setup(int winW, int winH, int framerate) { if(!winW || !winH) { printf("error: invalid win_w or win_h: %dx%d\n", winW, winH); return false; } if(!framerate) { printf("error: invalid fps: %d\n", framerate); return false; } win_w = winW; win_h = winH; uv_w = vid_w * 0.5; uv_h = vid_h * 0.5; fps = framerate; if(!setupSizes()) { printf("error: cannot setup the sizes. did you add any? make sure to call addSize()\n"); return false; } if(!setupTextures()) { printf("error: cannot setup textures.\n"); return false; } #if 0 if(!setupPBO()) { printf("error: cannot setup pbox.\n"); return false; } #endif if(!setupFBO()) { printf("error: cannot setup fbo.\n"); return false; } if(!setupVAO()) { printf("error: cannot setup vao.\n"); return false; } if(!setupShaders()) { printf("error: cannot setup shaders.\n"); return false; } image = new unsigned char[tex_w * tex_h]; if(!image) { printf("error: cannot allocate image buffer.\n"); return false; } // set the pointers to the image for(std::vector<YUV420PSize>::iterator it = sizes.begin(); it != sizes.end(); ++it) { YUV420PSize& s = *it; s.planes[0] = &image[s.y_offset]; s.planes[1] = &image[s.u_offset]; s.planes[2] = &image[s.v_offset]; } frame_delay = (1.0/fps) * 1000 * 1000 * 1000; return true; }
JNIEXPORT void JNICALL Java_com_limasky_test_LSGL1Renderer_init(JNIEnv *env, jclass jcls, jint width, jint height) { setupSounds(); setupTextures(); setupGraphics( width, height ); }
//---------------------------------------------------------------------- DistanceTransform::DistanceTransform(Globals* g, int tex_size) { this->g = g; this->tex_size = tex_size; setupTextures(); }