Skip to content

Commit

Permalink
Postprocess works, FB resizing, mouse acceleration
Browse files Browse the repository at this point in the history
- client
  * postprocessing & offscreen rendering fixed for NaCl
  * framebuffer resizing
  * Windows switches to configured width and height when toggling fullscreen
  * mouse acceleration/decceleration implemented again, only enabled in
    fullscreen mode on X11
  • Loading branch information
ducakar committed Jul 4, 2012
1 parent ea94f3b commit 35814a6
Show file tree
Hide file tree
Showing 29 changed files with 405 additions and 374 deletions.
6 changes: 3 additions & 3 deletions data/ozbase/glsl/postprocess.frag
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void main()
vec4 sample = texture2D( oz_Textures[0], exTexCoord );
float luminance = clamp( ( multiSample.r + multiSample.g + multiSample.b ) * LUMINANCE_FACTOR, 0.0, 1.0 );

// vec4 blurred = mix( sample, blur, 0 );
// gl_FragColor = mix( blurred, bloom, luminance );
gl_FragColor = vec4( 1.0 );
vec4 blurred = mix( sample, blur, 0.5 );
gl_FragColor = mix( blurred, bloom, luminance );
// gl_FragColor = mix( sample, bloom, luminance );
}
2 changes: 1 addition & 1 deletion src/build/Build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ void Build::packArchive( const char* name, bool useCompression, bool use7zip )

if( size >= 0 ) {
Log::println();
Log::println( "Archive size: %.1f MiB = %.1f MB",
Log::println( "Archive size: %.2f MiB = %.2f MB",
float( size ) / ( 1024.0f * 1024.0f ),
float( size ) / ( 1000.0f * 1000.0f ) );
}
Expand Down
2 changes: 1 addition & 1 deletion src/build/Compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void Compiler::blend( bool doBlend )
hard_assert( flags & MESH_BIT );
hard_assert( !( flags & PART_BIT ) );

part.material = doBlend ? Mesh::ALPHA_BIT : Mesh::SOLID_BIT;
part.material = doBlend ? int( Mesh::ALPHA_BIT ) : int( Mesh::SOLID_BIT );
}

void Compiler::texture( const char* texture )
Expand Down
2 changes: 2 additions & 0 deletions src/client/Camera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ void Camera::prepare()
{
updateReferences();

ui::mouse.update();

bool alt = ( input.keys[SDLK_LALT] | input.keys[SDLK_RALT] ) != 0;

relH = float( -ui::mouse.overEdgeX ) * mouseXSens * mag;
Expand Down
164 changes: 83 additions & 81 deletions src/client/DMesh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,87 @@ DMesh::DMesh() :
positionsTexId( 0 ), normalsTexId( 0 ), vertices( null ), positions( null ), normals( null )
{}

void DMesh::drawFrame( int mask, int frame ) const
{
if( shader.hasVertexTexture ) {
glActiveTexture( GL_TEXTURE3 );
glBindTexture( GL_TEXTURE_2D, positionsTexId );
glActiveTexture( GL_TEXTURE4 );
glBindTexture( GL_TEXTURE_2D, normalsTexId );
}
else {
const Point* framePositions = &positions[frame * nFramePositions];
const Vec3* frameNormals = &normals[frame * nFramePositions];

for( int i = 0; i < nFrameVertices; ++i ) {
int j = int( vertices[i].pos[0] * float( nFramePositions - 1 ) + 0.5f );

Point pos = framePositions[j];
Vec3 normal = frameNormals[j];

vertexAnimBuffer[i].pos[0] = pos.x;
vertexAnimBuffer[i].pos[1] = pos.y;
vertexAnimBuffer[i].pos[2] = pos.z;

vertexAnimBuffer[i].texCoord[0] = vertices[i].texCoord[0];
vertexAnimBuffer[i].texCoord[1] = vertices[i].texCoord[1];

vertexAnimBuffer[i].normal[0] = quantifyToByte( normal.x );
vertexAnimBuffer[i].normal[1] = quantifyToByte( normal.y );
vertexAnimBuffer[i].normal[2] = quantifyToByte( normal.z );
}

Mesh::upload( vertexAnimBuffer, nFrameVertices, GL_STREAM_DRAW );
}

glUniform3f( param.oz_MeshAnimation, float( frame ) / float( nFrames ), 0.0f, 0.0f );

Mesh::draw( mask );
}

void DMesh::drawAnim( int mask, int firstFrame, int secondFrame, float interpolation ) const
{
if( shader.hasVertexTexture ) {
glActiveTexture( GL_TEXTURE3 );
glBindTexture( GL_TEXTURE_2D, positionsTexId );
glActiveTexture( GL_TEXTURE4 );
glBindTexture( GL_TEXTURE_2D, normalsTexId );

glUniform3f( param.oz_MeshAnimation,
float( firstFrame ) / float( nFrames ),
float( secondFrame ) / float( nFrames ),
interpolation );
}
else {
const Point* currFramePositions = &positions[firstFrame * nFramePositions];
const Point* nextFramePositions = &positions[secondFrame * nFramePositions];
const Vec3* currFrameNormals = &normals[firstFrame * nFramePositions];
const Vec3* nextFrameNormals = &normals[secondFrame * nFramePositions];

for( int i = 0; i < nFrameVertices; ++i ) {
int j = int( vertices[i].pos[0] * float( nFramePositions - 1 ) + 0.5f );

Point pos = Math::mix( currFramePositions[j], nextFramePositions[j], interpolation );
Vec3 normal = Math::mix( currFrameNormals[j], nextFrameNormals[j], interpolation );

vertexAnimBuffer[i].pos[0] = pos.x;
vertexAnimBuffer[i].pos[1] = pos.y;
vertexAnimBuffer[i].pos[2] = pos.z;

vertexAnimBuffer[i].texCoord[0] = vertices[i].texCoord[0];
vertexAnimBuffer[i].texCoord[1] = vertices[i].texCoord[1];

vertexAnimBuffer[i].normal[0] = quantifyToByte( normal.x );
vertexAnimBuffer[i].normal[1] = quantifyToByte( normal.y );
vertexAnimBuffer[i].normal[2] = quantifyToByte( normal.z );
}

Mesh::upload( vertexAnimBuffer, nFrameVertices, GL_STREAM_DRAW );
}

Mesh::draw( mask );
}

void DMesh::load( InputStream* istream, const char* path )
{
if( shader.hasVertexTexture ) {
Expand Down Expand Up @@ -107,6 +188,8 @@ void DMesh::load( InputStream* istream, const char* path )
vertexAnimBufferLength = nFrameVertices;
}
}

OZ_GL_CHECK_ERROR();
}

void DMesh::unload()
Expand All @@ -126,87 +209,6 @@ void DMesh::unload()
}
}

void DMesh::drawFrame( int mask, int frame ) const
{
if( shader.hasVertexTexture ) {
glActiveTexture( GL_TEXTURE3 );
glBindTexture( GL_TEXTURE_2D, positionsTexId );
glActiveTexture( GL_TEXTURE4 );
glBindTexture( GL_TEXTURE_2D, normalsTexId );
}
else {
const Point* framePositions = &positions[frame * nFramePositions];
const Vec3* frameNormals = &normals[frame * nFramePositions];

for( int i = 0; i < nFrameVertices; ++i ) {
int j = int( vertices[i].pos[0] * float( nFramePositions - 1 ) + 0.5f );

Point pos = framePositions[j];
Vec3 normal = frameNormals[j];

vertexAnimBuffer[i].pos[0] = pos.x;
vertexAnimBuffer[i].pos[1] = pos.y;
vertexAnimBuffer[i].pos[2] = pos.z;

vertexAnimBuffer[i].texCoord[0] = vertices[i].texCoord[0];
vertexAnimBuffer[i].texCoord[1] = vertices[i].texCoord[1];

vertexAnimBuffer[i].normal[0] = quantifyToByte( normal.x );
vertexAnimBuffer[i].normal[1] = quantifyToByte( normal.y );
vertexAnimBuffer[i].normal[2] = quantifyToByte( normal.z );
}

Mesh::upload( vertexAnimBuffer, nFrameVertices, GL_STREAM_DRAW );
}

glUniform3f( param.oz_MeshAnimation, float( frame ) / float( nFrames ), 0.0f, 0.0f );

Mesh::draw( mask );
}

void DMesh::drawAnim( int mask, int firstFrame, int secondFrame, float interpolation ) const
{
if( shader.hasVertexTexture ) {
glActiveTexture( GL_TEXTURE3 );
glBindTexture( GL_TEXTURE_2D, positionsTexId );
glActiveTexture( GL_TEXTURE4 );
glBindTexture( GL_TEXTURE_2D, normalsTexId );

glUniform3f( param.oz_MeshAnimation,
float( firstFrame ) / float( nFrames ),
float( secondFrame ) / float( nFrames ),
interpolation );
}
else {
const Point* currFramePositions = &positions[firstFrame * nFramePositions];
const Point* nextFramePositions = &positions[secondFrame * nFramePositions];
const Vec3* currFrameNormals = &normals[firstFrame * nFramePositions];
const Vec3* nextFrameNormals = &normals[secondFrame * nFramePositions];

for( int i = 0; i < nFrameVertices; ++i ) {
int j = int( vertices[i].pos[0] * float( nFramePositions - 1 ) + 0.5f );

Point pos = Math::mix( currFramePositions[j], nextFramePositions[j], interpolation );
Vec3 normal = Math::mix( currFrameNormals[j], nextFrameNormals[j], interpolation );

vertexAnimBuffer[i].pos[0] = pos.x;
vertexAnimBuffer[i].pos[1] = pos.y;
vertexAnimBuffer[i].pos[2] = pos.z;

vertexAnimBuffer[i].texCoord[0] = vertices[i].texCoord[0];
vertexAnimBuffer[i].texCoord[1] = vertices[i].texCoord[1];

vertexAnimBuffer[i].normal[0] = quantifyToByte( normal.x );
vertexAnimBuffer[i].normal[1] = quantifyToByte( normal.y );
vertexAnimBuffer[i].normal[2] = quantifyToByte( normal.z );
}

Mesh::upload( vertexAnimBuffer, nFrameVertices, GL_STREAM_DRAW );
}

Mesh::draw( mask );
}

void DMesh::free()
{
delete[] vertexAnimBuffer;
Expand Down
6 changes: 3 additions & 3 deletions src/client/DMesh.hh
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ class DMesh : public Mesh

DMesh();

void load( InputStream* istream, const char* path );
void unload();

void drawFrame( int mask, int frame ) const;
void drawAnim( int mask, int firstFrame, int secondFrame, float interpolation ) const;

void load( InputStream* istream, const char* path );
void unload();

static void free();

};
Expand Down
4 changes: 2 additions & 2 deletions src/client/GameStage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void GameStage::reload()

loader.load();

ui::ui.prepare();
// ui::ui.prepare();
ui::ui.showLoadingScreen( false );

Log::unindent();
Expand Down Expand Up @@ -448,7 +448,7 @@ void GameStage::load()

loader.load();

ui::ui.prepare();
// ui::ui.prepare();
ui::ui.showLoadingScreen( false );

loadingMicros = Time::uclock() - loadingMicros;
Expand Down
15 changes: 15 additions & 0 deletions src/client/Input.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "client/Input.hh"

#include "client/Window.hh"
#include "client/NaCl.hh"

namespace oz
{
Expand Down Expand Up @@ -115,6 +116,14 @@ void Input::update()
mouseX = +inputX;
mouseY = -inputY;

int clickedButtons = input.buttons & ~input.oldButtons;

leftClick = clickedButtons & Input::LEFT_BUTTON;
middleClick = clickedButtons & Input::MIDDLE_BUTTON;
rightClick = clickedButtons & Input::RIGHT_BUTTON;
wheelUp = input.mouseW > 0;
wheelDown = input.mouseW < 0;

// If input is not grabbed we must centre mouse so it cannot move out of the window.
if( isLocked ) {
reset();
Expand All @@ -132,6 +141,12 @@ void Input::init()
oldButtons = 0;
currButtons = 0;

leftClick = false;
middleClick = false;
rightClick = false;
wheelUp = false;
wheelDown = false;

hasFocus = true;
isLocked = true;

Expand Down
6 changes: 6 additions & 0 deletions src/client/Input.hh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ class Input
char oldButtons;
char currButtons;

bool leftClick;
bool rightClick;
bool middleClick;
bool wheelUp;
bool wheelDown;

bool hasFocus;
bool isLocked;

Expand Down
Loading

0 comments on commit 35814a6

Please sign in to comment.