Skip to content

Commit

Permalink
Merge pull request #442 from tribal-tec/master
Browse files Browse the repository at this point in the history
Close #439: Fix MSVC build
  • Loading branch information
tribal-tec committed May 12, 2015
2 parents 684fe31 + 7469d75 commit a156cb9
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 16 deletions.
16 changes: 9 additions & 7 deletions eq/client/compositor.cpp
Expand Up @@ -1323,12 +1323,12 @@ void Compositor::_drawPixelsGLSL( const Image* image, const ImageOp& op,
bool Compositor::_setupDrawPixels( const Image* image, const ImageOp& op,
const Frame::Buffer which )
{
Channel* channel = op.channel; // needed for glewGetContext
const PixelViewport& pvp = image->getPixelViewport();
const util::Texture* texture = 0;
if( image->getStorageType() == Frame::TYPE_MEMORY )
{
LBASSERT( image->hasPixelData( which ));
Channel* channel = op.channel; // needed for glewGetContext
util::ObjectManager& objects = channel->getObjectManager();

const bool coreProfile = channel->getWindow()->getIAttribute(
Expand Down Expand Up @@ -1381,7 +1381,8 @@ void Compositor::_drawTexturedQuad( const T* key, const ImageOp& op,
const PixelViewport& pvp,
const bool withDepth )
{
util::ObjectManager& om = op.channel->getObjectManager();
Channel* channel = op.channel; // needed for glewGetContext
util::ObjectManager& om = channel->getObjectManager();
GLuint program = om.getProgram( key );
GLuint vertexArray = om.getVertexArray( key );
GLuint vertexBuffer = om.getBuffer( key );
Expand Down Expand Up @@ -1427,7 +1428,8 @@ void Compositor::_drawTexturedQuad( const T* key, const ImageOp& op,
"}\n"
};

LBCHECK( util::shader::linkProgram( program, vertexShaderGLSL,
LBCHECK( util::shader::linkProgram( glewGetContext(), program,
vertexShaderGLSL,
fragmentShaderGLSL ));

EQ_GL_CALL( glUseProgram( program ));
Expand Down Expand Up @@ -1457,10 +1459,10 @@ void Compositor::_drawTexturedQuad( const T* key, const ImageOp& op,
};

eq::Frustumf frustum;
frustum.left() = op.channel->getPixelViewport().x;
frustum.right() = op.channel->getPixelViewport().getXEnd();
frustum.bottom() = op.channel->getPixelViewport().y;
frustum.top() = op.channel->getPixelViewport().getYEnd();
frustum.left() = channel->getPixelViewport().x;
frustum.right() = channel->getPixelViewport().getXEnd();
frustum.bottom() = channel->getPixelViewport().y;
frustum.top() = channel->getPixelViewport().getYEnd();
frustum.far_plane() = 1.0f;
frustum.near_plane() = -1.0f;
const eq::Matrix4f& proj = frustum.compute_ortho_matrix();
Expand Down
2 changes: 1 addition & 1 deletion eq/client/roiFinder.cpp
Expand Up @@ -601,7 +601,7 @@ void ROIFinder::_readbackInfo( util::ObjectManager& glObjects )
#else
const GLchar* fShaderPtr = roiFragmentShaderRGB_glsl.c_str();
#endif
LBCHECK( util::shader::compile( shader, fShaderPtr ));
LBCHECK( util::shader::compile( glewGetContext(), shader, fShaderPtr ));
program = glObjects.newProgram( shaderRBInfo );

EQ_GL_CALL( glAttachShader( program, shader ));
Expand Down
6 changes: 6 additions & 0 deletions eq/server/config/resources.cpp
Expand Up @@ -55,6 +55,12 @@
# include <hwsd/net/dns_sd/module.h>
#endif

#ifdef _MSC_VER
# include <eq/client/os.h>
# define setenv( name, value, overwrite ) \
SetEnvironmentVariable( name, value )
#endif

#define USE_IPv4

namespace eq
Expand Down
13 changes: 9 additions & 4 deletions eq/util/shader.cpp
Expand Up @@ -21,14 +21,18 @@
#include <eq/client/gl.h>
#include <lunchbox/log.h>

#undef glewGetContext
#define glewGetContext() glewContext

namespace eq
{
namespace util
{
namespace shader
{

bool compile( const unsigned shader, const char* source )
bool compile( const GLEWContext* glewContext LB_UNUSED, const unsigned shader,
const char* source )
{
EQ_GL_CALL( glShaderSource( shader, 1, &source, 0 ));
EQ_GL_CALL( glCompileShader( shader ));
Expand All @@ -45,7 +49,8 @@ bool compile( const unsigned shader, const char* source )
return true;
}

bool linkProgram( const unsigned program, const char* vertexShaderSource,
bool linkProgram( const GLEWContext* glewContext LB_UNUSED,
const unsigned program, const char* vertexShaderSource,
const char* fragmentShaderSource )
{
if( !program || !vertexShaderSource || !fragmentShaderSource )
Expand All @@ -56,14 +61,14 @@ bool linkProgram( const unsigned program, const char* vertexShaderSource,
}

const GLuint vertexShader = glCreateShader( GL_VERTEX_SHADER );
if( !compile( vertexShader, vertexShaderSource ))
if( !compile( glewContext, vertexShader, vertexShaderSource ))
{
EQ_GL_CALL( glDeleteShader( vertexShader ));
return false;
}

const GLuint fragmentShader = glCreateShader( GL_FRAGMENT_SHADER );
if( !compile( fragmentShader, fragmentShaderSource ))
if( !compile( glewContext, fragmentShader, fragmentShaderSource ))
{
EQ_GL_CALL( glDeleteShader( fragmentShader ));
return false;
Expand Down
9 changes: 7 additions & 2 deletions eq/util/shader.h
Expand Up @@ -20,6 +20,7 @@
#define EQUTIL_SHADER_H

#include <eq/client/api.h>
#include <eq/client/types.h>

namespace eq
{
Expand All @@ -31,24 +32,28 @@ namespace shader
/**
* Compile a shader object from a GLSL source and print errors if any.
*
* @param glewContext the OpenGL function table.
* @param shader OpenGL shader object
* @param source GLSL formatted shader source
* @return true on successful compilation, false otherwise
* @version 1.9
*/
EQ_API bool compile( const unsigned shader, const char* source );
EQ_API bool compile( const GLEWContext* glewContext,
const unsigned shader, const char* source );

/**
* Link a shader program from a given vertex and fragment GLSL source and print
* errors if any.
*
* @param glewContext the OpenGL function table.
* @param program OpenGL shader program
* @param vertexShaderSource GLSL formatted vertex shader source
* @param fragmentShaderSource GLSL formatted vertex shader source
* @return true on successful linking, false otherwise
* @version 1.9
*/
EQ_API bool linkProgram( const unsigned program, const char* vertexShaderSource,
EQ_API bool linkProgram( const GLEWContext* glewContext,
const unsigned program, const char* vertexShaderSource,
const char* fragmentShaderSource );

}
Expand Down
5 changes: 4 additions & 1 deletion examples/eqHello/hello.cpp
Expand Up @@ -182,8 +182,11 @@ bool eqHello::Renderer::_loadShaders()
return true;

_program = om.newProgram( &_program );
if( !seq::linkProgram( _program, vertexShader_glsl, fragmentShader_glsl ))
if( !seq::linkProgram( om.glewGetContext(), _program, vertexShader_glsl,
fragmentShader_glsl ))
{
return false;
}

EQ_GL_CALL( glUseProgram( _program ));
_matrixUniform = glGetUniformLocation( _program, "MVP" );
Expand Down
3 changes: 2 additions & 1 deletion examples/eqPly/vertexBufferState.h
Expand Up @@ -73,7 +73,8 @@ class VertexBufferState : public triply::VertexBufferState
bool linkProgram( const unsigned program, const char* vertexShaderSource,
const char* fragmentShaderSource )
{
return eq::util::shader::linkProgram( program, vertexShaderSource,
return eq::util::shader::linkProgram( _objectManager.glewGetContext(),
program, vertexShaderSource,
fragmentShaderSource );
}

Expand Down

0 comments on commit a156cb9

Please sign in to comment.