// create a new window and set it's characteristics
int OpenGLDisplayDevice::open_window(char *nm, int *size, int *loc,
                                     int argc, char** argv) {
  int SX = 596, SY = 190;
  if (loc) {
    SX = loc[0];
    // X screen uses Y increasing from upper-left corner down; this is
    // opposite to what GL does, which is the way VMD was set up originally
    SY = screenY - loc[1] - size[1];
  }
  glwsrv.cursornum = 0; // initialize cursor number
  
  // window opening stuff goes here
  int rc = OpenWin32Connection(&glwsrv);
  if (rc != 0) {
    return -1;
  }

  xOrig = 0;
  yOrig = 0;
  xSize = size[0]; 
  ySize = size[1]; 
  glwsrv.width = xSize; 
  glwsrv.height = ySize; 
  rc = myCreateWindow(this, 0, 0, glwsrv.width, glwsrv.height);
  if (rc != 0) {
    return -1;
  }

  // Determine if stereo is available
  if (glwsrv.PFDisStereo == 0) {
    ext->hasstereo = FALSE;
  } else {
    ext->hasstereo = TRUE;
  }
  ext->stereodrawforced = FALSE; // don't force stereo draws initially
  
  setup_initial_opengl_state();

#ifdef VMDSPACEWARE
  vmd_setupwin32spaceball(&glwsrv); 
#endif

  // normal return: window was successfully created
  have_window = TRUE;
  // return window id
  return 0;
}
Esempio n. 2
0
int main()
{

	GLFWwindow* window = myCreateWindow();

	GLchar* earth = "Model/earth/earth.obj";
	GLchar* moon = "Model/moon/moon.obj";

	vector<const GLchar*> faces;
	faces.push_back("Texture/sky/purplenebula_rt.tga");
	faces.push_back("Texture/sky/purplenebula_lf.tga");
	faces.push_back("Texture/sky/purplenebula_up.tga");
	faces.push_back("Texture/sky/purplenebula_dn.tga");
	faces.push_back("Texture/sky/purplenebula_bk.tga");
	faces.push_back("Texture/sky/purplenebula_ft.tga");

	//GLuint skyID = loadCubemap(faces);

	Star Earth(0.001,45.0f);
	Earth.init(earth);

	Star Moon(0.002, 45.0f,glm::vec3(0.0f,0.0f,0.0f), 2.0f);
	Moon.init(moon);

	while (!glfwWindowShouldClose(window))
	{
		GLfloat currentFrame = glfwGetTime();
		deltaTime = currentFrame - lastFrame;
		lastFrame = currentFrame;
		Do_Movement();
		glfwPollEvents();

		glClearColor(0.05f, 0.05f, 0.05f, 1.0f);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		Earth.drawStar();
		Moon.drawStar();

		glfwSwapBuffers(window);
	}

	glfwTerminate();
	return 0;
}