/*-----------------------------------------------------------------------------------------------
Description:
    Governs window creation, the initial OpenGL configuration (face culling, depth mask, even
    though this is a 2D demo and that stuff won't be of concern), the creation of geometry, and
    the creation of a texture.
Parameters:
    argc    (From main(...)) The number of char * items in argv.  For glut's initialization.
    argv    (From main(...)) A collection of argument strings.  For glut's initialization.
Returns:
    False if something went wrong during initialization, otherwise true;
Exception:  Safe
Creator:    John Cox (3-7-2016)
-----------------------------------------------------------------------------------------------*/
void Init()
{
    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);
    glFrontFace(GL_CCW);

    glEnable(GL_DEPTH_TEST);
    glDepthMask(GL_TRUE);
    glDepthFunc(GL_LEQUAL);
    glDepthRange(0.0f, 1.0f);

    gProgramId = GenerateShaderProgram();
    gUnifMatrixTransform = glGetUniformLocation(gProgramId, "translateMatrixWindowSpace");
    gUnifTextureSampler = glGetUniformLocation(gProgramId, "tex");

    GenerateTriangle(&gTriangle);
    GenerateBox(&gBox);
    GenerateCircle(&gCircle);
    InitializeGeometry(gProgramId, &gTriangle);
    InitializeGeometry(gProgramId, &gBox);
    InitializeGeometry(gProgramId, &gCircle);

    gTexture1Id = CreateRandom3BeamTexture();
    gTexture2Id = CreateRandom3BeamTexture();
    gTexture3Id = CreateRandom3BeamTexture();

    // the textures all share the same properties, so I'll use the same sampler for all
    gSamplerId = CreateGenericSampler();
}
예제 #2
0
void createLoadingScreen(const std::string &file_name, GLFWwindow *window) {

    auto program_id = ShaderProgram("src/shaders/vert_texture.glsl", "src/shaders/frag_texture.glsl");
    glUseProgram(program_id);
    InitializeGeometry(program_id);

    FileLoader::TGAFILE_t tgafile;
    FileLoader::LoadTGAFile(file_name.c_str(), &tgafile);

    std::vector<char> buffer(tgafile.imageData, tgafile.imageData + tgafile.imageWidth * tgafile.imageHeight * (tgafile.bitCount / 8));

    GLuint texture_id;
    glGenTextures(1, &texture_id);
    glBindTexture(GL_TEXTURE_2D, texture_id);

    // Set mipmaps
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1500, 843, 0, GL_RGB, GL_UNSIGNED_BYTE, buffer.data());

    auto texture_attrib = glGetUniformLocation(program_id, "Texture");
    glUniform1i(texture_attrib, 0);
    glActiveTexture(GL_TEXTURE0 + 0);
    glBindTexture(GL_TEXTURE_2D, texture_id);
    glClearColor(.5f,.5f,.5f,0);
    // Clear depth and color buffers
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    // Draw triangles using the program
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

    glfwSwapBuffers(window);
    //glfwPollEvents();
}
void WorldObjectWidget::SetSelection(WorldLight* light)
{
  UnsetSelection();
  InitializeGeometry(light->nodePath);
  InitializeCollider(light->collider);

  {
    LColor color = light->GetColor();
    ui->lightColorR->setValue(color.get_x());
    ui->lightColorG->setValue(color.get_y());
    ui->lightColorB->setValue(color.get_z());
  }

  ui->lightTargets->clear();
  std::for_each(light->enlightened_index.begin(), light->enlightened_index.end(), [this](const WorldLight::EnlightenedObjectSettings& settings)
  {
    ui->lightTargets->AddEnlightenedObject(settings.name.c_str(), settings.priority, settings.inherited_property);
  });

  ui->lightTypesList->setCurrentIndex((int)light->type);
  InitializeShadowCaster(light);
  InitializeLightAttenuation(light);
  ui->lightPriority->setValue(light->priority);
  ui->objectName->setEnabled(true);
  ui->objectName->setText(QString::fromStdString(light->name));
  ui->lightSetEnabled->setChecked(light->enabled);
  ui->lightSetDisabled->setChecked(!light->enabled);
  selection.light = light;
  selection_type  = 3;
  ui->tabWidget->addTab(ui->lightTab,        "Light");
  ui->tabWidget->addTab(ui->lightTargetsTab, "Light Targets");
}
logical DesignerMode :: Initialize ( )
{
logical                 term = NO;
OWidgetDesignMode::Initialize();
InitializeGeometry();
return(term);
}
logical DesignerMode :: SetODControl (ODControl *od_control )
{


control = od_control;
InitializeGeometry();
return(NO);
}
void WorldObjectWidget::InitializeMapObject(MapObject* object)
{
  ui->objectName->setEnabled(true);
  ui->objectName->setText(QString::fromStdString(object->name));
  ui->inheritsFloor->setChecked(object->inherits_floor);
  InitializeGeometry(object->nodePath);
  InitializeCollider(object->collider);
  InitializeRender(object);
  ui->objectFloor->setValue(object->floor);
}
예제 #7
0
파일: planetgrid.cpp 프로젝트: jpcoles/ZM
PlanetographicGrid::PlanetographicGrid(const Body& _body) :
    body(_body),
    minLongitudeStep(10.0f),
    minLatitudeStep(10.0f),
    longitudeConvention(Westward),
    northDirection(NorthNormal)
{
    if (xyCircle == NULL)
        InitializeGeometry();
    setTag("planetographic grid");
    setIAULongLatConvention();
}
예제 #8
0
bool SpotlightSample::Init()
{
	if (!DirectXGame::Init())
		return false;

	InitializeCamera();
	InitializeLighting();
	InitializeGeometry();
	InitializeShaders();
	InitializeShaderResources();

	return true;
}
예제 #9
0
void Level00::VInitialize()
{
	mState = BASE_SCENE_STATE_INITIALIZING;

	VOnResize();

	InitializeLevel();
	InitializeGrid();
	InitializeRobots();
	InitializeGeometry();
	InitializeWallShaders();
	InitializeLightShaders();
	InitializePlayerShaders();
	InitializeCamera();

	mState = BASE_SCENE_STATE_RUNNING;
}
예제 #10
0
logical DesignerMode :: Event (QEvent *pQEvent, QWidget *event_target )
{
QDropEvent * drop   = NULL;
QWidget    * widget = NULL;
QPoint       pos;
logical      term = NO;
if ( ctx_design && ctx_design->get_control() && ctx_design->get_control()->get_complexWidget() )
  widget = ctx_design->get_control()->get_complexWidget()->WidgetQ();

switch ( pQEvent->type() )
{
  case QEvent::Show:
    InitializeGeometry();
  default:
    term = OWidgetDesignMode::Event(pQEvent, event_target);
}
return(term);
}
예제 #11
0
int main() {
  // Initialize GLFW
  if (!glfwInit()) {
    std::cerr << "Failed to initialize GLFW!" << std::endl;
    return EXIT_FAILURE;
  }

  // Setup OpenGL context
  glfwWindowHint(GLFW_SAMPLES, 4);
  glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
  glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
  glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
  glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

  // Try to create a window
  auto window = glfwCreateWindow( SIZE, SIZE, "OpenGL", NULL, NULL);
  if (window == NULL) {
    std::cerr << "Failed to open GLFW window, your graphics card is probably only capable of OpenGL 2.1" << std::endl;
    glfwTerminate();
    return EXIT_FAILURE;
  }

  // Finalize window setup
  glfwMakeContextCurrent(window);

  // Initialize GLEW
  glewExperimental = GL_TRUE;
  glewInit();
  if (!glewIsSupported("GL_VERSION_3_3")) {
    std::cerr << "Failed to initialize GLEW with OpenGL 3.3!" << std::endl;
    glfwTerminate();
    return EXIT_FAILURE;
  }

  // Load shaders
  auto program_id = ShaderProgram("gl_texture.vert", "gl_texture.frag");
  glUseProgram(program_id);

  InitializeGeometry(program_id);

  // Create texture
  GLuint texture_id;
  glGenTextures(1, &texture_id);
  glBindTexture(GL_TEXTURE_2D, texture_id);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

  // Bind texture
  auto texture_attrib = glGetUniformLocation(program_id, "Texture");
  glUniform1i(texture_attrib, 0);
  glActiveTexture(GL_TEXTURE0 + 0);
  glBindTexture(GL_TEXTURE_2D, texture_id);

  // Time counter
  float time = 0;

  // Main execution loop
  while (!glfwWindowShouldClose(window)) {
    // Update Framebuffer
    UpdateFramebuffer(time++);

    // Update texture data with framebuffer
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, SIZE, SIZE, 0, GL_RGB, GL_UNSIGNED_BYTE, framebuffer);

    // Set gray background
    glClearColor(.5f,.5f,.5f,0);
    // Clear depth and color buffers
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Draw triangles using the program
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

    // Display result
    glfwSwapBuffers(window);
    glfwPollEvents();
  }

  // Clean up
  glfwTerminate();

  return EXIT_SUCCESS;
}
예제 #12
0
void Bomb::Initialize()
{
    InitializeGeometry();
    InitializeAnimation();
}
예제 #13
0
void Fire::Initialize()
{
    InitializeGeometry();
    InitializeAnimation();
}