Fixed image for a crosshair
parent
6acdd33de9
commit
5c91d808d2
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 344 B |
|
@ -28,24 +28,25 @@ int main(int argc, char **argv)
|
|||
while (window.isRunning())
|
||||
{
|
||||
Uint32 current_time = SDL_GetTicks();
|
||||
|
||||
float dt = static_cast<float>(current_time - last_time);
|
||||
|
||||
window.pollEvents();
|
||||
|
||||
camera.update(dt);
|
||||
|
||||
renderer.clear();
|
||||
|
||||
renderer.start2d();
|
||||
//renderer.drawRect(-0.01f, -0.01f, 0.02, 0.03, glm::vec3(1.0f, 1.0f, 1.0f));
|
||||
renderer.drawCrosshair();
|
||||
renderer.end2d();
|
||||
|
||||
renderer.start3d();
|
||||
{
|
||||
renderer.handleCamera(&camera);
|
||||
world_renderer.render(&world, &renderer);
|
||||
|
||||
}
|
||||
renderer.end3d();
|
||||
|
||||
renderer.start2d();
|
||||
{
|
||||
renderer.drawCrosshair();
|
||||
}
|
||||
renderer.end2d();
|
||||
|
||||
window.swapBuffers();
|
||||
|
||||
last_time = current_time;
|
||||
|
|
|
@ -14,21 +14,14 @@ Q3Texture *crosshairTexture;
|
|||
Q3Renderer::Q3Renderer()
|
||||
{
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glClearDepth(1.0f);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
glViewport(0, 0, Q3_WINDOWWIDTH, Q3_WINDOWHEIGHT);
|
||||
/*
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glm::mat4 perspective = glm::perspective(Q3_FOV, (float)Q3_WINDOWWIDTH / Q3_WINDOWHEIGHT, 0.1f, 100.0f);
|
||||
glLoadMatrixf(&perspective[0][0]);*/
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
|
@ -91,22 +84,27 @@ void Q3Renderer::drawRect(float x, float y, float w, float h, glm::vec3 col)
|
|||
|
||||
void Q3Renderer::drawCrosshair()
|
||||
{
|
||||
glColor3ub(240, 240, 240); //white
|
||||
glLineWidth(2.0);
|
||||
glPushMatrix();
|
||||
glTranslatef(-0.1f, -0.1f, 0.1f);
|
||||
crosshairTexture->bind();
|
||||
glBegin(GL_QUADS);
|
||||
{
|
||||
glTexCoord2f(0.f, 1.f);
|
||||
glVertex2f(0.f, 0.f);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glTexCoord2f(0.f, 0.f);
|
||||
glVertex2f(0.f, 0.2f);
|
||||
|
||||
glVertex3f(-0.05f, 0.f, 0.f);
|
||||
glVertex3f(0.05f, 0.f, 0.f);
|
||||
glTexCoord2f(1.f, 0.f);
|
||||
glVertex2f(0.2f, 0.2f);
|
||||
|
||||
glTexCoord2f(1.f, 1.f);
|
||||
glVertex2f(0.2f, 0.f);
|
||||
}
|
||||
glEnd();
|
||||
crosshairTexture->unbind();
|
||||
|
||||
glBegin(GL_LINES);
|
||||
|
||||
glVertex3f(0.f, -0.05f, 0.f);
|
||||
glVertex3f(0.f, 0.05f, 0.f);
|
||||
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void Q3Renderer::drawCube(float x, float y, float z, float sx, float sy, float sz)
|
||||
|
|
Loading…
Reference in New Issue