本文整理汇总了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();
}
示例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);
}
示例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");
}
}
示例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();
}
示例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);
}
示例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);
}
示例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 );
}
示例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 */
}
示例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;
}
示例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;
}
示例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;
}
示例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");
}
示例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 );
}
示例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 */
}
示例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);
}