本文整理汇总了C++中InitOpenGL函数的典型用法代码示例。如果您正苦于以下问题:C++ InitOpenGL函数的具体用法?C++ InitOpenGL怎么用?C++ InitOpenGL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InitOpenGL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int
main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
screen_width = framebuffer_width * zoomed_pixel_size;
screen_height = framebuffer_height * zoomed_pixel_size;
glutInitWindowSize(screen_width, screen_height);
glutInitWindowPosition(20, 20);
glutCreateWindow("Triangle rasterization");
glutDisplayFunc(&DrawScene);
glutIdleFunc(&DrawScene);
//glutReshapeFunc(&ReSizeScene);
//glutSpecialFunc(&specialKeyPressed);
glutKeyboardFunc(&KeyPressed);
//glutMouseFunc(&mouseFunc);
//glutMotionFunc(&motionFunc);
InitOpenGL();
glutMainLoop();
return 1;
}
示例2: CreateWnd
// CreateWnd: creates a full screen window to span the projectors
void CreateWnd(HINSTANCE &hinst, int width, int height, int depth)
{
// Find the middle projector
POINT pt;
pt.x = -SCRWIDTH;
pt.y = 100;
HMONITOR hmon; // monitor handles
hmon = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST);
MONITORINFO mi;
mi.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(hmon, &mi);
// Set the window position based on the projector locations
int posx1 = mi.rcMonitor.left;
int posy1 = mi.rcMonitor.top;
// Constants for fullscreen mode
long wndStyle = WS_POPUP | WS_VISIBLE;
// create the window
hwnd1 = CreateWindowEx(NULL,
WNDCLASSNAME,
WNDNAME,
wndStyle | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
posx1, posy1,
width, height,
NULL,
NULL,
hinst,
NULL);
hdc1 = GetDC(hwnd1);
PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
SCRDEPTH,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
32,
0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0
};
indexPixelFormat = ChoosePixelFormat(hdc1, &pfd);
SetPixelFormat(hdc1, indexPixelFormat, &pfd);
// Setup OpenGL
hglrc = wglCreateContext(hdc1);
wglMakeCurrent(hdc1, hglrc);
glewExperimental = GL_TRUE;
glewInit();
InitOpenGL();
ShowWindow(hwnd1, SW_SHOW); // everything went OK, show the window
UpdateWindow(hwnd1);
}
示例3: glViewport
void WindowManager::Reinitialize()
{
glViewport(0,0,_Window->w,_Window->h); // Resize OpenGL Viewport to fit the screen/window
IsGLErrors("ToggleFullscreen");
InitOpenGL();
TM->ReloadTextures();
GetRenderer()->ReinitializeAll();
_Active=true;
}
示例4: TryCompileShader
int TryCompileShader(GLenum eGLSLShaderType, char* inFilename, char* shader, double* pCompileTime)
{
GLint iCompileStatus;
GLuint hShader;
Timer_t timer;
InitTimer(&timer);
InitOpenGL();
hShader = glCreateShaderObjectARB(eGLSLShaderType);
glShaderSourceARB(hShader, 1, (const char **)&shader, NULL);
ResetTimer(&timer);
glCompileShaderARB(hShader);
*pCompileTime = ReadTimer(&timer);
/* Check it compiled OK */
glGetObjectParameterivARB (hShader, GL_OBJECT_COMPILE_STATUS_ARB, &iCompileStatus);
if (iCompileStatus != GL_TRUE)
{
FILE* errorFile;
GLint iInfoLogLength = 0;
char* pszInfoLog;
bstring filename = bfromcstr(inFilename);
char* cstrFilename;
glGetObjectParameterivARB (hShader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &iInfoLogLength);
pszInfoLog = malloc(iInfoLogLength);
printf("Error: Failed to compile GLSL shader\n");
glGetInfoLogARB (hShader, iInfoLogLength, NULL, pszInfoLog);
printf(pszInfoLog);
bcatcstr(filename, "_compileErrors.txt");
cstrFilename = bstr2cstr(filename, '\0');
//Dump to file
errorFile = fopen(cstrFilename, "w");
fprintf(errorFile, pszInfoLog);
fclose(errorFile);
bdestroy(filename);
free(cstrFilename);
free(pszInfoLog);
return 0;
}
return 1;
}
示例5: main
int main (int argc, char **argv)
{
glutInit(&argc, argv);
CreateGlutWindow();
CreateGlutCallbacks();
InitOpenGL();
glutMainLoop();
ExitGlut();
return 0;
}
示例6: Install
/**
* @brief Initializes the SpringApp instance
* @return whether initialization was successful
*/
bool SpringApp::Initialize ()
{
if (!ParseCmdLine ())
return false;
#ifdef WIN32
// Initialize crash reporting
Install( (LPGETLOGFILE) crashCallback, "[email protected]", "TA Spring Crashreport");
#endif
// Initialize class system
creg::ClassBinder::InitializeClasses ();
#ifndef NO_LUA
// Initialize lua bindings
CLuaBinder lua;
if (!lua.LoadScript("testscript.lua"))
handleerror(NULL, lua.lastError.c_str(), "lua",MBF_OK|MBF_EXCL);
#endif
InitVFS ();
if (!InitWindow ("RtsSpring"))
{
SDL_Quit ();
return false;
}
// Global structures
ENTER_SYNCED;
gs=new CGlobalSyncedStuff();
ENTER_UNSYNCED;
gu=new CGlobalUnsyncedStuff();
InitOpenGL();
palette.Init();
// Initialize keyboard
SDL_EnableUNICODE(1);
SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
SDL_SetModState (KMOD_NONE);
keys = new Uint8[SDLK_LAST];
memset (keys,0,sizeof(Uint8)*SDLK_LAST);
// Initialize font
font = new CglFont(32,223);
LoadExtensions();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_GL_SwapBuffers();
CreateGameSetup ();
return true;
}
示例7: CreateNewWindow
bool CreateNewWindow() {
HWND hWnd = CreateNewWindow_impl();
m_hWnd = hWnd;
if (hWnd != INVALID_HANDLE_VALUE) {
RegisterWindow(hWnd, this);
ResetTimer();
InitOpenGL(hWnd);
return true;
}
return false;
}
示例8: GLRB_DriverInit
/*
@@@@@@@@@@@@@@@@@@@@@
Returns the opengl graphics driver and sets up global state
@@@@@@@@@@@@@@@@@@@@@
*/
void GLRB_DriverInit( void )
{
GFX_Shutdown = GLRB_Shutdown;
GFX_UnbindResources = GLRB_RestoreTextureState;
GFX_LastError = GLRB_LastError;
GFX_ReadPixels = GLRB_ReadPixels;
GFX_ReadDepth = GLRB_ReadDepth;
GFX_ReadStencil = GLRB_ReadStencil;
GFX_CreateImage = GL_CreateImage;
GFX_DeleteImage = GL_DeleteImage;
GFX_UpdateCinematic = GL_UpdateCinematic;
GFX_DrawImage = GLRB_DrawImage;
GFX_GetImageFormat = GL_GetImageFormat;
GFX_SetGamma = GLRB_SetGamma;
GFX_GetFrameImageMemoryUsage = GL_SumOfUsedImages;
GFX_GraphicsInfo = GLRB_GfxInfo_f;
GFX_Clear = GL_Clear;
GFX_SetProjectionMatrix = GL_SetProjection;
GFX_GetProjectionMatrix = GL_GetProjection;
GFX_SetModelViewMatrix = GL_SetModelView;
GFX_GetModelViewMatrix = GL_GetModelView;
GFX_SetViewport = GL_SetViewport;
GFX_Flush = GL_Finish;
GFX_SetState = GL_State;
GFX_ResetState2D = GLRB_ResetState2D;
GFX_ResetState3D = GLRB_ResetState3D;
GFX_SetPortalRendering = GLRB_SetPortalRendering;
GFX_SetDepthRange = GL_SetDepthRange;
GFX_SetDrawBuffer = GLRB_SetDrawBuffer;
GFX_EndFrame = GLimp_EndFrame;
GFX_MakeCurrent = GLimp_MakeCurrent;
GFX_ShadowSilhouette = GLRB_ShadowSilhouette;
GFX_ShadowFinish = GLRB_ShadowFinish;
GFX_DrawSkyBox = GLRB_DrawSkyBox;
GFX_DrawBeam = GLRB_DrawBeam;
GFX_DrawStageGeneric = GLRB_StageIteratorGeneric;
GFX_DrawStageVertexLitTexture = GLRB_StageIteratorVertexLitTexture;
GFX_DrawStageLightmappedMultitexture = GLRB_StageIteratorLightmappedMultitexture;
GFX_DebugDrawAxis = GLRB_SurfaceAxis;
GFX_DebugDrawTris = GLRB_DebugDrawTris;
GFX_DebugDrawNormals = GLRB_DebugDrawNormals;
GFX_DebugSetOverdrawMeasureEnabled = GLRB_SetOverdrawMeasureEnabled;
GFX_DebugSetTextureMode = GL_TextureMode;
GFX_DebugDrawPolygon = GLRB_DebugPolygon;
InitOpenGL();
// Copy the resource strings to the vgConfig
Q_strncpyz( vdConfig.renderer_string, glState.renderer_string, sizeof( vdConfig.renderer_string ) );
Q_strncpyz( vdConfig.vendor_string, glState.vendor_string, sizeof( vdConfig.vendor_string ) );
Q_strncpyz( vdConfig.version_string, glState.version_string, sizeof( vdConfig.version_string ) );
}
示例9: TryCompileShader
int TryCompileShader(GLenum eGLSLShaderType, const char* inFilename, char* shader, double* pCompileTime)
{
GLint iCompileStatus;
GLuint hShader;
Timer_t timer;
InitTimer(&timer);
InitOpenGL();
hShader = glCreateShaderObjectARB(eGLSLShaderType);
glShaderSourceARB(hShader, 1, (const char **)&shader, NULL);
ResetTimer(&timer);
glCompileShaderARB(hShader);
*pCompileTime = ReadTimer(&timer);
/* Check it compiled OK */
glGetObjectParameterivARB (hShader, GL_OBJECT_COMPILE_STATUS_ARB, &iCompileStatus);
FILE* errorFile;
GLint iInfoLogLength = 0;
char* pszInfoLog;
std::string filename;
filename += inFilename;
glGetObjectParameterivARB (hShader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &iInfoLogLength);
if (iInfoLogLength > 1)
{
pszInfoLog = new char[iInfoLogLength];
if (iCompileStatus != GL_TRUE)
printf("Error: Failed to compile GLSL shader\n");
glGetInfoLogARB(hShader, iInfoLogLength, NULL, pszInfoLog);
printf(pszInfoLog);
filename += "_compileErrors.txt";
//Dump to file
errorFile = fopen(filename.c_str(), "w");
fprintf(errorFile, pszInfoLog);
fclose(errorFile);
delete[] pszInfoLog;
}
return iCompileStatus == GL_TRUE ? 1 : 0;
}
示例10: Win32InitOpenGL
internal void
Win32InitOpenGL(HDC WindowDC)
{
Win32LoadWGLExtensions();
HGLRC OpenGLRC = 0;
bool32 ModernContext = true;
if(wglCreateContextAttribsARB)
{
int Win32OpenGLAttribs[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB,
3,
WGL_CONTEXT_MINOR_VERSION_ARB,
1,
WGL_CONTEXT_FLAGS_ARB,
WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB
#if LUDUS_INTERNAL
|
WGL_CONTEXT_DEBUG_BIT_ARB
#endif
,
WGL_CONTEXT_PROFILE_MASK_ARB,
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
0
};
Win32SetPixelFormat(WindowDC);
OpenGLRC = wglCreateContextAttribsARB(WindowDC, 0, Win32OpenGLAttribs);
}
if(!OpenGLRC)
{
ModernContext = false;
OpenGLRC = wglCreateContext(WindowDC);
}
if(wglMakeCurrent(WindowDC, OpenGLRC))
{
InitOpenGL(ModernContext);
if(wglSwapInterval)
{
wglSwapInterval(1);
}
}
else
{
Win32Log("Couldnt set OpenGL context");
LOG_FORMATTED_ERROR(4096);
}
}
示例11: SDL_Init
SCSerror SCSapplication::Create (const SCSstring sTitle, const SCSstring sVersion, const SCSbool iFullscreen)
{
m_sTitle = sTitle;
m_sVersion = sVersion;
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
if (SCSdisplay::Singleton()->Create(iFullscreen)) return scsHandleError(SCS_ERROR_FRAMEWORK | SCS_ERROR_CREATE | SCS_ERROR_DISPLAY);
SDL_WM_SetCaption(m_sTitle.c_str(), m_sTitle.c_str());
InitOpenGL();
SCSgraphics::Singleton()->Init();
SCSmixer::Singleton()->Init(32);
return SCS_ERROR_NONE;
}
示例12: printf
openni::Status SampleViewer::Init(int argc, char **argv)
{
// initial ros node
ros::init(argc, argv, "user_viewer");
ros::NodeHandle n;
movePublisher = n.advertise<std_msgs::String>("cmd_erica", 20);
// initial variable
rightShoulderYaw = 0, rightShoulderPitch = 0, rightElbowTheta = 0, rightElbowYaw = 0;
rightShoulderYawPub = 0, rightShoulderPitchPub = 0, rightElbowYawPub = 0, rightElbowThetaPub = 0;
leftShoulderYaw = 0, leftShoulderPitch = 0, leftElbowTheta = 0, leftElbowYaw = 0;
leftShoulderYawPub = 0, leftShoulderPitchPub = 0, leftElbowYawPub = 0, leftElbowThetaPub = 0;
m_pTexMap = NULL;
openni::Status rc = openni::OpenNI::initialize();
if (rc != openni::STATUS_OK)
{
printf("Failed to initialize OpenNI\n%s\n", openni::OpenNI::getExtendedError());
return rc;
}
const char* deviceUri = openni::ANY_DEVICE;
for (int i = 1; i < argc-1; ++i)
{
if (strcmp(argv[i], "-device") == 0)
{
deviceUri = argv[i+1];
break;
}
}
rc = m_device.open(deviceUri);
if (rc != openni::STATUS_OK)
{
printf("Failed to open device\n%s\n", openni::OpenNI::getExtendedError());
return rc;
}
nite::NiTE::initialize();
if (m_pUserTracker->create(&m_device) != nite::STATUS_OK)
{
return openni::STATUS_ERROR;
}
return InitOpenGL(argc, argv);
}
示例13: main
//-----------------------------------------------------------------------------
int main(int argc, char **argv) {
// Inicializações.
InitOpenGL(&argc, argv);
InitCallBacks();
InitDataStructures();
// Ajusta a função que chama as funções do mygl.h
DrawFunc = MyGlDraw;
// Framebuffer scan loop.
glutMainLoop();
return 0;
}
示例14: CreateGameWindow
HDC GameWindow::Init(HINSTANCE hinstance)
{
m_hinstance = hinstance;
CreateGameWindow("IN3026 Template");
// If we never got a valid window handle, quit the program
if(m_hwnd == NULL) {
return NULL;
} else {
// INIT OpenGL
InitOpenGL();
return m_hdc;
}
}
示例15: RE_Init
/*
===============
RE_Init
===============
*/
void RE_Init( void ) {
int err;
ST_Printf( PRINT_R_VERBOSE, "----- R_Init -----\n" );
R_Register();
InitOpenGL();
err = glGetError();
if ( err != GL_NO_ERROR )
ST_Printf ( PRINT_R_VERBOSE, "glGetError() = 0x%x\n", err );
ST_Printf( PRINT_R_VERBOSE, "----- finished R_Init -----\n" );
}