Example #1
0
void COGL::SetupExtensions (void)
{
pszOglExtensions = reinterpret_cast<const char*> (glGetString (GL_EXTENSIONS));
//wii edit: glew doesn't exist
//glewInit ();
SetupMultiTexturing ();
SetupShaders ();
SetupOcclusionQuery ();
SetupPointSprites ();
SetupTextureCompression ();
SetupStencilOps ();
SetupRefreshSync ();
SetupAntiAliasing ();
SetupVBOs ();
#if RENDER2TEXTURE == 1
SetupPBuffer ();
#elif RENDER2TEXTURE == 2
CFBO::Setup ();
#endif
if (!(gameOpts->render.bUseShaders && m_states.bShadersOk)) {
	gameOpts->ogl.bGlTexMerge = 0;
	m_states.bLowMemory = 0;
	m_states.bHaveTexCompression = 0;
	}
}
Example #2
0
        Test5::Test5(greng::Greng& greng) : Test3(greng) {
            SetupProcessors();
            SetupMeshes();
            SetupTextures();
            SetupShaders();
            SetupLights();

            light1.position.Set(0, 50, 0);

            GetDebugRenderer().SetLight(&light1);
        }
Example #3
0
static void
Init(void)
{
   CheckExtensions();
   SetupRenderbuffers();
   SetupShaders();
   SetupLighting();
   glEnable(GL_DEPTH_TEST);

   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   glEnableIndexedEXT(GL_BLEND, 1);
}
Example #4
0
bool GameWindow::SetupWindow()
{
	GLenum err;
	glfwMakeContextCurrent(wnd);

	// we have an opengl context, try opening up glew
	if ((err = glewInit()) != GLEW_OK)
	{
		Log::Logf("glew failed initialization: %s", glewGetErrorString(err));
		return false;
	}

	BindingsManager::Initialize();

	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	// glEnable(GL_CULL_FACE);
	glEnable(GL_LINE_SMOOTH);
	// glCullFace(GL_BACK);
	// glFrontFace(GL_CW);
	// glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);

	glEnable(GL_ALPHA_TEST);
	glAlphaFunc(GL_GREATER, 0);

	if (VSync)
		glfwSwapInterval(1);

	projection = glm::ortho<float>(0.0, matrixSize.x, matrixSize.y, 0.0, -32.0, 0.0);
	projectionInverse = glm::inverse(projection);

	if (!SetupShaders())
		return false;

	InitializeRender();

	// GLFW Hooks
	glfwSetFramebufferSizeCallback(wnd, ResizeFunc);
	glfwSetWindowSizeCallback(wnd, ResizeFunc);
	glfwSetKeyCallback(wnd, InputFunc);
	glfwSetMouseButtonCallback(wnd, MouseInputFunc);
	glfwSetCursorPosCallback(wnd, MouseMoveFunc);
	glfwSetScrollCallback(wnd, ScrollFunc);
	glfwSetCharCallback(wnd, CharInputFunc);

	ResizeFunc(wnd, size.x, size.y);

	return true;
}
Example #5
0
//----------------------------------------------------------------------------
bool RipplingOcean::OnInitialize ()
{
    if ( !Application::OnInitialize() )
        return false;

    m_bVertexShader = true;
    m_spkVertShader = VertexShader::Load("RipplingOcean.wvs");
    m_spkPixShader = PixelShader::Load("RipplingOcean.wps");

    m_fAmbient = 0.3f;
    m_fTexRepeat = 6.0f;
    m_fWaveSpeedFactor = 1.0f;
    m_fWaveHeightFactor = 1.0f;
    m_fRippleSpeedFactor = 1.0f;

    if ( !m_spkVertShader || !m_spkPixShader || !Setup() )
        return true;

    SetupShaders();

    m_spkScene->UpdateGS(0.0f);

    ms_spkCamera->SetFrustum(1.0f,10000.0f,-0.55f,0.55f,0.4125f,-0.4125f);
    Vector3f kCLeft(1.0f,0.0f,0.0f);
    Vector3f kCUp(0.0f,1.0f,0.0f); 

    Vector3f kCDir(0.0f,1.0f,0.5f);
    kCDir.Normalize();
    Vector3f kCLoc(0.0f, -600.0f, -100.0f);
    ms_spkCamera->SetFrame(kCLoc,kCLeft,kCUp,kCDir);

    // initial update of objects
    ms_spkCamera->Update();
    m_spkScene->UpdateGS(0.0f);
    m_spkScene->UpdateRS();

    m_spkMotionObject = m_spkScene;
    m_fTrnSpeed = 2.0f;
    m_fRotSpeed = 0.001f;
    m_bTurretActive = true;
    SetTurretAxes();

    m_bInitialized = true;
    return true;
}
HRESULT ColladaLoader::Run()
{
	StartLogging();

	if(!Initialize()) {
        StopLogging();
        return -1;
    } else {
        SetupShaders();
        SetupMatrices();
        SetupLights();
        SetupGeometry();
        MainLoop();
        Terminate();
        StopLogging();
    }

	return 0;

}
bool Painter::SetupEnvoriment(ScreenManager *sm){
    bear::out << "Initializing\n";
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);

	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);

	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
	SDL_GL_SetSwapInterval(0);

    glewExperimental = GL_TRUE;
    GLenum glewError = glewInit();
    if( glewError != GLEW_OK )
    {
        bear::out << "Error initializing GLEW!\n";
        return false;
    }

    DisplayGlError("1");

	SDL_GL_SwapWindow(sm->m_window);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    bear::out << "Loading shaders\n";
    SetupShaders();

    glClearColor(0.0, 0.0, 0.0, 0.0);
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

	DisplayGlError("Error on starting");

    bear::out << "Making buffers\n";
	glGenBuffers(4, Painter::Buffers);
	DisplayGlError("SetupEnvoriment");


	UnloadedTextureId = 0; //todo
    return true;
}
Example #8
0
void StartupModernGLPatch(){
	//setup a global VAO/VBO for rendering everything
	//hopefully this will be good enough
	if(vtx.vao_handle == 0){
		glGenVertexArrays(1,&vtx.vao_handle);		
		glGenBuffers(1, &vtx.vbo_handle);
		glBindBuffer(GL_ARRAY_BUFFER, vtx.vbo_handle);
		glBufferData(GL_ARRAY_BUFFER, GRANULARITY, 0, GL_DYNAMIC_DRAW);
		vtx.vbo_capacity = GRANULARITY + 4;
		vtx.vbo_size = 0;
	}

	// - - - - - - - - - - - - - - - -
	//setup the UBOS
	// - - - - - - - - - - - - - - - -
	SetupUBOs();
	matSetIdentity44(&transforms.mv);
	matSetIdentity44(&transforms.proj);

	// - - - - - - - - - - - - - - - -
	//setup the shaders library
	// - - - - - - - - - - - - - - - -
	SetupShaders();	

	// - - - - - - - - - - - - - - - -
	//Allocate float data 
	// - - - - - - - - - - - - - - - -
	//vtx.p_pre_gl_buffer = (float*)malloc(vtx.vbo_capacity);
	//vtx.p_buffer_loc = vtx.p_pre_gl_buffer;
	glBindBuffer(GL_ARRAY_BUFFER, vtx.vbo_handle);
	vtx.p_pre_gl_buffer = (float*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
	vtx.p_buffer_loc = vtx.p_pre_gl_buffer;

	// - - - - - - - - - - - - - - - -
	//
	// - - - - - - - - - - - - - - - -
	InitialiseStack(transform_stack_size);
	CreateDebugTextures();
}
Example #9
0
void PreviewPane::initializeGL()
{
    initializeOpenGLFunctions();

    printVersionInformation();

    glClearColor(0.15f, 0.15f, 0.15f, 1.0f);

    SetupShaders();
    SetupVertexBuffer();
    SetupObject();
    //SetupTexture();

    object.release();
    vertex.release();
    program->release();

    _initialized = true;

    glGenTextures(1, &textureRed);
    glGenTextures(1, &textureGreen);
    glGenTextures(1, &textureBlue);
}
void RefreshScreenInit(void)
{
	// Enable depth test
	glEnable(GL_DEPTH_TEST);
	// Accept fragment if it closer to the camera than the former one
	glDepthFunc(GL_LESS);

	// Cull triangles which normal is not towards the camera
	glEnable(GL_CULL_FACE);

    //Setup texture
	glGenTextures(1, &gTexture.glName);
	gTexture.frameBufferTexture = fbOneSample;
	gTexture.realWidth = 640;
	gTexture.realHeight = 480;
	gTexture.textureBytes = gTexture.realWidth * gTexture.realHeight * 4;
	glBindTexture( GL_TEXTURE_2D, gTexture.glName );
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, gTexture.realWidth, gTexture.realHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );

	// Generate Pixel Buffer Object
	glGenBuffers(1, &gPBO);
	glGenFramebuffers(1, &gFBO);
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gFBO);

    //Setup shader
    gProgramId = SetupShaders();

    glUseProgram(gProgramId);
    gTexID = glGetUniformLocation(gProgramId, "renderedTexture");

    //Setup vertexes
    glGenBuffers(1, &gQuad_vertexbuffer);
    glBindBuffer(GL_ARRAY_BUFFER, gQuad_vertexbuffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(g_quad_vertex_buffer_data), g_quad_vertex_buffer_data, GL_STATIC_DRAW);
}
Example #11
0
//----------------------------------------------------------------------------
void RipplingOcean::OnIdle ()
{
    MeasureTime();
    MoveCamera();

    if ( m_bVertexShader )
    {
        SetupShaders();
    }

    if ( MoveObject() )
        m_spkScene->UpdateGS(0.0f);

    ms_spkRenderer->ClearBuffers();
    if ( ms_spkRenderer->BeginScene() )
    {
        if ( m_bInitialized )
        {
            ms_spkRenderer->Draw(m_spkScene);
            DrawFrameRate(8,GetHeight()-8,ColorRGB::WHITE);
        }
        else
        {
            ms_spkRenderer->Draw(8,32,ColorRGB::WHITE,
                "Load of ripple.{wvs,wps}, sky.mif, watergradient.mif"\
                " or plasa.mif failed.  ");
            ms_spkRenderer->Draw(8,48,ColorRGB::WHITE,
                "Make sure these files are in the same directory as the "
                "executable.");
        }
        ms_spkRenderer->EndScene();
    }
    ms_spkRenderer->DisplayBackBuffer();

    UpdateClicks();
}
Example #12
0
//----------------------------------------------------------------------------
bool RipplingOcean::Setup ()
{
    m_bStopped = false;
    m_fStopTime = GetTimeInSeconds();

    m_spkScene = new Node(1);
    m_spkTrnNode = new Node(1);
    m_spkScene->AttachChild(m_spkTrnNode);

    // Root node for a scene graph that contains a bump-mapped triangle mesh
    // square.
    m_spkModel = new Node(1);

    // create the triangle mesh surface
    TriMesh* pkMesh = NULL;
    CreateRectangleMesh(pkMesh, Vector3f::ZERO,
        Vector3f::UNIT_X, Vector3f::UNIT_Y, -Vector3f::UNIT_Z,
        1400.0f, 1200.0f, 50, 50, true, true, true);

    m_spkTriMesh = pkMesh;

    m_spkTriMesh->SetVertexShader(m_spkVertShader);
    m_spkTriMesh->SetPixelShader(m_spkPixShader);
    SetupShaders();

    Image* pkNormal = Image::Load("plasma.mif");
    if ( !pkNormal )
        return false;

    HeightToNormalMap( pkNormal );

    Texture* pkNormalTex = new Texture;
    pkNormalTex->SetImage(pkNormal);
    pkNormalTex->Mipmap() = Texture::MM_LINEAR_LINEAR;
    pkNormalTex->Filter() = Texture::FM_LINEAR;
    pkNormalTex->Apply() = Texture::AM_DECAL;
    pkNormalTex->Wrap() = Texture::WM_WRAP_S_WRAP_T;
    TextureState* pkTS = new TextureState;
    pkTS->Set(0,pkNormalTex);

    Image* pkWater = Image::Load("watergradient.mif");
    if (!pkWater)
        return false;

    Texture* pkWaterTex = new Texture;
    pkWaterTex->SetImage(pkWater);
    pkWaterTex->Apply() = Texture::AM_DECAL;
    pkWaterTex->Wrap() = Texture::WM_CLAMP_S_CLAMP_T;
    pkTS->Set(1,pkWaterTex);

    Image* pkSkySphere = Image::Load("sky.mif");
    if (!pkSkySphere)
        return false;

    Texture* pkSkySphereTex = new Texture;
    pkSkySphereTex->SetImage(pkSkySphere);
    pkTS->Set(2,pkSkySphereTex);

    m_spkTriMesh->SetRenderState(pkTS);

    m_spkModel->AttachChild(m_spkTriMesh);
    m_spkTrnNode->AttachChild(m_spkModel);

    // I'll admit that this is kind of a hack, but it puts the sun
    // a smidge higher in the sky.  It makes it look nicest to start.  =)
    Matrix3f kIncr;
    kIncr.FromAxisAngle(Vector3f::UNIT_X, -0.08f);
    m_spkTrnNode->Rotate() = kIncr; 

    return true;
}