本文整理汇总了C++中InitGL函数的典型用法代码示例。如果您正苦于以下问题:C++ InitGL函数的具体用法?C++ InitGL怎么用?C++ InitGL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InitGL函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: SDL_GL_SetAttribute
int Engine::Init(std::string title)
{
// Start SDL
if(SDL_Init( SDL_INIT_VIDEO ) == -1)
return -1;
// Setup double Buffering
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
//kill sdl on exiting
atexit(SDL_Quit);
// setup screen (with OpenGL)
screen = SDL_SetVideoMode(ScreenWidth, ScreenHeight, BitsPerPixel, SDL_OPENGL);
if(screen == NULL)
return -1;
// set the window title
SDL_WM_SetCaption(title.c_str(), NULL);
//Initialise OpenGL
InitGL();
//Intialise Audio
soundManager = new SoundManager();
// seed random
srand(time(NULL));
return 0;
}
开发者ID:EvanCGriffin,项目名称:soccergame,代码行数:32,代码来源:Engine.cpp
示例2: SetCurrent
void Pcb3D_GLCanvas::Redraw( void )
/**********************************/
{
SetCurrent();
InitGL();
glMatrixMode(GL_MODELVIEW); /* position viewer */
/* transformations */
GLfloat mat[4][4];
glTranslatef(Draw3d_dx, Draw3d_dy, 0.0F);
build_rotmatrix( mat, g_Parm_3D_Visu.m_Quat );
glMultMatrixf( &mat[0][0] );
glRotatef(g_Parm_3D_Visu.m_Rot[0], 1.0, 0.0, 0.0);
glRotatef(g_Parm_3D_Visu.m_Rot[1], 0.0, 1.0, 0.0);
glRotatef(g_Parm_3D_Visu.m_Rot[2], 0.0, 0.0, 1.0);
if( m_gllist ) glCallList( m_gllist );
else
{
m_gllist = CreateDrawGL_List();
// m_gllist = DisplayCubeforTest();
}
glFlush();
SwapBuffers();
}
开发者ID:BackupTheBerlios,项目名称:kicad-svn,代码行数:29,代码来源:3d_draw.cpp
示例3: main
int main(int argc, char* argv[]){
cout << PROGRAM_NAME << " - " << VERSION << endl
<< "BYU CS 455 - Fall 2012" << endl << endl
<< "Created by:" << endl
<< "\tJosh Davis" << endl
<< "\tTyler Gill" << endl
<< "\tMorgan Strong" << endl
<< "\tJames Williams" << endl << endl;
glutInit(&argc, argv);
/* setting up double buffering rbg and depth for this */
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(windowWidth, windowHeight);
glutInitWindowPosition(100, 100);
/* this name needs to match the name of the window in DrawGLScene */
glutCreateWindow(windowName);
InitGL();
/* the draw function will draw once and no more */
glutDisplayFunc(DrawGLScene);
/* this is the idle function it gets called as much as possible */
glutIdleFunc(IdleGLScene);
/* This is called everytime the window is altered */
glutReshapeFunc(ReSizeGLScene);
/* this gets called on a keyboard event */
//glutKeyboardFunc(GLKeyDown);
//glutSpecialFunc(SpecialKeys);
//glutSpecialUpFunc(SpecialKeysUp);
// Game initialization
ObjectMan* man = ObjectMan::GetInstance();
InputMan* inman = InputMan::GetInstance();
cout << "Running Game..." << endl << endl;
/* Gets the loop rolling */
try{
/*
* This loop wont return ever so we are going to play some tricks
* to make it look like it exits when it is actually done. That is why
* we use the try catch.
*/
// TODO: Override the x button on the window.
glutMainLoop();
}
catch(const char* msg){
printf(msg);
HWND hwnd = FindWindow("glut", windowName);
ShowWindow(hwnd, SW_HIDE);
Sleep(500);
}
return 0;
}
开发者ID:tygill,项目名称:Racer,代码行数:59,代码来源:main.cpp
示例4: InitManagers
void CoreMac::Init(const ax::Size& frame_size)
{
// std::cout << "Init axCoreMac." << std::endl;
InitManagers();
InitGL();
ResizeFrame(frame_size);
// _size = frame_size;
}
开发者ID:axlib,项目名称:OpenAX,代码行数:8,代码来源:axCoreMac.cpp
示例5: Entity
Player::Player(World& world, glm::vec3 position, glm::vec2 rotation, float speed)
: Entity(world,
AABB(position, glm::vec3(-0.4, 0, -0.4), glm::vec3(0.4, 1.8, 0.4)),
rotation, speed),
m_blockSelected(glm::vec3(), glm::vec3(), glm::vec3())
{
InitGL();
}
开发者ID:lolzballs,项目名称:Blocket,代码行数:8,代码来源:player.cpp
示例6: InitGL
BOOL CIdleOpenGLWnd::OnCreate(LPCREATESTRUCT lpcs)
{
if (!MSG_FORWARD_WM_CREATE(COpenGLWnd, lpcs))
return FALSE;
m_hrc = InitGL();
return TRUE;
}
开发者ID:dlarudgus20,项目名称:IkhWinLib2,代码行数:8,代码来源:CIdleOpenGLWnd.cpp
示例7: InitEverything
bool InitEverything(SDL_GLContext& g_Context, SDL_Window*& g_Window, std::unique_ptr<Scene>& pScene) {
if (InitSDL())
if (InitGL(g_Context, g_Window))
if (InitSound())
if (InitPython())
if (InitScene(pScene))
return true;
return false;
}
开发者ID:mynameisjohn,项目名称:PyRenderer,代码行数:9,代码来源:Init.cpp
示例8: InitGL
void View2::OnInitialUpdate()
{
CView::OnInitialUpdate();
LEFT_DOWN=false;
RIGHT_DOWN=false;
InitGL();
}
开发者ID:pigoblock,项目名称:TFYP,代码行数:9,代码来源:View2.cpp
示例9: main
int main(int argc, char **argv) {
if (argc < 6) {
printf("usage: leitura arqin.raw width height slices dslices colormap\n");
exit(1);
}
glutInit(&argc, argv);
//glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100, 100);
glutInitWindowSize(640, 640);
glutCreateWindow("Teste de Vizualizacao com textura 3D");
glutDisplayFunc(&DrawGLScene);
glutIdleFunc(&DrawGLScene);
glutReshapeFunc(&ReSizeGLScene);
glutKeyboardFunc(&keyPressed);
glutMotionFunc(MoveMouseBotaoPressionado);
glutPassiveMotionFunc(MoveMouse);
glutMouseFunc(GerenciaMouse);
raw = readRAW(argc, argv);
GLenum err = glewInit();
if (GLEW_OK != err) {
fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
}
if (glewIsSupported("GL_VERSION_2_1"))
printf("Ready for OpenGL 2.1\n");
else {
printf("OpenGL 2.1 not supported\n");
exit(1);
}
if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader
&& GL_EXT_geometry_shader4)
printf("Ready for GLSL - vertex, fragment, and geometry units\n");
else {
printf("Not totally ready :( \n");
exit(1);
}
if(argc==7) colorMapRead(argv[6],cm);
else {
createColorMap(cm);
//colorMapWrite("teste.map", cm);
//colorMapRead("teste.map", cm);
}
InitGL(640, 640);
/* Start Event Processing Engine */
glutMainLoop();
return 1;
}
开发者ID:agnus-fem,项目名称:VisDaVol,代码行数:57,代码来源:main.cpp
示例10: main
int main( int argc, char* argv[] )
{
g_InitialCameraPosition = glm::vec3( 0, 0, 10 );
g_Camera.SetPosition( g_InitialCameraPosition );
g_Camera.SetRotation( g_InitialCameraRotation );
InitGL(argc, argv);
InitGLEW();
// Load some shaders.
GLuint vertexShader = LoadShader( GL_VERTEX_SHADER, "../data/shaders/simpleShader.vert" );
GLuint fragmentShader = LoadShader( GL_FRAGMENT_SHADER, "../data/shaders/simpleShader.frag" );
std::vector<GLuint> shaders;
shaders.push_back(vertexShader);
shaders.push_back(fragmentShader);
// Create the shader program.
g_ShaderProgram = CreateShaderProgram( shaders );
assert( g_ShaderProgram != 0 );
GLint positionAtribID = glGetAttribLocation( g_ShaderProgram, "in_position" );
GLint colorAtribID = glGetAttribLocation( g_ShaderProgram, "in_color" );
g_uniformMVP = glGetUniformLocation( g_ShaderProgram, "MVP" );
// Create a VAO for the cube.
glGenVertexArrays( 1, &g_vaoCube );
glBindVertexArray( g_vaoCube );
GLuint vertexBuffer, indexBuffer;
glGenBuffers( 1, &vertexBuffer );
glGenBuffers( 1, &indexBuffer );
glBindBuffer( GL_ARRAY_BUFFER, vertexBuffer );
glBufferData( GL_ARRAY_BUFFER, sizeof(g_Vertices), g_Vertices, GL_STATIC_DRAW );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, indexBuffer );
glBufferData( GL_ELEMENT_ARRAY_BUFFER, sizeof(g_Indices), g_Indices, GL_STATIC_DRAW );
glVertexAttribPointer( positionAtribID, 3, GL_FLOAT, false, sizeof(VertexXYZColor),
reinterpret_cast<const GLvoid*>(offsetof(VertexXYZColor,m_Pos)) );
glEnableVertexAttribArray( positionAtribID );
glVertexAttribPointer( colorAtribID, 3, GL_FLOAT, false, sizeof(VertexXYZColor),
reinterpret_cast<const GLvoid*>(offsetof(VertexXYZColor,m_Color)));
glEnableVertexAttribArray( colorAtribID );
// Make sure we disable and unbind everything to prevent rendering issues later.
glBindVertexArray( 0 );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
glDisableVertexAttribArray( positionAtribID );
glDisableVertexAttribArray( colorAtribID );
glutMainLoop();
}
开发者ID:LingboTang,项目名称:GameDev,代码行数:56,代码来源:mainCube.cpp
示例11: InitGL
//---------------------------------------------------------------------------
int CFabAtHomeView::OnCreate(LPCREATESTRUCT lpCreateStruct)
//---------------------------------------------------------------------------
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
InitGL(); // initialize OpenGL
return 0;
}
开发者ID:idle-git,项目名称:fabathome,代码行数:11,代码来源:FabAtHomeView.cpp
示例12: main
int main(int argc, char* argv[])
{
g_PreviousTime = std::clock();
std::string windowname = "test";
InitGL(argc, argv, windowname); //create window with name
glutMainLoop(); //enter openGL's main loop
return 0;
}
开发者ID:TheMeII,项目名称:T3DRIS,代码行数:10,代码来源:Engine.cpp
示例13: main
int main(int argc,char **argv)
{
srandom(123456789);
init_particles();
InitGL(argc, argv);
InitCL();
glutDisplayFunc(mydisplayfunc);
glutKeyboardFunc(getout);
glutMainLoop();
}
开发者ID:awbrenn,项目名称:particle_sytem,代码行数:10,代码来源:particle_system.cpp
示例14: main
// The ubiquituous main function.
int main ( int argc, char** argv ) // Create Main Function For Bringing It All Together
{
// get the the filename from the commandline.
/*if (argc!=2)
{
printf("usage: %s trackfilname\n", argv[0]);
system("PAUSE");
exit(1);
}*/
/* load the track, this routine aborts if it fails */
g_Track.loadSplineFrom("track");
/*** The following are commands for setting up GL ***/
/*** No OpenGl call should be before this sequence!!!! ***/
/* Initialize glut */
glutInit(&argc,argv);
/* Set up window modes */
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
/* Set window position (where it will appear when it opens) */
glutInitWindowPosition(0,0);
/* Set size of window */
glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT);
/* Create the window */
glutCreateWindow ( "CMPSC 458: Rollercoaster" ); // Window Title (argv[0] for current directory as title)
/**** Call to our initialization routine****/
InitGL ();
/* tells glut to use a particular display function to redraw */
glutDisplayFunc(display);
/** allow the user to quit using the right mouse button menu **/
/* Set menu function callback */
g_iMenuId = glutCreateMenu(menufunc);
/* Set identifier for menu */
glutSetMenu(g_iMenuId);
/* Add quit option to menu */
glutAddMenuEntry("Quit",0);
/* Add any other menu functions you may want here. The format is:
* glutAddMenuEntry(MenuEntry, EntryIndex)
* The index is used in the menufunc to determine what option was selected
*/
/* Attach menu to right button clicks */
glutAttachMenu(GLUT_RIGHT_BUTTON);
/* Set idle function. You can change this to call code for your animation,
* or place your animation code in doIdle */
glutIdleFunc(doIdle);
/* callback for keyboard input */
glutKeyboardFunc(keyboardfunc);
glutMainLoop ( ); // Initialize The Main Loop
return 0;
}
开发者ID:jbl5088,项目名称:psu,代码行数:56,代码来源:rc_main.cpp
示例15: _tWinMain
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPTSTR lpCmdLine,
_In_ int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
angle = 0.0f;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_OPENGLWIN32PROJECT, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_OPENGLWIN32PROJECT));
InitGL();
glClear(GL_COLOR_BUFFER_BIT);
bExit = false;
//main game loop
while (!bExit)
{
// Main message loop:
PeekMessage(&msg, hWnd, NULL, NULL, PM_REMOVE);
if (msg.message == WM_QUIT)
{
bExit = true;
}
else
{
//draw functions
Render();
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
开发者ID:jason-bunn,项目名称:Win32Tutorials,代码行数:55,代码来源:OpenGlWin32Project.cpp
示例16: m_ptrWnd
NaGsView::NaGsView(CWnd* pWnd, NaGsDisplayContext* ctx) : m_ptrWnd(pWnd), m_theContext(ctx)
{
m_xRot = -45.0f;
m_zRot = -45.0f;
m_yRot = 0;
m_xTrans = m_yTrans = m_zTrans = 0.0f;
m_myCamera = new NaDbCamera();
m_myViewType = GLAXONVIEW;
m_myProjType = GLORTHOGRAPHIC;
m_nRange = 500;
m_bkRed = 134 / 255.0;
m_bkGreen = 193 / 255.0;
m_bkBlue = 239 / 255.0;
m_displayMode = GLSHADED;
m_antialias = false;
//1
m_colorv[0].amb[0] = 0.0F; m_colorv[0].amb[1] = 0.0F; m_colorv[0].amb[2] = 0.0F;
m_colorv[0].diff[0] = 0.1F; m_colorv[0].diff[1] = 0.6F; m_colorv[0].diff[2] = 0.3F;
m_colorv[0].spec[0] = 1.0F; m_colorv[0].spec[1] = 1.0F; m_colorv[0].spec[2] = 1.0F;
m_colorv[0].ratio = 0.75F;
m_colorv[0].indexes[0] = 0; m_colorv[0].indexes[1] = 0; m_colorv[0].indexes[2] = 0;
//2
m_colorv[1].amb[0] = 0.0F; m_colorv[1].amb[1] = 0.0F; m_colorv[1].amb[2] = 0.0F;
m_colorv[1].diff[0] = 0.0F; m_colorv[1].diff[1] = 0.2F; m_colorv[1].diff[2] = 0.5F;
m_colorv[1].spec[0] = 1.0F; m_colorv[1].spec[1] = 1.0F; m_colorv[1].spec[2] = 1.0F;
m_colorv[1].ratio = 0.75F;
m_colorv[1].indexes[0] = 0; m_colorv[1].indexes[1] = 0; m_colorv[1].indexes[2] = 0;
//3
m_colorv[2].amb[0] = 0.0F; m_colorv[2].amb[1] = 0.05F; m_colorv[2].amb[2] = 0.05F;
m_colorv[2].diff[0] = 0.6F; m_colorv[2].diff[1] = 0.0F; m_colorv[2].diff[2] = 0.8F ;
m_colorv[2].spec[0] = 1.0F; m_colorv[2].spec[1] = 1.0F; m_colorv[2].spec[2] = 1.0F ;
m_colorv[2].ratio = 0.75F;
m_colorv[2].indexes[0] = 0; m_colorv[2].indexes[1] = 0; m_colorv[2].indexes[2] = 0 ;
m_ZoomON = false;
m_PanON = false;
m_RotON = false;
m_gridOn = false;
myTrihedron = new NaDbTrihedron;
myGrid = new NaDbGrid;
InitGL();
}
开发者ID:cybaj,项目名称:NAK,代码行数:55,代码来源:NaGsView.cpp
示例17: ParseCmdString
// In this function, we save the instance handle, then create and display the main program window.
BOOL SingleFace::InitInstance(HINSTANCE hInstance, PWSTR lpCmdLine, int nCmdShow)
{
m_hInst = hInstance; // Store instance handle in our global variable
ParseCmdString(lpCmdLine);
WCHAR szTitle[MaxLoadStringChars]; // The title bar text
LoadString(m_hInst, IDS_APP_TITLE, szTitle, ARRAYSIZE(szTitle));
static const PCWSTR RES_MAP[] = { L"80x60", L"320x240", L"640x480", L"1280x960" };
static const PCWSTR IMG_MAP[] = { L"PLAYERID", L"RGB", L"YUV", L"YUV_RAW", L"DEPTH" };
// Add mode params in title
WCHAR szTitleComplete[MAX_PATH];
swprintf_s(szTitleComplete, L"%s -- Depth:%s:%s Color:%s:%s NearMode:%s, SeatedSkeleton:%s", szTitle,
IMG_MAP[m_depthType], (m_depthRes < 0)? L"ERROR": RES_MAP[m_depthRes], IMG_MAP[m_colorType], (m_colorRes < 0)? L"ERROR": RES_MAP[m_colorRes], m_bNearMode? L"ON": L"OFF",
m_bSeatedSkeletonMode?L"ON": L"OFF");
WCHAR szWindowClass[MaxLoadStringChars]; // the main window class name
LoadString(m_hInst, IDC_SINGLEFACE, szWindowClass, ARRAYSIZE(szWindowClass));
RegisterClass(szWindowClass);
m_hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_SINGLEFACE));
m_pImageBuffer = FTCreateImage();
m_pVideoBuffer = FTCreateImage();
m_hWnd = CreateWindow(szWindowClass, szTitleComplete, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, WINDOWWIDTH, WINDOWHEIGHT, NULL, NULL, m_hInst, this);
if (!m_hWnd)
{
return FALSE;
}
ShowWindow(m_hWnd, nCmdShow);
UpdateWindow(m_hWnd);
#ifdef USEOPENGL
m_GLContext.init(m_hWnd);
InitGL();
#endif
return SUCCEEDED(m_FTHelper.Init(m_hWnd,
FTHelperCallingBack,
this,
m_depthType,
m_depthRes,
m_bNearMode,
TRUE, // if near mode doesn't work, fall back to default mode
m_colorType,
m_colorRes,
m_bSeatedSkeletonMode));
}
开发者ID:huangxiaojian,项目名称:GIT,代码行数:55,代码来源:SingleFace.cpp
示例18: main
int main(int argc, char** argv) {
OptParse(argv);
if(InitGL()) return -1;
Render();
glfwTerminate();
return 0;
}
开发者ID:chaosink,项目名称:cube-fluctuation,代码行数:11,代码来源:cube-fluctuation.cpp
示例19: WndProc
LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg) {
case WM_CREATE:
GetCursorPos(&initpoint);
InitGL(hwnd);
oldticks = GetTickCount();
TimerID = timeSetEvent (timerdelay, 0, TimeProc, (DWORD)hwnd, TIME_PERIODIC);
break;
case WM_PAINT:
{
DWORD ticks = oldticks;
POINT currpoint;
oldticks = GetTickCount();
DrawScene(hwnd, dc, oldticks - ticks);
if(fullscreen)
{
GetCursorPos(&currpoint);
if(abs(currpoint.x - initpoint.x) + (abs(currpoint.y - initpoint.y)) > 10)
PostMessage(hwnd, WM_CLOSE, 0, 0);
}
break;
}
case WM_DESTROY:
timeKillEvent(TimerID);
gluDeleteQuadric(cylinder);
wglMakeCurrent(0, 0);
wglDeleteContext(hrc);
ReleaseDC(hwnd, dc);
DeleteDC(dc);
if (fullscreen)
ShowCursor(TRUE);
PostQuitMessage(0);
break;
case WM_NOTIFY:
case WM_SYSKEYDOWN:
PostMessage(hwnd, WM_CLOSE, 0, 0);
break;
case WM_SIZE:
{
int width = LOWORD(lParam);
int height = HIWORD(lParam);
float fscale;
glViewport(0, 0, width, height);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
fscale = 0.8/(float)lvls;
glScalef(fscale, fscale, fscale);
break;
}
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
开发者ID:Nevermore2015,项目名称:reactos,代码行数:54,代码来源:cylfrac.c
示例20: realize_sub
static void realize_sub( GtkWidget* w )
{
GdkGLContext* glContext = gtk_widget_get_gl_context( w );
GdkGLDrawable* glDrawable = GDK_GL_DRAWABLE( gtk_widget_get_gl_window( w ) );
if( !gdk_gl_drawable_gl_begin( glDrawable, glContext ) )
g_assert_not_reached();
InitGL();
gdk_gl_drawable_gl_end( glDrawable );
}
开发者ID:stilewski,项目名称:Tree-Generator,代码行数:11,代码来源:main.c
注:本文中的InitGL函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论