当前位置: 首页>>代码示例>>C++>>正文


C++ InitShader函数代码示例

本文整理汇总了C++中InitShader函数的典型用法代码示例。如果您正苦于以下问题:C++ InitShader函数的具体用法?C++ InitShader怎么用?C++ InitShader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了InitShader函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init

void init() {
	// Load shaders and use the resulting shader program
    GLuint drawProg = InitShader("Draw.vertex", "Draw.fragment");
	GLuint shadowProg = InitShader("ShadowMap.vertex", "ShadowMap.fragment");
    glUseProgram(drawProg);

	meshSetup(Global::red_opaque, 1.2);

	const mat4 projection = Perspective(Global::FOV, 1.0f, 0.0078125f, 16.0f) * 
		translate(0.0f, 0.0f, 0.75f) * scale(10.0f);

	Global::root = new RenderGraph(
		drawProg,
		shadowProg,
		*genIdyll(5, 1.2f),
		projection
	);
	Global::sun = new RenderGraph(
		drawProg,
		shadowProg,
		*genSun( translate(16.0 * Global::sunVec) * scale(0.4f) *
			rX(M_PI/2.0) ),
		projection
	);

	help();
}
开发者ID:Emassengill,项目名称:ComputerGraphicsFinal,代码行数:27,代码来源:Main.cpp

示例2: init

void init() {

  /*select clearing (background) color*/
  glClearColor(1.0, 1.0, 1.0, 1.0);


  //populate our arrays
  spherevertcount = generateSphere(2, 10);


   // Load shaders and use the resulting shader program
    program1 = InitShader( "vshader-lighting.glsl", "fshader-lighting.glsl" );
	program2 = InitShader( "vshader-phongshading.glsl", "fshader-phongshading.glsl" );
	program3 = InitShader( "vshader-celshading.glsl", "fshader-celshading.glsl" );

	// Create a vertex array object
    glGenVertexArrays( 1, &vao[0] );

    // Create and initialize any buffer objects
	glBindVertexArray( vao[0] );
	glGenBuffers( 2, &vbo[0] );
    glBindBuffer( GL_ARRAY_BUFFER, vbo[0] );
    glBufferData( GL_ARRAY_BUFFER, spherevertcount*sizeof(vec4), sphere_verts, GL_STATIC_DRAW);
	

	//and now our colors for each vertex
	glBindBuffer( GL_ARRAY_BUFFER, vbo[1] );
	glBufferData( GL_ARRAY_BUFFER, spherevertcount*sizeof(vec3), sphere_normals, GL_STATIC_DRAW );

	setupShader(program1);

  //Only draw the things in the front layer
	glEnable(GL_DEPTH_TEST);
}
开发者ID:ande8331,项目名称:SEIS750-OpenGL,代码行数:34,代码来源:lighting_skeleton.cpp

示例3: InitShader

void VerticalBlurShader::changeShaderBlur(bool isHighBlur)
{
    if (isHighBlur)
    {
        InitShader(L"../shaders/increasedVertBlur_vs.hlsl", L"../shaders/increasedVertBlur_ps.hlsl");
    }
    else
    {
        InitShader(L"../shaders/verticalBlur_vs.hlsl", L"../shaders/verticalBlur_ps.hlsl");
    }
}
开发者ID:Jamesnoble1,项目名称:Shaders,代码行数:11,代码来源:VerticalBlurShader.cpp

示例4: main

int main(int argc, char** argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
    glutInitWindowSize(500, 500);
    glutInitContextVersion( 3, 2 );
    glutInitContextProfile( GLUT_CORE_PROFILE );
    glutCreateWindow("particle system");
    glutDisplayFunc(myDisplay);
    
	glewExperimental = GL_TRUE;    
    glewInit();
    program = InitShader("vshader91.glsl", "fshader91.glsl");
    myinit ();

    glutCreateMenu(main_menu);
    glutAddMenuEntry("more particles", 1);
    glutAddMenuEntry("fewer particles", 2);
    glutAddMenuEntry("faster", 3);
    glutAddMenuEntry("slower", 4);
    glutAddMenuEntry("larger particles", 5);
    glutAddMenuEntry("smaller particles", 6);
    glutAddMenuEntry("toggle gravity",7);
    glutAddMenuEntry("toggle restitution",8);
    glutAddMenuEntry("toggle repulsion",9);
    glutAddMenuEntry("quit",10);
    glutAttachMenu(GLUT_MIDDLE_BUTTON);

    glutIdleFunc(myIdle);
    glutReshapeFunc (myReshape); 
    glutMainLoop();
}
开发者ID:matthiascy,项目名称:interactive_computer_graphics,代码行数:32,代码来源:chap09_6E_example1.cpp

示例5: init

// OpenGL initialization
void
init()
{
    mesh();

    // Create a vertex array object
    GLuint vao;
    glGenVertexArraysAPPLE( 1, &vao );
    glBindVertexArrayAPPLE( vao );

    // Create and initialize a buffer object
    GLuint buffer;
    glGenBuffers( 1, &buffer );
    glBindBuffer( GL_ARRAY_BUFFER, buffer );
    glBufferData( GL_ARRAY_BUFFER, sizeof(points), points, GL_STATIC_DRAW ); 

    // Load shaders and use the resulting shader program
    GLuint program = InitShader( "vmesh.glsl", "fmesh.glsl" );
    glUseProgram( program );

    // set up vertex arrays
    GLuint vPosition = glGetAttribLocation( program, "vPosition" );
    glEnableVertexAttribArray( vPosition );
    glVertexAttribPointer( vPosition, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0) );

    timeParam = glGetUniformLocation(program, "time");
    MVP_loc = glGetUniformLocation(program, "ModelViewProjection");
    
    glClearColor( 1.0, 1.0, 1.0, 1.0 );
    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
}
开发者ID:jtanx,项目名称:CITS3003-L,代码行数:32,代码来源:wave.cpp

示例6: initApp

	//SoundPlayerGuard spg;
	void initApp(){
		//Seed the random number generator
		std::srand(std::time(NULL));

		sProgram=InitShader("Resources/PhongShader_vertex.glsl","Resources/PhongShader_fragment.glsl");
		initShaderVariables(sProgram);

		glClearColor( .05f, .075f, .1f, 1.f );
		glClearColor( .3f, .2f, .25f, 1.f ); //lightBlue Sky
		glClearColor( .7f, .9f, .9f, 1.f ); //lightBlue Sky
		glEnable(GL_DEPTH_TEST);
		glDepthFunc(GL_LEQUAL);

		//INIT THE LIGHTS
		for(int i=0;i<LIGHT_COUNT;i++){
			wLights[i]=NULL;
		}
		//Null Scenes
		for(int i=0;i<SCENE_COUNT;i++){
			wScenes[i]=NULL;
		}

		//viewFullscreen();
		glutWarpPointer(glutGet(GLUT_WINDOW_WIDTH)/2,glutGet(GLUT_WINDOW_HEIGHT)/2);
		glutSetCursor(GLUT_CURSOR_NONE);

		//setup scenes
		wScenes[0]=new Scene_1();

		wScenes[currentLevel]->setup();

		Globals::setHasFog(true);
	}
开发者ID:elixiroflife4u,项目名称:cs174a_term_project,代码行数:34,代码来源:general.cpp

示例7: init

// OpenGL initialization
void
init()
{
	srand(time(NULL));

	numSquares = 0;

	drawSquares(0, 0, 1, 1, 4, 4);

	exitMaker();

    // Create and initialize a buffer object

   // Load shaders and use the resulting shader program
    GLuint program = InitShader( "vshader00_v110.glsl", "fshader00_v110.glsl" );
    glUseProgram( program );

    
    vPosition = glGetAttribLocation( program, "vPosition" );
	
    glEnableVertexAttribArray( vPosition );
    
	
	color_loc = glGetUniformLocation(program, "color");
	model_view_loc = glGetUniformLocation(program, "modelview");

    glEnable( GL_DEPTH_TEST );
    glClearColor( 1.0, 1.0, 1.0, 1.0 ); 
}
开发者ID:Tampy,项目名称:CS537,代码行数:30,代码来源:lab2.cpp

示例8: init

void init()
{

  // Create a vertex array object
  GLuint vao;
  glGenVertexArrays( 1, &vao );
  glBindVertexArray( vao );

  /* set up vertex buffer object */

  glGenBuffers(1, buffers);
  glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
  glBufferData(GL_ARRAY_BUFFER, sizeof(points) + sizeof(quad_color), NULL, GL_STATIC_DRAW);

  program = InitShader("vshader52.glsl", "fshader52.glsl");
  glUseProgram(program);

  loc = glGetAttribLocation(program, "vPosition");
  glEnableVertexAttribArray(loc);
  glVertexAttribPointer(loc, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
  loc2 = glGetAttribLocation(program, "vColor");
  glEnableVertexAttribArray(loc2);
  glVertexAttribPointer(loc2, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(sizeof(points)));

  glClearColor(1.0, 1.0, 1.0, 1.0); /* white background */
}
开发者ID:kchapdaily,项目名称:CS452-LAB4,代码行数:26,代码来源:main.cpp

示例9: SetRenderFlag

void DexSkinMesh::Init()
{
	m_iRenderFlag = 0;
	m_fAnimateRatio = 1.0f;
	m_eAniType = SkinMeshAnimateType_Loop;
	m_eMeshType = SkinMeshModelType_UnKnown;
	m_iAnimateStartTime = 0;
	m_iAnimateNowTime = 0;
	m_iAnimateEndTime = 0;
	m_iAnimateMaxTime = 0;
	m_pRootJoint = NULL;
	m_bHaveAnimation = true;
	m_bAnimate = true;
	m_iLightFlag = 0;

	m_pRootJoint = new Joint;
	m_pRootJoint->m_pFather = NULL;
	m_pRootJoint->str_name = "root_joint";
	m_pRootJoint->id = _SKIN_MESH_ROOT_JOINT_ID;
	m_pRootJoint->frame_matrix.Identity();
	m_pRootJoint->meshMatrix.Identity();
	m_pRootJoint->localMeshMatrixInvert.Identity();
	m_pRootJoint->world_matrix.Identity();
	m_vecJoints.push_back(m_pRootJoint);
	SetRenderFlag(SKINMESH_RENDER_MESH);
	jointsMatrix = new D3DXMATRIX[sGetMaxJointCount()];
	m_fJointScale = 1.0f;
	InitShader();

	iHideMeshIndex = -1;

}
开发者ID:BruceKen2014,项目名称:Dex,代码行数:32,代码来源:DexSkinMesh.cpp

示例10: CreateShader

int CreateShader(Shader* s, char* fname, GLenum type)
{
	FILE* file = fopen(fname, "r");

	int size;
	int bytes;
	int error;

	char buffer[1024];
	memset(buffer, 0, 1024);

	if(!file){
		error = errno;
		OutputDebugString(strerror(errno));
		return -1;
	}
	
	fseek(file, 0, SEEK_END);
	size = ftell(file);
	rewind(file);

	bytes = fread(buffer, 1, size, file);

	InitShader(s, buffer, type);

	return bytes;
}
开发者ID:eygbey,项目名称:Cynfiny,代码行数:27,代码来源:g_shader.c

示例11: init

void init () 
{

	glClearColor (0.0, 0.0, 0.0, 0.0);

    //Starte the Brownian motion
	head = getRandomStart(minX, maxX, minY, maxY);
	curr = head;

		
	glGenBuffers( 2, &buffers[0] );
	


    glBindBuffer( GL_ARRAY_BUFFER, buffers[0] );
	glBufferData( GL_ARRAY_BUFFER, sizeof(bBox), bBox, GL_STATIC_DRAW );

	// Load shaders and use the resulting shader program
    program = InitShader( "vshader23_v110.glsl","fshader23_v110.glsl" );
    glUseProgram( program );
	projmat_loc = glGetUniformLocation(program, "projmat");
	modelview_loc = glGetUniformLocation(program, "modelview");
	draw_color_loc = glGetUniformLocation(program, "vColor");


    // set up vertex attributes arrays
    GLuint vPosition = glGetAttribLocation( program, "vPosition" );
	glEnableVertexAttribArray( vPosition );
    glVertexAttribPointer( vPosition, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0) );
	
	width = maxX - minX;
	height = maxY - minY;
}
开发者ID:Tampy,项目名称:CS537,代码行数:33,代码来源:hwk1.cpp

示例12: BaseShader

PulsingPlanetShader::PulsingPlanetShader(ID3D11Device* device, HWND hwnd) : BaseShader(device, hwnd)
{

	// Load our shader files.
	InitShader(L"../shaders/pulsing_planet_vs.hlsl", L"../shaders/pulsing_planet_ps.hlsl");

}
开发者ID:jmottershead94,项目名称:ProceduralFun,代码行数:7,代码来源:PulsingPlanetShader.cpp

示例13: myInit

void myInit( void ) {
  // Load shaders and use the resulting shader program
  GLuint program = InitShader( "./tri.vert", "./tri.frag" );
  glUseProgram( program );

  // Create a vertex array object
  GLuint vao;
  glGenVertexArrays( 1, &vao );
  glBindVertexArray( vao );

  // Create and initalize a buffer object
  GLuint buffer;
  glGenBuffers( 1, &buffer );
  glBindBuffer( GL_ARRAY_BUFFER, buffer );
  glBufferData( GL_ARRAY_BUFFER, sizeof(points), points, GL_STATIC_DRAW );

  // set up vertex arrays 
  GLuint vPosition = glGetAttribLocation( program, "vPosition" );
  glEnableVertexAttribArray( vPosition );
  glVertexAttribPointer( vPosition, 4, GL_FLOAT, GL_FALSE, 0, 
          BUFFER_OFFSET(0) );


  glClearColor( 1.0, 1.0, 1.0, 1.0 );

}
开发者ID:rodriggochaves,项目名称:pcg,代码行数:26,代码来源:triangulo.cpp

示例14: init

void init()
{

 // Create a vertex array object
    GLuint vao;
    glGenVertexArraysAPPLE( 1, &vao );
    glBindVertexArrayAPPLE( vao );

/* set up buffer object */

   glGenBuffers(1, buffers);
   glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
   glBufferData(GL_ARRAY_BUFFER, sizeof(square), square, GL_STATIC_DRAW);

   program = InitShader("vshader48.glsl", "fshader48.glsl");
   glUseProgram( program );

   loc = glGetAttribLocation(program, "vPosition");
   glEnableVertexAttribArray(loc);
   glVertexAttribPointer(loc, 4, GL_FLOAT, GL_FALSE, 0, 0);
   matrix_loc = glGetUniformLocation(program, "model_view");
   projection_loc = glGetUniformLocation(program, "projection");
   color_loc = glGetUniformLocation(program, "fcolor");

   for(int i =0; i<4; i++) for(int j =0; j<4;j++) m[i][j] = 0.0;
   m[0][0] = m[1][1] = m[2][2] = 1.0;
   m[3][1] = -1.0/light[1];

   glClearColor(1.0, 1.0, 1.0, 1.0); /* white background */
}
开发者ID:jetblack87,项目名称:cs537,代码行数:30,代码来源:example8.cpp

示例15: glutInit

void Game::init(int* argcp, char** argvp) {
    glutInit(argcp, argvp);
    glutInitDisplayMode( GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
    glutInitWindowSize (480, 480);
    glutInitContextVersion( 3, 2 );
    glutInitContextProfile( GLUT_CORE_PROFILE );
    glutCreateWindow ("Ablockalypse");
    glutSetWindowTitle("Ablockalypse");
    glutSetIconTitle("Ablockalypse");
    
    glewExperimental = GL_TRUE;
    glewInit ();

    // do shader stuff here...
    GLuint program = InitShader( "vshader.glsl", "fshader.glsl" );
    glUseProgram( program );

    vPosition = glGetAttribLocation( program, "vPosition" );
    vColor = glGetAttribLocation( program, "vColor" );
    xlate = glGetUniformLocation( program, "xlate" );

    initGeometry (paddle);
    initGeometry (ball);
    initBricks ();

    glEnable( GL_DEPTH_TEST );
    glClearColor(0, 0, 0, 0); 
}
开发者ID:jrd730,项目名称:Ablockalypse,代码行数:28,代码来源:game.cpp


注:本文中的InitShader函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。