Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
netrunner
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Odilitime
netrunner
Commits
50a93f83
Commit
50a93f83
authored
7 years ago
by
Odilitime
Browse files
Options
Downloads
Patches
Plain Diff
useBoxShader, keep box coords on resize, no need to update indices on resize
parent
7f5f4345
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/graphics/components/InputComponent.cpp
+39
-9
39 additions, 9 deletions
src/graphics/components/InputComponent.cpp
with
39 additions
and
9 deletions
src/graphics/components/InputComponent.cpp
+
39
−
9
View file @
50a93f83
...
...
@@ -11,7 +11,8 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r
//std::cout << "InputComponent::InputComponent - data" << std::endl;
//std::cout << "InputComponent::InputComponent - window: " << windowWidth << "x" << windowHeight << " passed " << passedWindowWidth << "x" << passedWindowHeight << std::endl;
boundToPage
=
true
;
//boundToPage = true;
useBoxShader
=
true
;
// set up state
windowWidth
=
passedWindowWidth
;
...
...
@@ -21,6 +22,9 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r
// ugh
x
=
rawX
;
y
=
rawY
;
lastRenderedWindowHeight
=
windowHeight
;
//std::cout << "InputComponent::InputComponent - placing box at " << (int)x << "," << (int)y << " size: " << (int)width << "x" << (int)height << std::endl;
// copy initial state
initialX
=
x
;
...
...
@@ -47,7 +51,7 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r
distanceToViewport
(
vWidth
,
vHeight
);
//std::cout << "vWidth after: " << (int)vWidth << std::endl;
//std::cout << "placing box at GL " <<
(int)
vx << "
x" << (int)vy << " size: " << (int)(vWidth*10000)
<< "x" <<
(int)(
vHeight
*10000)
<< std::endl;
//std::cout << "
InputComponent::InputComponent -
placing box at GL " << vx << "
," << vy << " to " << vx+vWidth << "," << vy+vHeight << " size: " << vWidth
<< "x" << vHeight << std::endl;
vertices
[(
0
*
5
)
+
0
]
=
vx
;
vertices
[(
0
*
5
)
+
1
]
=
vy
+
vHeight
;
...
...
@@ -130,6 +134,8 @@ void InputComponent::render() {
}
}
// this doesn't seem to work
// text is fine though
void
InputComponent
::
resize
(
const
int
passedWindowWidth
,
const
int
passedWindowHeight
)
{
//std::cout << "InputComponent::resize" << std::endl;
//std::cout << "InputComponent::resize - rasterizing at " << (int)x << "x" << (int)y << " size: " << (int)width << "x" << (int)height << std::endl;
...
...
@@ -138,19 +144,31 @@ void InputComponent::resize(const int passedWindowWidth, const int passedWindowH
// set up state
windowWidth
=
passedWindowWidth
;
windowHeight
=
passedWindowHeight
;
if
(
!
boundToPage
)
{
// ok because box shader is anchored to the bottom of the screen
// if we resize Y (increase height), we need to rebind
int
yDiff
=
windowHeight
-
lastRenderedWindowHeight
;
//std::cout << "InputComponent::resize - Adjusting y: " << y << " by " << yDiff << std::endl;
this
->
y
+=
yDiff
;
lastRenderedWindowHeight
=
windowHeight
;
}
// turning this off breaks coordinates
boundToPage
=
false
;
//boundToPage = true;
useBoxShader
=
true
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
data
[
0
][
0
][
i
]
=
0xf0
;
// set RGB color
}
data
[
0
][
0
][
3
]
=
0xff
;
// set alpha
//std::cout << "InputComponent::resize - placing box at " << (int)x << "," << (int)y << " size: " << (int)width << "x" << (int)height << std::endl;
float
vx
=
x
;
float
vy
=
y
;
float
vx1
=
x
+
width
;
float
vy1
=
y
-
height
;
//
float vx1 = x + width;
//
float vy1 = y - height;
/*
std::cout << "placing box at " << (int)vx << "," << (int)vy << " size: " << (int)width << "x" << (int)height << " v1: " << (int)vx1 << "," << (int)vy1 << std::endl;
//float vWidth = width;
...
...
@@ -165,10 +183,19 @@ void InputComponent::resize(const int passedWindowWidth, const int passedWindowH
vx1 = x + width;
vy1 = y - height;
boundToPage = false;
*/
*/
pointToViewport
(
vx
,
vy
);
pointToViewport
(
vx1
,
vy1
);
//pointToViewport(vx1, vy1);
float
vWidth
=
width
;
float
vHeight
=
height
;
distanceToViewport
(
vWidth
,
vHeight
);
float
vx1
=
vx
+
vWidth
;
float
vy1
=
vy
+
vHeight
;
//std::cout << "FALSE placing box at GL v: " << vx << "," << vy << " v1: " << vx1 << "," << vy1 << std::endl;
//std::cout << "InputComponent::resize - placing box at GL " << vx << "," << vy << " to " << vx1 << "," << vy1 << " size: " << vWidth << "x" << vHeight << std::endl;
// converts 512 to 1 and 1 to 2
//std::cout << "vWidth before: " << (int)vWidth << std::endl;
...
...
@@ -193,13 +220,16 @@ void InputComponent::resize(const int passedWindowWidth, const int passedWindowH
glBindBuffer
(
GL_ARRAY_BUFFER
,
vertexBufferObject
);
glBufferData
(
GL_ARRAY_BUFFER
,
sizeof
(
vertices
),
vertices
,
GL_STATIC_DRAW
);
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
elementBufferObject
);
glBufferData
(
GL_ELEMENT_ARRAY_BUFFER
,
sizeof
(
indices
),
indices
,
GL_STATIC_DRAW
);
//
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBufferObject);
//
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
glBindVertexArray
(
0
);
// protect what we created against any further modification
//updateText();
if
(
userInputText
)
{
userInputText
->
resize
(
passedWindowWidth
,
passedWindowHeight
);
}
}
void
InputComponent
::
addChar
(
char
c
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment