本文整理汇总了C++中Render函数的典型用法代码示例。如果您正苦于以下问题:C++ Render函数的具体用法?C++ Render怎么用?C++ Render使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Render函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
void TileMap::Render( int OffsetX, int OffsetY, float Scale )
{
Render( OffsetX, OffsetY, Scale, Scale );
}
示例2: MainApplication
// the program starts here
void MainApplication() {
// initialise GLFW
if(!glfwInit())
throw std::runtime_error("glfwInit failed");
// open a window with GLFW
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
MainWindow = glfwCreateWindow((int)SCREEN_SIZE.x, (int)SCREEN_SIZE.y,"Rotation",NULL,NULL);
if(!MainWindow)
throw std::runtime_error("glfwOpenWindow failed. Can your hardware handle OpenGL 4.2?");
glfwSetWindowSizeCallback(MainWindow,handleResize); //callback function of GLFW to handle window resize
glfwSetKeyCallback(MainWindow,handleKeypress); //callback function to handle keypress
glfwMakeContextCurrent(MainWindow);
// initialise GLEW
glewExperimental = GL_TRUE; //stops glew crashing on OSX :-/
if(glewInit() != GLEW_OK)
throw std::runtime_error("glewInit failed");
// print out some info about the graphics drivers
std::cout << "OpenGL version: " << glGetString(GL_VERSION) << std::endl;
std::cout << "GLSL version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
std::cout << "Vendor: " << glGetString(GL_VENDOR) << std::endl;
std::cout << "Renderer: " << glGetString(GL_RENDERER) << std::endl;
// make sure OpenGL version 3.2 API is available
if(!GLEW_VERSION_4_2)
throw std::runtime_error("OpenGL 4.2 API is not available.");
// load vertex and fragment shaders into opengl
LoadShaders();
// create buffer and fill it with the points of the triangle
LoadTriangle();
// run while the window is open
double lastTime = glfwGetTime();
while(!glfwWindowShouldClose(MainWindow)){
// update the scene based on the time elapsed since last update
double thisTime = glfwGetTime();
Update(thisTime - lastTime);
lastTime = thisTime;
// process pending events
glfwPollEvents();
// draw one frame
Render(MainWindow);
// check for errors
GLenum error = glGetError();
if(error != GL_NO_ERROR)
std::cerr << "OpenGL Error " << error /*<< ": " << (const GLubyte)gluErrorString(error)*/ << std::endl;
}
// clean up and exit
glfwTerminate();
}
示例3: main
//.........这里部分代码省略.........
// windowed mode
style |= WS_SYSMENU|WS_BORDER|WS_CAPTION;
Adjust(rect, screenwidth, screenheight, style, 0);
hwnd = CreateWindowA("TestClass", TITLE, style,
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
NULL, NULL, wc.hInstance, NULL);
if( !hwnd )
{
MYERROR("Could not create window");
goto _end;
}
if( FAILED(InitDirect3D(hwnd)) )
{
MYERROR("Failed to initialize Direct3D");
goto _end;
}
if( FAILED(InitScene()) )
{
MYERROR("Failed to initialize scene");
goto _end;
}
ShowWindow(hwnd, SW_SHOWDEFAULT);
UpdateWindow(hwnd);
MSG msg;
ZeroMemory(&msg, sizeof(msg));
POINT p;
GetCursorPos(&p);
ScreenToClient(hwnd, &p);
// timer
QueryPerformanceFrequency(&qwTicksPerSec);
tickspersec = qwTicksPerSec.QuadPart;
QueryPerformanceCounter(&qwTime);
last = (qwTime.QuadPart % tickspersec) / (double)tickspersec;
while( msg.message != WM_QUIT )
{
QueryPerformanceCounter(&qwTime);
current = (qwTime.QuadPart % tickspersec) / (double)tickspersec;
if (current < last)
delta = ((1.0 + current) - last);
else
delta = (current - last);
last = current;
accum += delta;
mousedx = mousedy = 0;
while( accum > 0.0333f )
{
accum -= 0.0333f;
while( PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Update(0.0333f);
}
if( msg.message != WM_QUIT )
Render((float)accum / 0.0333f, (float)delta);
}
_end:
UninitScene();
if( device )
{
ULONG rc = device->Release();
if( rc > 0 )
MYERROR("You forgot to release something");
}
if( direct3d )
direct3d->Release();
UnregisterClass("TestClass", wc.hInstance);
_CrtDumpMemoryLeaks();
#ifdef _DEBUG
system("pause");
#endif
return 0;
}
示例4: Render
void ALSoftwareGraphicsDriver::Render()
{
Render(None);
}
示例5: while
/* Function that runs the application */
INT CXBApplicationEx::Run()
{
CLog::Log(LOGNOTICE, "Running the application..." );
unsigned int lastFrameTime = 0;
unsigned int frameTime = 0;
const unsigned int noRenderFrameTime = 15; // Simulates ~66fps
#ifdef XBMC_TRACK_EXCEPTIONS
BYTE processExceptionCount = 0;
BYTE frameMoveExceptionCount = 0;
BYTE renderExceptionCount = 0;
const BYTE MAX_EXCEPTION_COUNT = 10;
#endif
// Run xbmc
while (!m_bStop)
{
#ifdef HAS_PERFORMANCE_SAMPLE
CPerformanceSample sampleLoop("XBApplicationEx-loop");
#endif
//-----------------------------------------
// Animate and render a frame
//-----------------------------------------
#ifdef XBMC_TRACK_EXCEPTIONS
try
{
#endif
lastFrameTime = XbmcThreads::SystemClockMillis();
Process();
//reset exception count
#ifdef XBMC_TRACK_EXCEPTIONS
processExceptionCount = 0;
}
catch (const XbmcCommons::UncheckedException &e)
{
e.LogThrowMessage("CApplication::Process()");
processExceptionCount++;
//MAX_EXCEPTION_COUNT exceptions in a row? -> bail out
if (processExceptionCount > MAX_EXCEPTION_COUNT)
{
CLog::Log(LOGERROR, "CApplication::Process(), too many exceptions");
throw;
}
}
catch (...)
{
CLog::Log(LOGERROR, "exception in CApplication::Process()");
processExceptionCount++;
//MAX_EXCEPTION_COUNT exceptions in a row? -> bail out
if (processExceptionCount > MAX_EXCEPTION_COUNT)
{
CLog::Log(LOGERROR, "CApplication::Process(), too many exceptions");
throw;
}
}
#endif
// Frame move the scene
#ifdef XBMC_TRACK_EXCEPTIONS
try
{
#endif
if (!m_bStop) FrameMove(true, m_renderGUI);
//reset exception count
#ifdef XBMC_TRACK_EXCEPTIONS
frameMoveExceptionCount = 0;
}
catch (const XbmcCommons::UncheckedException &e)
{
e.LogThrowMessage("CApplication::FrameMove()");
frameMoveExceptionCount++;
//MAX_EXCEPTION_COUNT exceptions in a row? -> bail out
if (frameMoveExceptionCount > MAX_EXCEPTION_COUNT)
{
CLog::Log(LOGERROR, "CApplication::FrameMove(), too many exceptions");
throw;
}
}
catch (...)
{
CLog::Log(LOGERROR, "exception in CApplication::FrameMove()");
frameMoveExceptionCount++;
//MAX_EXCEPTION_COUNT exceptions in a row? -> bail out
if (frameMoveExceptionCount > MAX_EXCEPTION_COUNT)
{
CLog::Log(LOGERROR, "CApplication::FrameMove(), too many exceptions");
throw;
}
}
#endif
// Render the scene
#ifdef XBMC_TRACK_EXCEPTIONS
try
{
#endif
if (m_renderGUI && !m_bStop) Render();
//.........这里部分代码省略.........
示例6: SDL_FillRect
void BaseScene::RenderFrame() {
SDL_FillRect(screen, 0, 0);
Render(screen);
SDL_Flip(screen);
}
示例7: Update
int WorldClass::Tick()
{
Update(CheckInput());
Render();
return 1;
}
示例8: Render
void Texture::Render(SDL_Renderer *const Renderer, const int &x, const int &y)
{
return Render(Renderer, x, y, NULL, 0.0, NULL, SDL_RendererFlip());
}
示例9: sizeof
void hgeFont::printfb(const float x, const float y, const float w, const float h,
const int align, const char* format, ...) {
auto lines = 0;
const auto p_arg = reinterpret_cast<char *>(&format) + sizeof(format);
_vsnprintf(buffer_, sizeof(buffer_) - 1, format, p_arg);
buffer_[sizeof(buffer_) - 1] = 0;
//vsprintf(buffer, format, pArg);
char* linestart = buffer_;
char* pbuf = buffer_;
char* prevword = nullptr;
for (;;) {
int i = 0;
while (pbuf[i] && pbuf[i] != ' ' && pbuf[i] != '\n') {
i++;
}
const auto chr = pbuf[i];
pbuf[i] = 0;
const auto ww = GetStringWidth(linestart);
pbuf[i] = chr;
if (ww > w) {
if (pbuf == linestart) {
pbuf[i] = '\n';
linestart = &pbuf[i + 1];
}
else {
*prevword = '\n';
linestart = prevword + 1;
}
lines++;
}
if (pbuf[i] == '\n') {
prevword = &pbuf[i];
linestart = &pbuf[i + 1];
pbuf = &pbuf[i + 1];
lines++;
continue;
}
if (!pbuf[i]) {
lines++;
break;
}
prevword = &pbuf[i];
pbuf = &pbuf[i + 1];
}
auto tx = x;
auto ty = y;
const auto hh = height_ * spacing_ * scale_ * lines;
switch (align & HGETEXT_HORZMASK) {
case HGETEXT_LEFT:
break;
case HGETEXT_RIGHT:
tx += w;
break;
case HGETEXT_CENTER:
tx += int(w / 2);
break;
}
switch (align & HGETEXT_VERTMASK) {
case HGETEXT_TOP:
break;
case HGETEXT_BOTTOM:
ty += h - hh;
break;
case HGETEXT_MIDDLE:
ty += int((h - hh) / 2);
break;
}
Render(tx, ty, align, buffer_);
}
示例10: main
// From <https://www.opengl.org/wiki/Programming_OpenGL_in_Linux:_GLX_and_Xlib>
int main(int argc, char** argv){
Initialised = false;
StartTime = GetClock();
double time;
Display* dpy;
Window root;
XVisualInfo* vi;
Colormap cmap;
XSetWindowAttributes swa;
Window win;
GLXContext glc;
XWindowAttributes gwa;
XEvent xev;
GLint att[] = {GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None};
dpy = XOpenDisplay(0);
if(dpy == 0){
printf("\n\tcannot connect to X server\n\n");
return 1;
}
root = DefaultRootWindow(dpy);
vi = glXChooseVisual(dpy, 0, att);
if(vi == 0){
printf("\n\tno appropriate visual found\n\n");
return 1;
}else{
// %p creates hexadecimal output like in glxinfo
printf("\n\tvisual %p selected\n", (void*)vi->visualid);
}
cmap = XCreateColormap(dpy, root, vi->visual, AllocNone);
swa.colormap = cmap;
swa.event_mask = ExposureMask | KeyPressMask;
win = XCreateWindow(
dpy,
root,
0, 0, 640, 480, 0,
vi->depth,
InputOutput,
vi->visual,
CWColormap | CWEventMask,
&swa
);
XMapWindow(dpy, win);
XStoreName(dpy, win, "OpenGL Sample");
glc = glXCreateContext(dpy, vi, 0, GL_TRUE);
glXMakeCurrent(dpy, win, glc);
if(!InitGLEW()){
glXMakeCurrent (dpy, None, 0);
glXDestroyContext(dpy, glc);
XDestroyWindow (dpy, win);
XCloseDisplay (dpy);
return 1;
}
if(!LoadShader ("OpenGL/Texture.vp", "OpenGL/Texture.fp")) return 1;
if(!LoadTexture("Pic/greatwall.jpg")) return 1;
Initialised = true;
bool running = true;
while(running){
while(XCheckWindowEvent(dpy, win, 0xFFFFFFFF, &xev)){
switch(xev.type){
case Expose:
XGetWindowAttributes(dpy, win, &gwa);
Render(gwa.width, gwa.height);
glXSwapBuffers(dpy, win);
break;
case KeyPress:
// printf("KeyPress: keycode %u state %u\n", xev.xkey.keycode, xev.xkey.state);
if(xev.xkey.keycode == Key_Escape) running = false;
else OnKeyDown(xev.xkey.keycode);
break;
}
}
XGetWindowAttributes(dpy, win, &gwa);
Render(gwa.width, gwa.height);
glXSwapBuffers(dpy, win);
RenderTime(GetClock()-time);
time = GetClock();
usleep(1000);
}
glXMakeCurrent (dpy, None, 0);
glXDestroyContext(dpy, glc);
XDestroyWindow (dpy, win);
XCloseDisplay (dpy);
//.........这里部分代码省略.........
示例11: WinMain
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
){
Initialised = false;
StartTime = GetClock();
double time = StartTime;
WNDCLASSEX wcex;
HGLRC hRC;
RECT rect;
MSG msg;
// register window class
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_OWNDC;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(0, IDI_APPLICATION);
wcex.hCursor = LoadCursor(0, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wcex.lpszMenuName = 0;
wcex.lpszClassName = "GLSample";
wcex.hIconSm = LoadIcon(0, IDI_APPLICATION);;
if(!RegisterClassEx(&wcex)) return 0;
// create main window
hwnd = CreateWindowEx(
0,
"GLSample",
"OpenGL Sample",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
640, 480,
0,
0,
hInstance,
0
);
ShowWindow(hwnd, nCmdShow);
// enable OpenGL for the window
PIXELFORMATDESCRIPTOR pfd;
int iFormat;
// get the device context (DC)
hDC = GetDC(hwnd);
// set the pixel format for the DC
ZeroMemory(&pfd, sizeof(pfd));
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 0;
pfd.iLayerType = PFD_MAIN_PLANE;
iFormat = ChoosePixelFormat(hDC, &pfd);
SetPixelFormat(hDC, iFormat, &pfd);
// create and enable the render context (RC)
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC);
if(!InitGLEW()){
wglMakeCurrent(0, 0);
wglDeleteContext(hRC);
ReleaseDC(hwnd, hDC);
DestroyWindow(hwnd);
return 1;
}
if(!LoadShader ("..\\OpenGL\\Texture.vp", "..\\OpenGL\\Texture.fp")) return 1;
if(!LoadTexture("..\\Pic\\greatwall.jpg")) return 1;
Initialised = true;
Initialised = true;
// program main loop
while(true){
while(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)){
if(msg.message == WM_QUIT) break;
TranslateMessage(&msg);
DispatchMessage (&msg);
}
if(msg.message == WM_QUIT) break;
GetClientRect(hwnd, &rect);
Render(rect.right, rect.bottom);
//.........这里部分代码省略.........
示例12: GameStart
void GameStart() {
RenderWindow window(VideoMode(MapWidth * SpriteSize, MapHeight * SpriteSize), "Snake");
Clock clock;
Game* game;
NewGame(game);
Text text = game->game_text->text;
while (window.isOpen()) //разбить на 3 метода
{
float time = clock.getElapsedTime().asSeconds();
clock.restart();
game->consts->time_counter += time;
ProcessEvents(window, game);
if (game->state == STARTGAME) {
window.clear();
text.setCharacterSize(120);
text.setString(" Snake!\n\nPress 'U' to start!");
text.setPosition(250, 50);
window.draw(text);
}
else if (game->state == RESTART) {
DestroyGame(game);
NewGame(game);
text = game->game_text->text;
game->state = PLAY;
}
else if (game->state == PAUSE) {
window.clear();
Render(window, game);
text.setCharacterSize(150);
text.setString("Pause");
text.setPosition(455, 160);
window.draw(text);
}
else if (game->state == PLAY) {
while (game->consts->time_counter > game->consts->speed) {
game->consts->time_counter = 0;
//Snake movement
Step(game->snake);
int snake_draw_counter = SnakeLength(game->snake);
ProcessCollisions(snake_draw_counter, game);
}
Render(window, game);
}
else if (game->state == ENDGAME) {
window.clear();
text.setCharacterSize(120);
text.setString(" Score: " + ToString(game->consts->score) + "\n Press 'Esc' to exit\n Press 'R' to restart");
text.setPosition(170, 28);
window.draw(text);
}
window.display();
}
DestroyGame(game);
}
示例13: while
void ClassDemoApp::UpdateAndRender() {
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT || event.type == SDL_WINDOWEVENT_CLOSE) {
done = true;
}
else if (false && event.type == SDL_MOUSEBUTTONDOWN && state == PlayingLevel) { //debugging - moves player(s) to cursor
if (event.button.button == SDL_BUTTON_LEFT) {
if (!includePlayer2) {
player->x += (event.button.x / WINDOW_WIDTH - 0.5f) * PROJECTION_WIDTH * 2;
player->y -= (event.button.y / WINDOW_HEIGHT - 0.5f) * PROJECTION_HEIGHT * 2;
player->velocity_y = 0;
}
else {
player->x = (player->x + player2->x) / 2 + (event.button.x / WINDOW_WIDTH - 0.5f) * PROJECTION_WIDTH * 2;
player->y = (player->y + player2->y) / 2 - (event.button.y / WINDOW_HEIGHT - 0.5f) * PROJECTION_HEIGHT * 2;
player->velocity_y = 0;
}
}
else if (event.button.button == SDL_BUTTON_RIGHT) {
if (includePlayer2) {
player2->x = (player->x + player2->x) / 2 + (event.button.x / WINDOW_WIDTH - 0.5f) * PROJECTION_WIDTH * 2;
player2->y = (player->y + player2->y) / 2 - (event.button.y / WINDOW_HEIGHT - 0.5f) * PROJECTION_HEIGHT * 2;
player2->velocity_y = 0;
}
}
}
else if (event.type == SDL_KEYDOWN) {
if (event.key.keysym.scancode == SDL_SCANCODE_R) {
infoBoxTimer = 8;
ResetPos();
}
else {
infoBoxTimer *= 0.05f;
if (!includePlayer2 && (event.key.keysym.scancode == controls[1]->UP ||
event.key.keysym.scancode == controls[1]->DOWN ||
event.key.keysym.scancode == controls[1]->LEFT ||
event.key.keysym.scancode == controls[1]->RIGHT ||
event.key.keysym.scancode == controls[1]->EXTEND)) {
includePlayer2 = true;
entities.push_back(player2);
}
}
}
}
float ticks = (float)SDL_GetTicks() / 1000.0f;
float elapsed = ticks - lastElapsedTime;
lastElapsedTime = ticks;
float fixedElapsed = elapsed;
if (fixedElapsed > FIXED_TIMESTEP * MAX_TIMESTEP)
fixedElapsed = FIXED_TIMESTEP * MAX_TIMESTEP;
while (fixedElapsed > FIXED_TIMESTEP) {
fixedElapsed -= FIXED_TIMESTEP;
Update(FIXED_TIMESTEP);
}
Update(fixedElapsed);
infoBoxTimer -= elapsed;
movingColor += elapsed * 0.3f;
Render();
}
示例14: main
int
main(int argc, char *argv[])
{
int fsaa, accel;
int value;
int i, done;
SDL_DisplayMode mode;
SDL_Event event;
Uint32 then, now, frames;
int status;
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Initialize parameters */
fsaa = 0;
accel = 0;
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (!state) {
return 1;
}
for (i = 1; i < argc;) {
int consumed;
consumed = SDLTest_CommonArg(state, i);
if (consumed == 0) {
if (SDL_strcasecmp(argv[i], "--fsaa") == 0) {
++fsaa;
consumed = 1;
} else if (SDL_strcasecmp(argv[i], "--accel") == 0) {
++accel;
consumed = 1;
} else if (SDL_strcasecmp(argv[i], "--zdepth") == 0) {
i++;
if (!argv[i]) {
consumed = -1;
} else {
depth = SDL_atoi(argv[i]);
consumed = 1;
}
} else {
consumed = -1;
}
}
if (consumed < 0) {
SDL_Log("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
SDLTest_CommonUsage(state));
quit(1);
}
i += consumed;
}
/* Set OpenGL parameters */
state->window_flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS;
state->gl_red_size = 5;
state->gl_green_size = 5;
state->gl_blue_size = 5;
state->gl_depth_size = depth;
state->gl_major_version = 1;
state->gl_minor_version = 1;
state->gl_profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
if (fsaa) {
state->gl_multisamplebuffers=1;
state->gl_multisamplesamples=fsaa;
}
if (accel) {
state->gl_accelerated=1;
}
if (!SDLTest_CommonInit(state)) {
quit(2);
}
context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(context));
if (context == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
quit(2);
}
/* Create OpenGL ES contexts */
for (i = 0; i < state->num_windows; i++) {
context[i] = SDL_GL_CreateContext(state->windows[i]);
if (!context[i]) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
quit(2);
}
}
if (state->render_flags & SDL_RENDERER_PRESENTVSYNC) {
SDL_GL_SetSwapInterval(1);
} else {
SDL_GL_SetSwapInterval(0);
}
SDL_GetCurrentDisplayMode(0, &mode);
SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
SDL_Log("\n");
SDL_Log("Vendor : %s\n", glGetString(GL_VENDOR));
SDL_Log("Renderer : %s\n", glGetString(GL_RENDERER));
//.........这里部分代码省略.........
示例15: Render
Buffer WoWFile::getFileBuff(){
Render();
this->buff.setPosition(0);
return this->buff;
}