-
Notifications
You must be signed in to change notification settings - Fork 7
Added orthographic mode #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tobleroneaddict
wants to merge
7
commits into
Vogtinator:master
Choose a base branch
from
tobleroneaddict:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+25
−5
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
73251ff
Update gl.h
tobleroneaddict 5c0a4eb
Update gl.cpp
tobleroneaddict a3deb29
Update gl.cpp
tobleroneaddict bc4fa90
Update gl.cpp
tobleroneaddict 210fabb
Update gl.cpp
tobleroneaddict 96d0d6b
Update gl.h
tobleroneaddict f0a1c96
Update gl.cpp
tobleroneaddict File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ static SDL_Surface *scr; | |
| #define P(m, y, x) (m->data[y][x]) | ||
|
|
||
| MATRIX *transformation; | ||
| static GLProjectionMode projection_mode = GLProjectionMode::GL_PROJECTION_PERSPECTIVE; //Default mode is perspective | ||
| static COLOR color; | ||
| static GLFix u, v; | ||
| static COLOR *screen; | ||
|
|
@@ -27,8 +28,10 @@ static const TEXTURE *texture; | |
| static unsigned int vertices_count = 0; | ||
| static VERTEX vertices[4]; | ||
| static GLDrawMode draw_mode = GL_TRIANGLES; | ||
| static bool is_monochrome; | ||
| static COLOR *screen_inverted; //For monochrome calcs | ||
| #ifdef _TINSPIRE | ||
| static bool is_monochrome; | ||
| static COLOR *screen_inverted; //For monochrome calcs | ||
| #endif | ||
| #ifdef FPS_COUNTER | ||
| volatile unsigned int fps; | ||
| #endif | ||
|
|
@@ -74,10 +77,9 @@ void nglUninit() | |
| uninit_fastmath(); | ||
| delete[] transformation; | ||
| delete[] z_buffer; | ||
|
|
||
| delete[] screen_inverted; | ||
|
|
||
|
|
||
| #ifdef _TINSPIRE | ||
| delete[] screen_inverted; | ||
| lcd_init(SCR_TYPE_INVALID); | ||
| #else | ||
| //TODO | ||
|
|
@@ -133,8 +135,16 @@ void nglMultMatVectRes(const MATRIX *mat1, const VECTOR3 *vect, VECTOR3 *res) | |
| res->z = P(mat1, 2, 0)*x + P(mat1, 2, 1)*y + P(mat1, 2, 2)*z + P(mat1, 2, 3); | ||
| } | ||
|
|
||
| void nglSetProjectionMode(GLProjectionMode mode) | ||
| { | ||
| projection_mode = mode; | ||
| } | ||
|
|
||
| void nglPerspective(VERTEX *v) | ||
| { | ||
| if (projection_mode == GL_PROJECTION_ORTHOGRAPHIC) | ||
| return; //Ortho mode | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs blank line after this |
||
|
|
||
| #ifdef BETTER_PERSPECTIVE | ||
| float new_z = v->z; | ||
| decltype(new_z) new_x = v->x, new_y = v->y; | ||
|
|
@@ -188,6 +198,9 @@ void nglPerspective(VERTEX *v) | |
|
|
||
| void nglPerspective(VECTOR3 *v) | ||
| { | ||
| if (projection_mode == GL_PROJECTION_ORTHOGRAPHIC) | ||
|
tobleroneaddict marked this conversation as resolved.
|
||
| return; //Ortho mode | ||
|
|
||
| #ifdef BETTER_PERSPECTIVE | ||
| float new_z = v->z; | ||
| decltype(new_z) new_x = v->x, new_y = v->y; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this is the right place. Arguably the projection should only be applied to actual drawing, not when calling nglPerspective manually? Not sure about use cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It felt less verbose than adding it to every usage of nglPerspective().