本文整理汇总了C++中createWindow函数的典型用法代码示例。如果您正苦于以下问题:C++ createWindow函数的具体用法?C++ createWindow怎么用?C++ createWindow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createWindow函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: createWindow
void
CMSWindowsServerTaskBarReceiver::showStatus()
{
// create the window
createWindow();
// lock self while getting status
lock();
// get the current status
std::string status = getToolTip();
// get the connect clients, if any
const CClients& clients = getClients();
// done getting status
unlock();
// update dialog
HWND child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_STATUS);
SendMessage(child, WM_SETTEXT, 0, (LPARAM)status.c_str());
child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_CLIENTS);
SendMessage(child, LB_RESETCONTENT, 0, 0);
for (CClients::const_iterator index = clients.begin();
index != clients.end(); ) {
const char* client = index->c_str();
if (++index == clients.end()) {
SendMessage(child, LB_ADDSTRING, 0, (LPARAM)client);
}
else {
SendMessage(child, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)client);
}
}
if (!IsWindowVisible(m_window)) {
// position it by the mouse
POINT cursorPos;
GetCursorPos(&cursorPos);
RECT windowRect;
GetWindowRect(m_window, &windowRect);
int x = cursorPos.x;
int y = cursorPos.y;
int fw = GetSystemMetrics(SM_CXDLGFRAME);
int fh = GetSystemMetrics(SM_CYDLGFRAME);
int ww = windowRect.right - windowRect.left;
int wh = windowRect.bottom - windowRect.top;
int sw = GetSystemMetrics(SM_CXFULLSCREEN);
int sh = GetSystemMetrics(SM_CYFULLSCREEN);
if (fw < 1) {
fw = 1;
}
if (fh < 1) {
fh = 1;
}
if (x + ww - fw > sw) {
x -= ww - fw;
}
else {
x -= fw;
}
if (x < 0) {
x = 0;
}
if (y + wh - fh > sh) {
y -= wh - fh;
}
else {
y -= fh;
}
if (y < 0) {
y = 0;
}
SetWindowPos(m_window, HWND_TOPMOST, x, y, ww, wh,
SWP_SHOWWINDOW);
}
}
开发者ID:axelson,项目名称:synergy-plus,代码行数:76,代码来源:CMSWindowsServerTaskBarReceiver.cpp
示例2: main
int main(int argc, char *argv[])
{
if(argc >= 2)
{
if(strcmp(argv[1],"-h") == 0 || strcmp(argv[1],"--help") == 0)
{
printf("\nConway\n");
printf("Copyright 2015 Harley Wiltzer\n\n");
printf("conway:\t\tOpen conway with a random color\n");
printf("conway 1:\tOpen conway blue theme\n");
printf("conway 2:\tOpen conway red theme\n");
printf("conway 3:\tOpen conway green theme\n");
printf("conway 4:\tOpen conway yellow theme\n");
printf("conway 5:\tOpen conway light blue theme\n");
printf("conway 6:\tOpen conway orange theme\n");
printf("conway 7:\tOpen conway white theme\n");
printf("\n");
printf("While running conway...\n");
printf("=======================\n");
printf("q:\t\tClose conway\n");
printf("space:\t\tActivate/Kill cell\n");
printf("enter:\t\tStart ticking\n");
printf("h:\t\tMove cursor left\n");
printf("j:\t\tMove cursor down\n");
printf("k:\t\tMove cursor up\n");
printf("l:\t\tMove cursor right\n");
printf("d:\t\tClear all cells\n");
printf("=:\t\tIncrease the amount of ticks by 10\n");
printf("-:\t\tDecrease the amount of ticks by 10\n");
printf("+:\t\tIncrease the amount of ticks by 1\n");
printf("_:\t\tDecrease the amount of ticks by 1\n");
return 0;
}
}
int i, c;
initCurses();
showSplash();
totalTicks = 0;
refresh();
getch();
win = createWindow(WIN_WIDTH,rows,0,cols - WIN_WIDTH - 1);
cols = cols - WIN_WIDTH - 1;
xs = rows;
ys = cols / 2;
area = rows * cols;
game = createWindow(cols - 1,rows,0,0);
ticks = DEFAULT_TICKS;
int cells[area / 2];
for(i = 0; i < area/2; i++)
{
cells[i] = 0;
}
x = y = row = col = 0;
if(has_colors() == 0) wprintw(game,"NO COLORS\n");
if(argc < 2)
{
srand(time(NULL));
color = rand()%7 + 1;
}
else
{
if(atoi(argv[1]) > 7 || atoi(argv[1]) < 1)
{
srand(time(NULL));
color = rand()%7 + 1;
}
else
{
color = atoi(argv[1]);
}
}
x = ys/2;
y = xs/2;
wmove(game,y, x * 2);
x = 2;
y = 2;
wrefresh(game);
updateWin(cells,area/2);
wmove(game,y,x * 2);
x = ys/2;
y = xs/2;
wmove(game,y,x * 2);
while((ch = getch()) != 'q')
{
wclear(game);
wclear(win);
int r, c;
render(cells,area/2);
wmove(game,y, x * 2);
//.........这里部分代码省略.........
开发者ID:prprprpony,项目名称:Conway,代码行数:101,代码来源:Source.c
示例3: QMainWindow
myGazeHaptic::myGazeHaptic(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
createWindow();
}
开发者ID:gkhartman,项目名称:haptic-Jose,代码行数:6,代码来源:mygazehaptic.cpp
示例4: initSystem
/*
=====================
initSystem
=====================
*/
BOOL initSystem() {
//get game directory path (Ex: D:\Games\Netrix)
//
GetCurrentDirectory( MAX_PATH, k_system.szStartDir );
N_InitTrace();
//init Win32 system
//
initWin32();
//System
//
k_system.pLeftGame = NULL;
k_system.pRightGame = NULL;
k_system.gameType = GNO;
k_system.pause = FALSE;
k_system.flags = 0;
k_system.dwAccumTime = 0;
k_system.dwTime = 0;
//Maps
//
k_system.cMaps = 0;
k_system.pMaps = NULL;
k_system.idMap = -1;
//Bots
//
k_system.cBots = 0;
k_system.pBots = NULL;
k_system.idBotLeft = -1;
k_system.idBotRight = -1;
//Paths
//
k_system.pPaths = NULL;
k_system.cPaths = 0;
//HWND
//
k_system.hwnd = NULL;
k_system.hwndLeft = NULL;
k_system.hwndRight = NULL;
k_system.cPlayers = 0;
initRandom();
cfInitTable();
//resources
//
loadResources();
//init bot system
//
botInit();
//Skins
//
loadSkin( &k_system.hSkinRgnLeft, &k_system.hSkinBitmapLeft,
&k_system.cxSkinLeft, &k_system.cySkinLeft, IDR_SKIN_LEFT );
loadSkin( &k_system.hSkinRgnRight, &k_system.hSkinBitmapRight,
&k_system.cxSkinRight, &k_system.cySkinRight, IDR_SKIN_RIGHT );
createWindow();
//GUI
//
populateGUI();
if( !initGraphics( NEUTRAL ) )
return FALSE;
if( !initGraphics( LEFTGAME ) )
return FALSE;
updateWindow( CGF_DRAWLEFT );
//winmm
timeBeginPeriod( 1 );
return TRUE;
}
开发者ID:dimovich,项目名称:netrix,代码行数:92,代码来源:sys.c
示例5: _windowHandle
Window::Window(const ConstructionData &ctorData) :
_windowHandle(createWindow(ctorData, this)),
_surface(_windowHandle.get()),
_inputSource(_windowHandle.get())
{
}
开发者ID:kpaleniu,项目名称:polymorph-td,代码行数:6,代码来源:Window.cpp
示例6: createWindow
bool CDDApplication::createMainWindow()
{
// Create a main game window
return createWindow("DiabloDream");
}
开发者ID:stevegocoding,项目名称:terrain_d3d,代码行数:5,代码来源:DemoApp.cpp
示例7: return
BOOL winapiwrapper::createWindow()
{
return(createWindow("mywrapperdefclass",0,0,800,600));
}
开发者ID:m022495,项目名称:snakegame,代码行数:6,代码来源:winapiwrapper.cpp
示例8: main
int main(int, char**)
{
// Timing
unsigned int lastUpdate;
unsigned int thisUpdate;
unsigned int dt = 0;
// FPS
int frames = 0;
int fps = 0;
int lastFPSUpdate;
// Pixel buffer
PixelBuffer pixelBuffer(width, height);
// SDL structures
SDL_Event event;
SDL_Window* window;
SDL_Renderer* renderer;
SDL_Texture* renderTexture;
// Seed random number generator
srand((unsigned int)time(0));
// Initialise SDL
SDL_Init(SDL_INIT_EVERYTHING);
// Initilialise timing
lastUpdate = thisUpdate = SDL_GetTicks();
lastFPSUpdate = lastUpdate;
// Create window
window = createWindow(TITLE_FORMAT, width, height);
// Create renderer
renderer = createRenderer(window);
// Create render texture
renderTexture = createTexture(renderer, width, height);
// Set window values
//int width = INITIAL_WIDTH;
//int height = INITIAL_HEIGHT;
// Create and initialise managers
BallManager ballManager(width, height);
// Create some balls
ballManager.createBalls(INITIAL_BALLS);
// Start main loop
bool running = true;
bool rendering_enabled = true;
bool movement_enabled = true;
while (running)
{
const SDL_Rect screenRect = {0, 0, width, height};
// Update timer
thisUpdate = SDL_GetTicks();
dt = thisUpdate - lastUpdate;
// Handle all events
while (SDL_PollEvent(&event))
{
// End when the user closes the window or presses esc
if (event.type == SDL_QUIT ||
(event.type == SDL_KEYDOWN && event.key.keysym.scancode == SDL_SCANCODE_ESCAPE))
{
running = false;
}
// Handle keyboard input
if (event.type == SDL_KEYDOWN)
{
// Toggle rendering when player presses R
if (event.key.keysym.sym == SDLK_r)
{
// Disable rendering
rendering_enabled = !rendering_enabled;
// Clear screen to white
pixelBuffer.clear(0xFFFFFFFF);
// Update render texture
SDL_UpdateTexture(renderTexture, &screenRect, pixelBuffer.getBuffer(), width * 4);
// Render texture to screen
SDL_RenderCopy(renderer, renderTexture, &screenRect, &screenRect);
// Flip screen buffer
SDL_RenderPresent(renderer);
}
// Toggle movement when player presses M
else if (event.key.keysym.sym == SDLK_m)
{
movement_enabled = !movement_enabled;
}
// Add 10 balls when user presses right arrow
//.........这里部分代码省略.........
开发者ID:tcantenot,项目名称:ECS,代码行数:101,代码来源:main.cpp
示例9: valueToStringWithUndefinedOrNullCheck
JSValue JSDOMWindow::showModalDialog(ExecState* exec)
{
String url = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0));
JSValue dialogArgs = exec->argument(1);
String featureArgs = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(2));
Frame* frame = impl()->frame();
if (!frame)
return jsUndefined();
Frame* lexicalFrame = toLexicalFrame(exec);
if (!lexicalFrame)
return jsUndefined();
Frame* dynamicFrame = toDynamicFrame(exec);
if (!dynamicFrame)
return jsUndefined();
if (!DOMWindow::canShowModalDialogNow(frame) || !domWindowAllowPopUp(dynamicFrame))
return jsUndefined();
HashMap<String, String> features;
DOMWindow::parseModalDialogFeatures(featureArgs, features);
const bool trusted = false;
// The following features from Microsoft's documentation are not implemented:
// - default font settings
// - width, height, left, and top specified in units other than "px"
// - edge (sunken or raised, default is raised)
// - dialogHide: trusted && boolFeature(features, "dialoghide"), makes dialog hide when you print
// - help: boolFeature(features, "help", true), makes help icon appear in dialog (what does it do on Windows?)
// - unadorned: trusted && boolFeature(features, "unadorned");
FloatRect screenRect = screenAvailableRect(frame->view());
WindowFeatures wargs;
wargs.width = WindowFeatures::floatFeature(features, "dialogwidth", 100, screenRect.width(), 620); // default here came from frame size of dialog in MacIE
wargs.widthSet = true;
wargs.height = WindowFeatures::floatFeature(features, "dialogheight", 100, screenRect.height(), 450); // default here came from frame size of dialog in MacIE
wargs.heightSet = true;
wargs.x = WindowFeatures::floatFeature(features, "dialogleft", screenRect.x(), screenRect.right() - wargs.width, -1);
wargs.xSet = wargs.x > 0;
wargs.y = WindowFeatures::floatFeature(features, "dialogtop", screenRect.y(), screenRect.bottom() - wargs.height, -1);
wargs.ySet = wargs.y > 0;
if (WindowFeatures::boolFeature(features, "center", true)) {
if (!wargs.xSet) {
wargs.x = screenRect.x() + (screenRect.width() - wargs.width) / 2;
wargs.xSet = true;
}
if (!wargs.ySet) {
wargs.y = screenRect.y() + (screenRect.height() - wargs.height) / 2;
wargs.ySet = true;
}
}
wargs.dialog = true;
wargs.resizable = WindowFeatures::boolFeature(features, "resizable");
wargs.scrollbarsVisible = WindowFeatures::boolFeature(features, "scroll", true);
wargs.statusBarVisible = WindowFeatures::boolFeature(features, "status", !trusted);
wargs.menuBarVisible = false;
wargs.toolBarVisible = false;
wargs.locationBarVisible = false;
wargs.fullscreen = false;
Frame* dialogFrame = createWindow(exec, lexicalFrame, dynamicFrame, frame, url, "", wargs, dialogArgs);
if (!dialogFrame)
return jsUndefined();
JSDOMWindow* dialogWindow = toJSDOMWindow(dialogFrame, currentWorld(exec));
dialogFrame->page()->chrome()->runModal();
Identifier returnValue(exec, "returnValue");
if (dialogWindow->allowsAccessFromNoErrorMessage(exec)) {
PropertySlot slot;
// This is safe, we have already performed the origin security check and we are
// not interested in any of the DOM properties of the window.
if (dialogWindow->JSGlobalObject::getOwnPropertySlot(exec, returnValue, slot))
return slot.getValue(exec, returnValue);
}
return jsUndefined();
}
开发者ID:azrul2202,项目名称:WebKit-Smartphone,代码行数:82,代码来源:JSDOMWindowCustom.cpp
示例10: wglChoosePixelFormatARB
//-----------------------------------------------------------------------------
// Description: Function to enable multisampling AA.
// Parameters:
// Returns:
// Notes:
//-----------------------------------------------------------------------------
void FWWin32GLWindow::enableAA()
{
if(mAAPixelFormat)
return;
// try to get extension
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB =
(PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
// just return if not available
if(!wglChoosePixelFormatARB)
return;
int iPixelFormat;
BOOL bValid;
unsigned int iNumFormats;
float fAttributes[] =
{
0.f,
0.f,
};
int iAttributes[] =
{
WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
WGL_COLOR_BITS_ARB, mDispInfo.mColorBits,
WGL_ALPHA_BITS_ARB, mDispInfo.mAlphaBits,
WGL_DEPTH_BITS_ARB, mDispInfo.mDepthBits,
WGL_STENCIL_BITS_ARB, mDispInfo.mStencilBits,
WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
WGL_SAMPLE_BUFFERS_ARB, GL_TRUE,
WGL_SAMPLES_ARB, 4,
0, 0,
};
// see if 4x multisampling is supported
bValid = wglChoosePixelFormatARB(mHDc, iAttributes, fAttributes, 1, &iPixelFormat, &iNumFormats);
if(bValid && iNumFormats >= 1)
{
// we got a valid format, so delete the current ogl context and recreate it
mDontQuit = true;
destroyWindow();
mAAPixelFormat = iPixelFormat;
createWindow();
mDontQuit = false;
return;
}
// see if 2x multisampling is supported
iAttributes[19] = 2;
bValid = wglChoosePixelFormatARB(mHDc, iAttributes, fAttributes, 1, &iPixelFormat, &iNumFormats);
if(bValid && iNumFormats >= 1)
{
// we got a valid format, so delete the current ogl context and recreate it
mDontQuit = true;
destroyWindow();
mAAPixelFormat = iPixelFormat;
createWindow();
mDontQuit = false;
return;
}
// couldn't create AA buffer
mDispInfo.mAntiAlias = false;
}
开发者ID:UofMBIomedEng,项目名称:TheVirtualHouse,代码行数:78,代码来源:FWWin32GLWindow.cpp
示例11: videoInit_
Renderer::Renderer() : videoInit_(false), window_(nullptr), context_(nullptr)
#ifdef OCULUSVR
, hmd_(nullptr), renderTex_(0), depthTex_(0), framebuffer_(0)
#endif
{
if(SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
{
throwSDLError();
}
videoInit_ = true;
#ifdef __APPLE__
// Apple's drivers don't support the compatibility profile on GL >v2.1
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
#endif
// 32 crashes mysteriously on my laptop
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
Config& config = Core::get().config();
int multisamples = config.getInt("Renderer.multisamples", 16);
if(multisamples != 0)
{
// Enable MSAA
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, multisamples);
}
createWindow();
context_ = SDL_GL_CreateContext(window_);
if(context_ == nullptr)
{
throwSDLError();
}
#ifdef _MSC_VER
GLenum glewErr = glewInit();
if(glewErr != GLEW_OK)
{
string err("Unable to initialize GLEW: ");
err.append((const char*)glewGetErrorString(glewErr));
throw runtime_error(err);
}
#endif
fieldOfView_ = config.getFloat("Renderer.fieldOfView", 90.0);
string textureFiltering = config.getString("Renderer.textureFiltering", "trilinear");
if(textureFiltering == "bilinear")
{
textureMinFilter_ = GL_LINEAR_MIPMAP_NEAREST;
}
else if(textureFiltering == "trilinear")
{
textureMinFilter_ = GL_LINEAR_MIPMAP_LINEAR;
}
else
{
throw runtime_error("Bad value for Renderer.textureFiltering");
}
textureMaxAnisotropy_ = static_cast<GLfloat>(config.getFloat("Renderer.anisotropyLevel", 0.0));
if(textureMaxAnisotropy_ != 0.0f)
{
#ifdef _MSC_VER
if(!GLEW_EXT_texture_filter_anisotropic)
{
throw runtime_error("Anisotropic filtering not supported");
}
#endif
GLfloat driverMaxAnisotropy;
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &driverMaxAnisotropy);
if(textureMaxAnisotropy_ < 0.0f || textureMaxAnisotropy_ > driverMaxAnisotropy)
{
throw runtime_error("Bad value for Renderer.maxAnisotropyLevel");
}
}
renderHitGeometry_ = config.getBool("Renderer.renderHitGeometry", false);
}
开发者ID:boardwalk,项目名称:bzr,代码行数:89,代码来源:Renderer.cpp
示例12: createWindow
EGLView::EGLView()
{
createWindow();
initEgl();
}
开发者ID:Icaxus,项目名称:pure2d,代码行数:5,代码来源:EGLView.cpp
示例13: switch
void Tutorial::initGlut()
{
switch (_tutorialID) {
case 1:
case 2:
case 3:
_pGameCamera = nullptr;
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
setWindowSize(WINDOW_WIDTH_1_14, WINDOW_HEIGHT_1_14);
_pGameCamera = new Camera(WINDOW_WIDTH_1_14, WINDOW_HEIGHT_1_14);
break;
case 15:
setWindowSize(WINDOW_WIDTH_15_17, WINDOW_HEIGHT_15_17);
_pGameCamera = new Camera(WINDOW_WIDTH_15_17, WINDOW_HEIGHT_15_17);
break;
case 16:
setWindowSize(WINDOW_WIDTH_16, WINDOW_HEIGHT_16);
_pGameCamera = new Camera(WINDOW_WIDTH_16, WINDOW_HEIGHT_16);
break;
case 17:
case 18:
case 19:
case 20:
case 21:
case 22:
case 23:
return;
default:
setWindowSize(WINDOW_WIDTH_1_14, WINDOW_HEIGHT_1_14);
_pGameCamera = new Camera(WINDOW_WIDTH_1_14, WINDOW_HEIGHT_1_14);
break;
}
setWindowLocation();
createWindow(_tutorialID);
glutDisplayFunc(renderFunction);
glutIdleFunc(idleFunction);
glutSpecialFunc(specialKeyboardCB);
glutKeyboardFunc(keyboardCB);
glutPassiveMotionFunc(passiveMouseCB);
if (_tutorialID == 15 || _tutorialID == 17) {
glutGameModeString("[email protected]");
glutEnterGameMode();
}
else if (_tutorialID == 16) {
glutGameModeString("[email protected]");
}
}
开发者ID:LouisParkin,项目名称:OpenGlDirsProject,代码行数:62,代码来源:Tutorial.cpp
示例14: createWindow
bool Window_Win32::createWindow( const std::string &titlewstring )
{
return createWindow( m_windowPosX, m_windowPosY, m_windowWidth, m_windowHeight, titlewstring );
}
开发者ID:pkm158,项目名称:Gears,代码行数:4,代码来源:Window_Win32.cpp
示例15: createRenderingTarget
void createRenderingTarget() {
createWindow(glm::uvec2(1280, 800), glm::ivec2(100, 100));
}
开发者ID:Kittnz,项目名称:OculusRiftInAction,代码行数:3,代码来源:Example_3_5_TrackerPrediction.cpp
示例16: main
int main(int argc, char** argv)
{
#if 1
uint32_t width = 1280;
uint32_t height = 720;
#else
uint32_t width = 1920;
uint32_t height = 1080;
#endif
HWND hwnd = createWindow(width, height);
input::initialize(hwnd);
RenderDevice renderer((void*)hwnd, glm::ivec2(width, height));
RendererEx r(&renderer);
dcfx::ProgramHandle program = asset::loadVSFSProgram(renderer.m_context,
"../../dcfx/assets/shaders/gl/mesh.vert",
"../../dcfx/assets/shaders/gl/mesh.frag");
// Sponza model
Model model;
model.create(renderer.m_context, "../../dcfx/assets/models/sponza.obj");
for(uint32_t i = 0; i < model.m_meshes.size(); ++i)
{
Mesh* mesh = &model.m_meshes[i];
RenderObject object;
object.m_bounds = mesh->m_bounds;
object.m_vertexBuffer = mesh->m_vertexBuffer;
object.m_indexBuffer = mesh->m_indexBuffer;
object.m_program = program;
object.m_material = model.m_materials[mesh->m_materialIndex];
object.m_offset = 0;
object.m_count = mesh->m_numIndices;
renderer.addRenderObject(object, mesh->m_bounds);
}
// Create camera
LookAt lookAt;
lookAt.m_pos = glm::vec3(0,0,0);
lookAt.m_distance = 10.0f;
PerspectiveCamera camera;
camera.initialize(glm::vec3(-918.825623, 1060.502686, -35.351444), 45.0f, glm::vec2(width, height), 0.25f, 5000.0f);
camera.m_orient.yawGlobal(-90.0f);
renderer.m_camera = &camera;
// Set Directional light.
DirectionalLight sunLight;
sunLight.m_orient.yaw(90.0f);
sunLight.m_orient.pitch(120.0f);
sunLight.m_color = glm::vec3(1.0, 0.8, 0.3);
r.setDirectionalLight(sunLight);
__int64 cntsPerSec = 0;
QueryPerformanceFrequency((LARGE_INTEGER*)&cntsPerSec);
float secsPerCnt = 1.0f / (float)cntsPerSec;
__int64 prevTimeStamp = 0;
QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp);
int inputMode = 0;
MSG msg;
msg.message = WM_NULL;
while (!g_exit)
{
{
TimedBlock b(0);
WaitForInputIdle(GetCurrentProcess(), 16);
while (0 != PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
__int64 currTimeStamp = 0;
QueryPerformanceCounter((LARGE_INTEGER*)&currTimeStamp);
float dt = (currTimeStamp - prevTimeStamp) * secsPerCnt;
prevTimeStamp = currTimeStamp;
input::getState();
// Select input mode
if(input::isKeyPressedAndReleased(DIK_F1))
{
inputMode = 0;
}
if(input::isKeyPressedAndReleased(DIK_F2))
{
inputMode = 1;
}
//.........这里部分代码省略.........
开发者ID:huxs,项目名称:dcfx,代码行数:101,代码来源:main.cpp
示例17: main
int main() {
createWindow(640, 480);
int framecnt = 0;
Image* img = loadTGAImage("cat.tga");
if(img == NULL) {
printf("ERROR: Could not open image file\n");
exit(1);
}
Image* font = loadTGAImage("font.tga");
if(font == NULL) {
printf("ERROR: Could not load font file\n");
exit(1);
}
int mousePos[2] = {0, 0};
while(1) {
KeyEvent ev;
profileBlockStart("eventHandling");
while(pollEvent(&ev)) {
switch(ev.type) {
case KEY_DOWN:
printf("Keycode: %d\n", ev.key);
if(ev.key == 53) {
goto endGame;
}
break;
case MOUSE_MOVE:
mousePos[0] = ev.posx;
mousePos[1] = ev.posy;
break;
}
}
profileBlockEnd("eventHandling");
Image* fb = getFramebuffer();
profileBlockStart("clearFramebuffer");
Color backColor = color(0, 30, 140, 40);
clear(fb, &backColor);
profileBlockEnd("clearFramebuffer");
profileBlockStart("paintCats");
for(int i = 0; i < 300; i++) {
paint(PAINT_OVER, img, fb, (int)(fb->width / 2 + (i * 0.7) * sin(i * 1.221 + framecnt * 0.004)),
(int)(fb->height / 2 + (i * 0.7) * cos(i * 1.221 + framecnt * 0.004)));
}
profileBlockEnd("paintCats");
profileBlockStart("paintText");
Color textColor = color(255, 200, 250, 255);
textColor.a = (framecnt * 32) % 256;
drawText(fb, font, &textColor, "Hello world!", mousePos[0], mousePos[1]);
drawButton(fb, font, "Click here!", 120, 200);
profileBlockEnd("paintText");
profileBlockStart("flush");
flushFramebuffer();
profileBlockEnd("flush");
framecnt++;
}
endGame:
saveProfile("_profile.json");
deleteImage(img);
closeWindow();
}
开发者ID:jonvaldes,项目名称:handmade,代码行数:67,代码来源:main.c
示例18: createDummyWindow
HWND createDummyWindow(int origin_x, int origin_y) {
if (!registerDummyWindow())
return NULL;
return createWindow(_CONTEXT_PRIVATE_CLASS_NAME, origin_x, origin_y, 1, 1, false, false, NULL);
}
开发者ID:JohnCarmack,项目名称:lwjgl,代码行数:5,代码来源:context.c
示例19: _glfwPlatformCreateWindow
int _glfwPlatformCreateWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
int status;
if (!createWindow(window, wndconfig))
return GLFW_FALSE;
if (ctxconfig->api != GLFW_NO_API)
{
if (!_glfwCreateContext(window, ctxconfig, fbconfig))
return GLFW_FALSE;
#if defined(_GLFW_WGL)
status = _glfwAnalyzeContext(window, ctxconfig, fbconfig);
if (status == _GLFW_RECREATION_IMPOSSIBLE)
return GLFW_FALSE;
if (status == _GLFW_RECREATION_REQUIRED)
{
// Some window hints require us to re-create the context using WGL
// extensions retrieved through the current context, as we cannot
// check for WGL extensions or retrieve WGL entry points before we
// have a current context (actually until we have implicitly loaded
// the vendor ICD)
// Yes, this is strange, and yes, this is the proper way on WGL
// As Windows only allows you to set the pixel format once for
// a window, we need to destroy the current window and create a new
// one to be able to use the new pixel format
// Technically, it may be possible to keep the old window around if
// we're just creating an OpenGL 3.0+ context with the same pixel
// format, but it's not worth the added code complexity
// First we clear the current context (the one we just created)
// This is usually done by glfwDestroyWindow, but as we're not doing
// full GLFW window destruction, it's duplicated here
_glfwPlatformMakeContextCurrent(NULL);
// Next destroy the Win32 window and WGL context (without resetting
// or destroying the GLFW window object)
_glfwDestroyContext(window);
destroyWindow(window);
// ...and then create them again, this time with better APIs
if (!createWindow(window, wndconfig))
return GLFW_FALSE;
if (!_glfwCreateContext(window, ctxconfig, fbconfig))
return GLFW_FALSE;
}
#endif // _GLFW_WGL
}
if (wndconfig->fullscreen)
{
_glfwPlatformShowWindow(window);
if (!enterFullscreenMode(window))
return GLFW_FALSE;
}
return GLFW_TRUE;
}
开发者ID:edensal,项目名称:glfw,代码行数:67,代码来源:win32_window.c
示例20: create_vulkan_renderer_backend
void create_vulkan_renderer_backend(ReaperRoot& root, VulkanBackend& backend)
{
REAPER_PROFILE_SCOPE("Vulkan", MP_RED1);
log_info(root, "vulkan: creating backend");
log_debug(root, "vulkan: loading {}", REAPER_VK_LIB_NAME);
backend.vulkanLib = dynlib::load(REAPER_VK_LIB_NAME);
vulkan_load_exported_functions(backend.vulkanLib);
vulkan_load_global_level_functions();
std::vector<const char*> extensions = {VK_KHR_SURFACE_EXTENSION_NAME, REAPER_VK_SWAPCHAIN_EXTENSION_NAME};
#if defined(REAPER_DEBUG)
extensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
#endif
log_info(root, "vulkan: using {} instance level extensions", extensions.size());
for (auto& e : extensions)
log_debug(root, "- {}", e);
vulkan_instance_check_extensions(extensions);
std::vector<const char*> layers;
#if defined(REAPER_DEBUG) && !defined(REAPER_PLATFORM_WINDOWS)
layers.push_back("VK_LAYER_LUNARG_standard_validation");
#endif
log_info(root, "vulkan: using {} instance level layers", layers.size());
for (auto& layer : layers)
log_debug(root, "- {}", layer);
vulkan_instance_check_layers(layers);
VkApplicationInfo application_info = {
VK_STRUCTURE_TYPE_APPLICATION_INFO, // VkStructureType sType
nullptr, // const void *pNext
"MyGame", // const char *pApplicationName
VK_MAKE_VERSION(
REAPER_VERSION_MAJOR, REAPER_VERSION_MINOR, REAPER_VERSION_PATCH), // uint32_t applicationVersion
"Reaper", // const char *pEngineName
VK_MAKE_VERSION(REAPER_VERSION_MAJOR, REAPER_VERSION_MINOR, REAPER_VERSION_PATCH), // uint32_t engineVersion
REAPER_VK_API_VERSION // uint32_t apiVersion
};
uint32_t layerCount = static_cast<uint32_t>(layers.size());
uint32_t extensionCount = static_cast<uint32_t>(extensions.size());
VkInstanceCreateInfo instance_create_info = {
VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // VkStructureType sType
nullptr, // const void* pNext
0, // VkInstanceCreateFlags flags
&application_info, // const VkApplicationInfo *pApplicationInfo
layerCount, // uint32_t enabledLayerCount
(layerCount > 0 ? &layers[0] : nullptr), // const char * const *ppEnabledLayerNames
extensionCount, // uint32_t enabledExtensionCount
(extensionCount > 0 ? &extensions[0] : nullptr), // const char * const *ppEnabledExtensionNames
};
Assert(vkCreateInstance(&instance_create_info, nullptr, &backend.instance) == VK_SUCCESS,
"cannot create Vulkan instance");
vulkan_load_instance_level_functions(backend.instance);
#if defined(REAPER_DEBUG)
log_debug(root, "vulkan: attaching debug callback");
vulkan_setup_debug_callback(root, backend);
#endif
WindowCreationDescriptor windowDescriptor;
windowDescriptor.title = "Vulkan";
windowDescriptor.width = 800;
windowDescriptor.height = 600;
windowDescriptor.fullscreen = false;
log_info(root,
"vulkan: creating window: size = {}x{}, title = '{}', fullscreen = {}",
windowDescriptor.width,
windowDescriptor.height,
windowDescriptor.title,
windowDescriptor.fullscreen);
IWindow* window = createWindow(windowDescriptor);
root.renderer->window = window;
log_debug(root, "vulkan: creating presentation surface");
vulkan_create_presentation_surface(backend.instance, backend.presentInfo.surface, window);
log_debug(root, "vulkan: choosing physical device");
vulkan_choose_physical_device(root, backend, backend.physicalDeviceInfo);
log_debug(root, "vulkan: creating logical device");
vulkan_create_logical_device(root, backend);
SwapchainDescriptor swapchainDesc;
swapchainDesc.preferredImageCount = 2; // Double buffering
swapchainDesc.preferredFormat = {VK_FORMAT_B8G8R8A8_UNORM, VK_COLORSPACE_SRGB_NONLINEAR_KHR};
swapchainDesc.preferredExtent = {windowDescriptor.width, windowDescriptor.height};
//.........这里部分代码省略.........
开发者ID:Ryp,项目名称:Reaper,代码行数:101,代码来源:SwapchainRendererBase.cpp
注:本文中的createWindow函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论