示例#1
0
chaos::ShaderProgram::ShaderProgram(const std::initializer_list<Shader> &listShaders){
    id = glCreateProgram();
    for (auto shr : listShaders) {
        glAttachShader(id, shr.getId());
    }
    glLinkProgram(id);
    GLint success;
    GLchar infoLog[512];
    glGetProgramiv(id, GL_LINK_STATUS, &success);
    if (!success) {
        glGetProgramInfoLog(id, 512, NULL, infoLog);
        SHOUT("ERROR::SHADER::PROGRAM::LINKING_FAILED: %s", infoLog);
    }
}
示例#2
0
chaos::ShaderProgram::ShaderProgram(const std::initializer_list<std::pair<std::string, GLenum>> &listShaders){
    id = glCreateProgram();
    std::vector<Shader*> vecShaders;
    for (auto shaderPair : listShaders) {
        vecShaders.push_back(new Shader(shaderPair.first, shaderPair.second));
        glAttachShader(id, vecShaders.back()->getId());
    }
    glLinkProgram(id);
    GLint success;
    GLchar infoLog[512];
    glGetProgramiv(id, GL_LINK_STATUS, &success);
    if (!success) {
        glGetProgramInfoLog(id, 512, NULL, infoLog);
        SHOUT("ERROR::SHADER::PROGRAM::LINKING_FAILED: %s", infoLog);
    }
    //destructor of Shader will call glDeleteShader on every element of vecShader
    for (unsigned int i = 0; i < vecShaders.size(); i++) {
        delete vecShaders[i];
    }
}
示例#3
0
nsresult
BrowserWindow::Create ( Handle * hwnd, PRInt32 width, PRInt32 height)
{
	PRINT("BrowserWindow::Create\n");
	nsresult result;

	webBrowser = do_CreateInstance( NS_WEBBROWSER_CONTRACTID );
	if ( ! webBrowser )
		return NS_ERROR_FAILURE;

    (void) webBrowser->SetContainerWindow (static_cast<nsIWebBrowserChrome *> (this));

    nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface( webBrowser );
    dsti->SetItemType( nsIDocShellTreeItem::typeContentWrapper );

	webNav = do_QueryInterface(webBrowser);
	sessionHistory = do_CreateInstance(NS_SHISTORY_CONTRACTID);
	webNav->SetSessionHistory(sessionHistory);

    nsCOMPtr<nsIWindowCreator> windowCreator (static_cast<nsIWindowCreator *> (this));

    // Attach it via the watcher service
    nsCOMPtr<nsIWindowWatcher> watcher = do_GetService(NS_WINDOWWATCHER_CONTRACTID);
    if (watcher)
      watcher->SetWindowCreator(windowCreator);

	
    nsCOMPtr<nsIX509CertDB> certdb = do_GetService(NS_X509CERTDB_CONTRACTID, &result);

	/** Component registration... ***/
	RegisterComponents ();

    baseWindow = do_QueryInterface (webBrowser);
	
	result = baseWindow->InitWindow( hwnd, nsnull,  0, 0, width, height );
	if (!NS_SUCCEEDED(result)) {
		SHOUT("BrowserWindow: Failed to initialize window\n");
		return NS_ERROR_FAILURE;
	}
    result = baseWindow->Create();
	if (!NS_SUCCEEDED(result)) {
		SHOUT("BrowserWindow: Failed to create window\n");
		return NS_ERROR_FAILURE;
	}

    nsCOMPtr<nsIWebProgressListener> wpl (static_cast<nsIWebProgressListener*>(this));
    nsCOMPtr<nsIWeakReference> weakWpl (NS_GetWeakReference (wpl));
    webBrowser->AddWebBrowserListener (weakWpl, NS_GET_IID (nsIWebProgressListener));

	baseWindow->SetVisibility( PR_TRUE );

	webNav = do_QueryInterface( webBrowser, &result );
	if ( NS_FAILED( result ) || ! webNav ) {
	    return NS_ERROR_FAILURE;
	}


    if ( webBrowser ) {
		// I really hope we don't need this, it calls in nsIWidget.h which calls
		// in a bunch of local includes we don't want
/*		
#ifdef NS_UNIX
		// save the window id of the newly created window
		nsCOMPtr<nsIWidget> mozWidget;
		baseWindow->GetMainWidget(getter_AddRefs(mozWidget));

		GdkWindow *tmp_window = static_cast<GdkWindow *> (mozWidget->GetNativeData(NS_NATIVE_WINDOW));

		// and, thanks to superwin we actually need the parent of that.
		tmp_window = gdk_window_get_parent(tmp_window);
		
		// save the widget ID - it should be the mozarea of the window.
		gpointer data = nsnull;
		gdk_window_get_user_data(tmp_window, &data);
		this->nativeMozWidget = static_cast<Handle *> (data);
#endif		
*/
		return NS_OK;
    }

    return NS_ERROR_FAILURE;
}