• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ InitShader函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: BaseShader

//////////////////////////////////////////////////////////
//======================================================//
//						Constructor						//
//======================================================//
// This will be used for initialising our shader files.	//
//////////////////////////////////////////////////////////
MasterShader::MasterShader(ID3D11Device* device, HWND hwnd) : BaseShader(device, hwnd)
{

	// Load in our shader files.
	InitShader(L"../shaders/master_vs.hlsl", L"../shaders/quad_tessellation_hs.hlsl", L"../shaders/quad_tessellation_ds.hlsl", L"../shaders/master_ps.hlsl");

}
开发者ID:jmottershead94,项目名称:3DPeace,代码行数:13,代码来源:MasterShader.cpp


示例17: BaseShader

LightAlphaMapShader::LightAlphaMapShader(ID3D11Device* device, HWND hwnd, 
  sz::ConstBufManager &buf_man, unsigned int lights_num) : 
    BaseShader(device, hwnd), material_buf_(nullptr) {
  InitShader(buf_man, L"../shaders/light_alpha_map_vs.hlsl", 
    L"../shaders/light_alpha_map_ps.hlsl", L"../shaders/tessellation_hs.hlsl",
    L"../shaders/light_ds.hlsl", lights_num);
}
开发者ID:snowzurfer,项目名称:graph-lemon,代码行数:7,代码来源:light_alpha_map_shader.cpp


示例18: init

void
init( void )
{
    vec3 vertices[4] = {
	vec3( 0.0, 0.0, -1.0 ),
	vec3( 0.0, 0.942809, 0.333333 ),
	vec3( -0.816497, -0.471405, 0.333333 ),
	vec3( 0.816497, -0.471405, 0.333333 )
    };	

    // Subdivide the original tetrahedron
    divide_tetra( vertices[0], vertices[1], vertices[2], vertices[3],
		  NumTimesToSubdivide );

    // 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 );

    // First, we create an empty buffer of the size we need by passing
    //   a NULL pointer for the data values
    glBufferData( GL_ARRAY_BUFFER, sizeof(points) + sizeof(colors),
		  NULL, GL_STATIC_DRAW );

    // Next, we load the real data in parts.  We need to specify the
    //   correct byte offset for placing the color data after the point
    //   data in the buffer.  Conveniently, the byte offset we need is
    //   the same as the size (in bytes) of the points array, which is
    //   returned from "sizeof(points)".
    glBufferSubData( GL_ARRAY_BUFFER, 0, sizeof(points), points );
    glBufferSubData( GL_ARRAY_BUFFER, sizeof(points), sizeof(colors), colors );

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

    // Initialize the vertex position attribute from the vertex shader    
    GLuint vPosition = glGetAttribLocation( program, "vPosition" );
    glEnableVertexAttribArray( vPosition );
    glVertexAttribPointer( vPosition, 3, GL_FLOAT, GL_FALSE, 0,
                           BUFFER_OFFSET(0) );

    // Likewise, initialize the vertex color attribute.  Once again, we
    //    need to specify the starting offset (in bytes) for the color
    //    data.  Just like loading the array, we use "sizeof(points)"
    //    to determine the correct value.
    GLuint vColor = glGetAttribLocation( program, "vColor" );
    glEnableVertexAttribArray( vColor );
    glVertexAttribPointer( vColor, 3, GL_FLOAT, GL_FALSE, 0,
                           BUFFER_OFFSET(sizeof(points)) );

    glEnable( GL_DEPTH_TEST );

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


示例19: main

int
main(int argc, char **argv)
{
    colorcube();

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
    glutInitWindowSize(500, 500);
    glutInitContextVersion( 3, 2 );
    glutInitContextProfile( GLUT_CORE_PROFILE );

    glutCreateWindow("colorcube");

	glewExperimental = GL_TRUE;
    glewInit();

    program  = InitShader("vshader72.glsl", "fshader72.glsl");

    init();

    glutReshapeFunc(myReshape);
    glutDisplayFunc(display);
    glutIdleFunc(spinCube);
    glutMouseFunc(mouse);

    glutKeyboardFunc(key);
    glutMainLoop();
    return 0;
}
开发者ID:matthiascy,项目名称:interactive_computer_graphics,代码行数:29,代码来源:example2.cpp


示例20: setupData

void setupData()
{
    // build tree
    rebuildTree();

    // matrices
    setView();
    
    // create shader program
    GLuint sProgram = InitShader( "vert.glsl", "frag.glsl" );
    
    // object buffer
    glGenBuffers( 1, &objectBuffer );
    glBindBuffer( GL_ARRAY_BUFFER, objectBuffer );
    
    // vertices
    vertLoc = glGetAttribLocation( sProgram, "a_vPosition" );

    // indices
    glGenBuffers( 1, &indexBuffer );
    glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, indexBuffer );

    // texture coordinates
    //texCoordLoc = glGetAttribLocation( sProgram, "a_vTexCoord" );
    
    // normals
    normalLoc = glGetAttribLocation( sProgram, "a_vNormal" );
    
    // buffer to GPU
    sendData();
}
开发者ID:blaws,项目名称:Tree,代码行数:31,代码来源:tree.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ InitStack函数代码示例发布时间:2022-05-30
下一篇:
C++ InitRandom函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap