예제 #1
0
/**
 * Initializes the rendering using the appropriate rendering method.
 */
bool InitializeRendering()
{
	DestroyWaveMesh();

	DeinitRendering();

	D3DPRESENT_PARAMETERS params;
	memset(&params, 0, sizeof(D3DPRESENT_PARAMETERS));
	params.Windowed = !gFullscreen;
	params.SwapEffect = D3DSWAPEFFECT_DISCARD;
	params.hDeviceWindow = gWindowHandle;
	params.BackBufferCount = 2;
	if (gFullscreen)
	{
		GetScreenSize(gWindowWidth, gWindowHeight);

		params.BackBufferFormat = D3DFMT_A8R8G8B8;
		params.BackBufferWidth = gWindowWidth;
		params.BackBufferHeight = gWindowHeight;
	}
	else
	{
		gWindowWidth = 1280;
		gWindowHeight = 1024;

		unsigned int width, height;
		DetermineWindowSize(width, height);

		SetWindowPos(gWindowHandle, HWND_TOP, 0, 0, width, height, SWP_NOMOVE);
	}

	HRESULT hr = gGraphicsDevice->Reset(&params);
	if (FAILED(hr))
	{
		ReportError("Failed to initialize device");
		return false;
	}

	InitRendering(gWindowWidth, gWindowHeight, gBroadcastWidth, gBroadcastHeight);
	
	// Set the viewport
	D3DVIEWPORT9 vp;
	vp.X = 0;
	vp.Y = 0;
	vp.MinZ = 0.0f;
	vp.MaxZ = 1.0f;
	vp.Width = gWindowWidth;
	vp.Height = gWindowHeight;
	gGraphicsDevice->SetViewport(&vp);

	// Setup the projection matrix
	D3DXMatrixPerspectiveFovLH(&gProjectionMatrix, D3DXToRadian(60), (FLOAT)gWindowWidth/(FLOAT)gWindowHeight, 1, 1000);

	// Create the mesh that will be rendered
	CreateWaveMesh(64, 20);

	InitializeChatRenderer(gWindowWidth, gWindowHeight);

	return true;
}
예제 #2
0
파일: Engine.cpp 프로젝트: subr3v/s-engine
void Init(HINSTANCE hInstance, int nCmdShow)
{
	// Make sure everything is zero-ed out.
	memset(&EngineModules, 0, sizeof(FEngineModules));

	InitCore(hInstance, nCmdShow);
	InitRendering();
	InitImGui();
}
int ParticleEngineServer::RenderIndex(int ID,float animate)
{
	InitRendering();
	int numRendered=0;
	if(children[ID])
	{
		numRendered=children[ID]->RenderParticles(&rminu,&rpluu,animate);
		childrenRendered[ID]=1;
		if(children[ID]->killFlag)
			KillChild(ID);
	}
	CloseRendering();
	return numRendered;
}
int ParticleEngineServer::RenderAll(float animate)
{
	InitRendering();
	int numRendered=0;
	for(int a=0;a<numChildren;a++)
	{
		if(children[a] && !childrenRendered[a])		// Validate that the child exists
		{
			numRendered+=children[a]->RenderParticles(&rminu,&rpluu,animate);
			if(children[a]->killFlag)
				KillChild(a);
		}
		childrenRendered[a] = 0;
	}
	CloseRendering();
	return numRendered;
}
예제 #5
0
파일: SGLDL.cpp 프로젝트: turrikasd/SGLDL
void sgInit(int argc, char* argv[], int width, int height, Game* game)
{
	gamePointer = game;
	wi = width;
	he = height;

	// Init GLUT
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
	glutInitWindowSize(width, height);

	// Create Window
	glutCreateWindow("Game1");

	InitRendering(); // function

	// Set handler functions
	glutDisplayFunc(DrawScene);
	glutKeyboardFunc(HandleKeypress);
	glutReshapeFunc(HandleResize);

	glutTimerFunc(17.0f, sgUpdate, 0);
}
예제 #6
0
int
main(int argc, char *argv[])
{
  const int winWidth = 800, winHeight = 600;
  Display *x_dpy;
  Window win;
  EGLSurface egl_surf;
  EGLContext egl_ctx;
  EGLDisplay egl_dpy;
  char *dpyName = NULL;
  GLboolean printInfo = GL_FALSE;
  EGLint egl_major, egl_minor;
  const char *s;


  if (!InitTest(argc, argv)) {
    return -1;
  }

  x_dpy = XOpenDisplay(dpyName);
  if (!x_dpy) {
    printf("Error: couldn't open display %s\n",
           dpyName ? dpyName : getenv("DISPLAY"));
    return -1;
  }

  egl_dpy = eglGetDisplay(x_dpy);
  if (!egl_dpy) {
    printf("Error: eglGetDisplay() failed\n");
    return -1;
  }

  if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
    printf("Error: eglInitialize() failed\n");
    return -1;
  }

  s = eglQueryString(egl_dpy, EGL_VERSION);
  printf("EGL_VERSION = %s\n", s);

  s = eglQueryString(egl_dpy, EGL_VENDOR);
  printf("EGL_VENDOR = %s\n", s);

  s = eglQueryString(egl_dpy, EGL_EXTENSIONS);
  printf("EGL_EXTENSIONS = %s\n", s);

  s = eglQueryString(egl_dpy, EGL_CLIENT_APIS);
  printf("EGL_CLIENT_APIS = %s\n", s);

  make_x_window(x_dpy, egl_dpy,
               "OpenGL ES 2.x tri", 0, 0, winWidth, winHeight,
               &win, &egl_ctx, &egl_surf);

  XMapWindow(x_dpy, win);
  if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
    printf("Error: eglMakeCurrent() failed\n");
    return -1;
  }

  if (printInfo) {
    printf("GL_RENDERER   = %s\n", (char *) glGetString(GL_RENDERER));
    printf("GL_VERSION    = %s\n", (char *) glGetString(GL_VERSION));
    printf("GL_VENDOR     = %s\n", (char *) glGetString(GL_VENDOR));
    printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
  }


  InitRendering();

  LoadData(testHelper->app()->defaultBuiltinDatasetIndex());

  // render once
  testHelper->app()->resizeView(winWidth, winHeight);
  testHelper->app()->applyBuiltinDatasetCameraParameters(testHelper->app()->defaultBuiltinDatasetIndex());
  testHelper->app()->render();
  eglSwapBuffers(egl_dpy, egl_surf);

  // begin the event loop if not in testing mode
  bool testPassed = true;
  if (!testHelper->isTesting()) {
    event_loop(x_dpy, win, egl_dpy, egl_surf);
  }
  else {
    testPassed = DoTesting();
  }

  FinalizeTest();

  eglDestroyContext(egl_dpy, egl_ctx);
  eglDestroySurface(egl_dpy, egl_surf);
  eglTerminate(egl_dpy);


  XDestroyWindow(x_dpy, win);
  XCloseDisplay(x_dpy);

  return testPassed ? 0 : 1;
}