本文整理汇总了C++中Mtx44::SetToOrtho方法的典型用法代码示例。如果您正苦于以下问题:C++ Mtx44::SetToOrtho方法的具体用法?C++ Mtx44::SetToOrtho怎么用?C++ Mtx44::SetToOrtho使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mtx44
的用法示例。
在下文中一共展示了Mtx44::SetToOrtho方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void Text2D::PrintText(const char* text, Color color, float size, float x, float y)
{
if(!m_mesh || m_mesh->textureID <= 0)
{
std::cout << "No text loaded\n";
return;
}
if(!text)
{
std::cout << "No text\n";
}
glUseProgram(m_shaderID);
glUniform3fv(m_uniformTextColor, 1, &color.r);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_mesh->textureID);
glUniform1i(m_uniformTexture, 0);
glDisable(GL_DEPTH_TEST);
Mtx44 ortho;
ortho.SetToOrtho(0, 40, 0, 30, -10, 10);
for(unsigned i = 0; i < strlen(text); ++i)
{
Mtx44 translate;
translate.SetToTranslation(i * 0.5f, 0, i * 0.001f);
Mtx44 MVP = ortho * translate;
glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
mesh->Render((unsigned)text[i] * 6, 6);
}
glEnable(GL_DEPTH_TEST);
glBindTexture(GL_TEXTURE_2D, 0);
glUniform1i(m_parameters[U_TEXT_ENABLED], 0);
}
示例2: QuestDetail
void SceneGalaxy::QuestDetail()
{
if (QuestDetailShown == false)
{
Mtx44 ortho;
glDisable(GL_DEPTH_TEST);
ortho.SetToOrtho(0, 80, 0, 60, -10, 10); //size of screen UI
projectionStack.PushMatrix();
projectionStack.LoadMatrix(ortho);
viewStack.PushMatrix();
viewStack.LoadIdentity(); //No need camera for ortho mode
modelStack.PushMatrix();
modelStack.LoadIdentity(); //Reset modelStack
modelStack.Translate(37.5, 27.5, -2);
modelStack.Scale(30, 50, 10);
modelStack.Rotate(90, 1, 0, 0);
renderMesh(meshList[GEO_BLACKSCREEN], false);
projectionStack.PopMatrix();
viewStack.PopMatrix();
modelStack.PopMatrix();
glEnable(GL_DEPTH_TEST);
if (Application::IsKeyPressed('E'))
{
QuestDetailShown = true;
}
}
}
示例3: Render
void UI::Render(const unsigned& screenX, const unsigned& screenY)
{
Mtx44 projection;
const unsigned depth = 100;
projection.SetToOrtho(0, screenX, 0, screenY, -depth, depth);
displaysFactory.Render(projection);
}
示例4:
void PLANET5::RenderHandOnScreen()
{
glDisable(GL_DEPTH_TEST);
//Add these code just after glDisable(GL_DEPTH_TEST);
Mtx44 ortho;
ortho.SetToOrtho(0, 80, 0, 60, -20, 20); //size of screen UI
projectionStack.PushMatrix();
projectionStack.LoadMatrix(ortho);
viewStack.PushMatrix();
viewStack.LoadIdentity(); //No need camera for ortho mode
modelStack.PushMatrix();
modelStack.LoadIdentity(); //Reset modelStack
modelStack.Translate(55 + MS_rotate / 2, -10 - MS_rotate / 6, 15);
modelStack.Rotate(155, 1, 0, 0);
modelStack.Rotate(-127, 0, 1, 0);
modelStack.Rotate(23, 0, 0, 1);
modelStack.Scale(6, 12, 8);
RenderMesh(meshList[ARM2], false);
//Add these code just before glEnable(GL_DEPTH_TEST);
projectionStack.PopMatrix();
viewStack.PopMatrix();
modelStack.PopMatrix();
glEnable(GL_DEPTH_TEST);
}
示例5: glClear
void Scene2::Render()
{
// clear color every frame
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Mtx44 translate, rotate, scale;
Mtx44 model;
Mtx44 view;
Mtx44 projection;
Mtx44 MVP;
translate.SetToIdentity();
rotate.SetToIdentity();
scale.SetToIdentity();
model.SetToIdentity();
view.SetToIdentity();//camera set at world origin
projection.SetToOrtho(-40, +40, -30, +30, -10, +10); //define the world in a cube by these boundaries
glEnableVertexAttribArray(0); //1st attri buffer: vertices
glEnableVertexAttribArray(1);
scale.SetToScale(10, 10, 10);
rotate.SetToRotation(45, 0, 0, 1);
translate.SetToTranslation(5, 5, 0);
model = translate * rotate *scale; //scale, fcollowed by rotate then translate
MVP = projection * view * model;
glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update new shader w MVP
glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_TRIANGLE_1]);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TRIANGLE_1]);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
//draw triangle
glDrawArrays(GL_TRIANGLES, 0, 6); //starting from vertex 0; 3 vertices = 1 triangle
glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_TRIANGLE_1]);
glVertexAttribPointer
(
0, //Attribute 0. Must match layout in shader. usually 0 is for vertex
3, //size
GL_FLOAT, //type
GL_FALSE, //normalised
0, //stride
0 //array buffer offset
);
glEnableVertexAttribArray(1);//2nd attr buffer: colors
glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TRIANGLE_1]);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(0);
}
示例6: LoadOrthoCamera
void View::LoadOrthoCamera()
{
this->m_eViewState = VIEW_ORTHO;
Mtx44 Projection;
Projection.SetToOrtho(0, (float)m_viewPort[VIEWPORT_WIDTH], 0, (float)m_viewPort[VIEWPORT_HEIGHT], -10, 100);
projectionStack.LoadIdentity();
projectionStack.LoadMatrix(Projection);
}
示例7:
void View::Render2DMesh(Mesh *mesh, bool enableLight, bool enableFog, float sizeX, float sizeY, float transX, float transY, float rotateValue)
{
if (mesh == NULL)
return;
Mtx44 ortho;
ortho.SetToOrtho(0, (float)m_viewPort[VIEWPORT_WIDTH], 0, (float)m_viewPort[VIEWPORT_HEIGHT], -10, 100);
projectionStack.PushMatrix();
projectionStack.LoadMatrix(ortho);
viewStack.PushMatrix();
viewStack.LoadIdentity();
modelStack.PushMatrix();
modelStack.LoadIdentity();
modelStack.Translate(transX, transY, 0);
modelStack.Rotate(rotateValue, 0, 0, 1);
modelStack.Scale(sizeX, sizeY, 1);
Mtx44 MVP, modelView, modelView_inverse_transpose;
MVP = projectionStack.Top() * viewStack.Top() * modelStack.Top();
// Alpha
glUniform1f(m_parameters[U_OBJECT_ALPHA], mesh->alpha);
glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
for (int i = 0; i < MAX_TEXTURES; i++)
{
if (mesh->textureArray[i] > 0)
{
glUniform1i(m_parameters[U_COLOR_TEXTURE_ENABLED + i], 1);
}
else
{
glUniform1i(m_parameters[U_COLOR_TEXTURE_ENABLED + i], 0);
}
glActiveTexture(GL_TEXTURE0 + i);
glBindTexture(GL_TEXTURE_2D, mesh->textureArray[i]);
//
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
//
glUniform1i(m_parameters[U_COLOR_TEXTURE + i], i);
}
mesh->Render();
glBindTexture(GL_TEXTURE_2D, 0);
modelStack.PopMatrix();
viewStack.PopMatrix();
projectionStack.PopMatrix();
}
示例8: glClear
void SP3::Render()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Projection matrix : Orthographic Projection
Mtx44 projection;
projection.SetToOrtho(0, m_worldWidth, 0, m_worldHeight, -10, 10);
projectionStack.LoadMatrix(projection);
// Camera matrix
viewStack.LoadIdentity();
viewStack.LookAt(
camera.position.x, camera.position.y, camera.position.z,
camera.target.x, camera.target.y, camera.target.z,
camera.up.x, camera.up.y, camera.up.z
);
// Model matrix : an identity matrix (model will be at the origin)
modelStack.LoadIdentity();
RenderMesh(meshList[GEO_AXES], false);
for (std::vector<GameObject *>::iterator it = m_goList.begin(); it != m_goList.end(); ++it)
{
GameObject *go = (GameObject *)*it;
if (go->active)
{
RenderGO(go);
}
}
std::ostringstream ss;
ss.str(string());
ss.precision(5);
ss << "FPS: " << fps;
RenderTextOnScreen(meshList[GEO_TEXT], ss.str(), Color(0, 1, 0), 3, 0, 0);
if (gameState == Menu)
{
modelStack.PushMatrix();
modelStack.Translate(65.f, 50.f, 0.f);
modelStack.Scale(115, 90, 0);
RenderMesh(meshList[GEO_UI], false);
modelStack.PopMatrix();
modelStack.PushMatrix();
RenderTextOnScreen(meshList[GEO_TEXT], "Welcome", Color(0, 0, 1), 4, 25, 50);
RenderTextOnScreen(meshList[GEO_TEXT], "To", Color(0, 0, 1), 4, 35, 45);
RenderTextOnScreen(meshList[GEO_TEXT], "Suk Malcolm Deek", Color(0, 0, 1), 4, 8, 40);
RenderTextOnScreen(meshList[GEO_TEXT], "Start Game", Color(1, 0, 0), 4, 20, 20);
RenderTextOnScreen(meshList[GEO_TEXT], "Quit Game", Color(1, 0, 0), 4, 22, 15);
modelStack.PopMatrix();
}
}
示例9:
void SceneText::Render2DMesh(Mesh *mesh, bool enableLight, float size, float x, float y, bool rotate)
{
glDisable(GL_DEPTH_TEST);
Mtx44 ortho;
ortho.SetToOrtho(0, 1024, 0, 800, -10, 10);
projectionStack.PushMatrix();
projectionStack.LoadMatrix(ortho);
viewStack.PushMatrix();
viewStack.LoadIdentity();
modelStack.PushMatrix();
modelStack.LoadIdentity();
modelStack.Translate(x, y, 0);
modelStack.Scale(size, size, size);
if(rotate)
{
//glDisable(GL_CULL_FACE);
//modelStack.Rotate(180, 0, 1, 0);
}
Mtx44 MVP, modelView, modelView_inverse_transpose;
MVP = projectionStack.Top() * viewStack.Top() * modelStack.Top();
glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
if(mesh->textureID > 0)
{
glUniform1i(m_parameters[U_COLOR_TEXTURE_ENABLED], 1);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, mesh->textureID);
glUniform1i(m_parameters[U_COLOR_TEXTURE], 0);
}
else
{
glUniform1i(m_parameters[U_COLOR_TEXTURE_ENABLED], 0);
}
mesh->Render();
if(mesh->textureID > 0)
{
glBindTexture(GL_TEXTURE_2D, 0);
}
modelStack.PopMatrix();
viewStack.PopMatrix();
projectionStack.PopMatrix();
glEnable(GL_DEPTH_TEST);
}
示例10: RenderTextOnScreen
void GameScene::RenderTextOnScreen(Mesh* mesh, std::string text, Colour colour, float size, float x, float y) {
if(!mesh || mesh->textureID <= 0) {//Proper error check
return;
}
glDisable(GL_DEPTH_TEST);
Mtx44 ortho;
ortho.SetToOrtho(0, glfwGetVideoMode(glfwGetPrimaryMonitor())->width, 0, glfwGetVideoMode(glfwGetPrimaryMonitor())->height, -10, 10); //size of screen UI
projectionStack.PushMatrix();
projectionStack.LoadMatrix(ortho);
viewStack.PushMatrix();
viewStack.LoadIdentity(); //No need camera for ortho mode
modelStack.PushMatrix();
modelStack.LoadIdentity(); //Reset modelStack
modelStack.Scale(size, size, size);
modelStack.Translate(x, y, 0);
glUniform1i(m_parameters[U_TEXT_ENABLED], 1);
glUniform3fv(m_parameters[U_TEXT_COLOR], 1, &colour.r);
glUniform1i(m_parameters[U_LIGHTENABLED], 0);
glUniform1i(m_parameters[U_COLOR_TEXTURE_ENABLED], 1);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, mesh->textureID);
glUniform1i(m_parameters[U_COLOR_TEXTURE], 0);
for(unsigned i = 0; i < text.length(); ++i) {
Mtx44 characterSpacing;
characterSpacing.SetToTranslation(i * 0.3f, 0, 0); //1.0f is the spacing of each character, you may change this value
Mtx44 MVP = projectionStack.Top() * viewStack.Top() * modelStack.Top() * characterSpacing;
glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
mesh->Render((unsigned)text[i] * 6, 6);
}
glBindTexture(GL_TEXTURE_2D, 0);
glUniform1i(m_parameters[U_TEXT_ENABLED], 0);
projectionStack.PopMatrix();
viewStack.PopMatrix();
modelStack.PopMatrix();
glEnable(GL_DEPTH_TEST);
}
示例11: double
/********************************************************************************
Render a mesh in 2D
********************************************************************************/
void SceneManager::Render2DMesh(Mesh *mesh, const bool enableLight, const Vector2 scale, const Vector2 pos, const float rotation)
{
if (!mesh || mesh->textureID <= 0)
return;
glDisable(GL_DEPTH_TEST);
Mtx44 ortho;
ortho.SetToOrtho(0, double(sceneWidth), 0, double(sceneHeight), -100, 100);
projectionStack.PushMatrix();
projectionStack.LoadMatrix(ortho);
viewStack.PushMatrix();
viewStack.LoadIdentity();
modelStack.PushMatrix();
modelStack.LoadIdentity();
modelStack.Translate(pos.x, pos.y, 0);
modelStack.Scale(scale.x, scale.y, 1);
if (rotation != 0.f)
modelStack.Rotate(rotation, 0, 0, 1);
Mtx44 MVP, modelView, modelView_inverse_transpose;
MVP = projectionStack.Top() * viewStack.Top() * modelStack.Top();
glUniformMatrix4fv(parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
if (mesh->textureID != NULL)
{
glUniform1i(parameters[U_COLOR_TEXTURE_ENABLED], 1);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, mesh->textureID);
glUniform1i(parameters[U_COLOR_TEXTURE], 0);
}
else
{
glUniform1i(parameters[U_COLOR_TEXTURE_ENABLED], 0);
}
mesh->Render();
if (mesh->textureID > 0)
{
glBindTexture(GL_TEXTURE_2D, 0);
}
modelStack.PopMatrix();
viewStack.PopMatrix();
projectionStack.PopMatrix();
glEnable(GL_DEPTH_TEST);
}
示例12: SetHUD
void SceneBase::SetHUD(const bool m_bHUDmode)
{
if (m_bHUDmode)
{
glDisable(GL_DEPTH_TEST);
Mtx44 ortho;
ortho.SetToOrtho(0, 80, 0, 60, -10, 10);
projectionStack.PushMatrix();
projectionStack.LoadMatrix(ortho);
}
else
{
projectionStack.PopMatrix();
glEnable(GL_DEPTH_TEST);
}
}
示例13:
void SceneBase::RenderMeshIn2D(Mesh *mesh, bool enableLight, float size, float x, float y, float rotate)
{
Mtx44 ortho;
//ortho.SetToOrtho(-m_window_width * 0.5f, m_window_width * 0.5f, -m_window_height * 0.5f, m_window_height * 0.5f, -10, 10);
ortho.SetToOrtho(0, m_window_width, 0, m_window_height, -10, 10);
projectionStack.PushMatrix();
projectionStack.LoadMatrix(ortho);
viewStack.PushMatrix();
viewStack.LoadIdentity();
/*modelStack.PushMatrix();
modelStack.LoadIdentity();
modelStack.Translate(x,y,0);
modelStack.Rotate(rotate, 0, 0, 1);
modelStack.Scale(size, size, size);*/
Mtx44 MVP, modelView, modelView_inverse_transpose;
MVP = projectionStack.Top() * viewStack.Top() * modelStack.Top();
glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
for (int i = 0; i < Mesh::MAX_TEXTURES; ++i)
{
if(mesh->textureID[i] > 0)
{
glUniform1i(m_parameters[U_COLOR_TEXTURE_ENABLED + (i * 2)], 1);
glActiveTexture(GL_TEXTURE0 + i);
glBindTexture(GL_TEXTURE_2D, mesh->textureID[i]);
glUniform1i(m_parameters[U_COLOR_TEXTURE + (i * 2)], i);
}
else
{
glUniform1i(m_parameters[U_COLOR_TEXTURE_ENABLED + (i * 2)], 0);
}
}
mesh->Render();
for (int i = 0; i < Mesh::MAX_TEXTURES; ++i)
{
if(mesh->textureID[i] > 0)
{
glBindTexture(GL_TEXTURE_2D, 0);
}
}
//modelStack.PopMatrix();
viewStack.PopMatrix();
projectionStack.PopMatrix();
}
示例14:
/********************************************************************************
Render this scene
********************************************************************************/
void CSceneManager2D::Render()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Mtx44 perspective;
//perspective.SetToPerspective(45.0f, 4.0f / 3.0f, 0.1f, 10000.0f);
perspective.SetToOrtho(0, m_window_width, 0, m_window_height, -1000, 1000);
projectionStack.LoadMatrix(perspective);
// Set up the view
viewStack.LoadIdentity();
viewStack.LookAt( camera.position.x, camera.position.y, camera.position.z,
camera.target.x, camera.target.y, camera.target.z,
camera.up.x, camera.up.y, camera.up.z );
// Model matrix : an identity matrix (model will be at the origin)
modelStack.LoadIdentity();
}
示例15: RenderTextOnScreen
/********************************************************************************
Render text onto the screen
********************************************************************************/
void SceneManager::RenderTextOnScreen(Mesh* mesh, std::string text, Color color, float size, float x, float y, float rotation)
{
if (!mesh || mesh->textureID <= 0)
return;
glDisable(GL_DEPTH_TEST);
Mtx44 ortho;
ortho.SetToOrtho(0, double(sceneWidth), 0, double(sceneHeight), -10, 10);
projectionStack.PushMatrix();
projectionStack.LoadMatrix(ortho);
viewStack.PushMatrix();
viewStack.LoadIdentity();
modelStack.PushMatrix();
modelStack.LoadIdentity();
modelStack.Translate(x, y, 0);
if (rotation != 0.f)
{
modelStack.Rotate(rotation, 0, 0, 1);
}
modelStack.Scale(size, size, size);
glUniform1i(parameters[U_TEXT_ENABLED], 1);
glUniform3fv(parameters[U_TEXT_COLOR], 1, &color.r);
glUniform1i(parameters[U_LIGHTENABLED], 0);
glUniform1i(parameters[U_COLOR_TEXTURE_ENABLED], 1);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, mesh->textureID);
glUniform1i(parameters[U_COLOR_TEXTURE], 0);
float temp = 0;
for (unsigned i = 0; i < text.length(); ++i)
{
Mtx44 characterSpacing;
characterSpacing.SetToTranslation(temp * 1.5f, 0, 0); //1.0f is the spacing of each character, you may change this value
Mtx44 MVP = projectionStack.Top() * viewStack.Top() * modelStack.Top() * characterSpacing;
glUniformMatrix4fv(parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
temp += textWidth[text[i]] * 0.01;
mesh->Render((unsigned)text[i] * 6, 6);
}
glBindTexture(GL_TEXTURE_2D, 0);
glUniform1i(parameters[U_TEXT_ENABLED], 0);
modelStack.PopMatrix();
viewStack.PopMatrix();
projectionStack.PopMatrix();
glEnable(GL_DEPTH_TEST);
}