Skip to content
Snippets Groups Projects
Commit c71156cd authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

tweak

parent f52ba225
No related branches found
No related tags found
No related merge requests found
......@@ -52,7 +52,7 @@ GLuint gmshPopplerWrapper::getTextureForPage(double xres,
poppler::image im = pr.render_page(_current_page, xres, yres, -1, -1, -1);
_w = im.width();
_h = im.height();
// im.save("page.png","png");
// im.save("page.png","png");
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
......
......@@ -95,21 +95,21 @@ class drawContextFltkCairo::queueString {
glScalef (2.0f / winw, 2.0f / winh, 1.0f);
glTranslatef (-winw / 2.0f, -winh / 2.0f, 0.0f);
//write the texture on screen
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glEnable(GL_TEXTURE_RECTANGLE_ARB);
glPushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT | GL_COLOR_BUFFER_BIT);
glDisable(GL_LIGHTING);
glDisable (GL_DEPTH_TEST);
glEnable (GL_BLEND);
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glGenTextures (1, &textureId);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, textureId);
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_ALPHA,
cairo_image_surface_get_width(surface),
cairo_image_surface_get_height(surface), 0,
GL_ALPHA, GL_UNSIGNED_BYTE, cairo_image_surface_get_data(surface));
glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, textureId);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_ALPHA,
cairo_image_surface_get_width(surface),
cairo_image_surface_get_height(surface), 0,
GL_ALPHA, GL_UNSIGNED_BYTE, cairo_image_surface_get_data(surface));
//glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_SRC0_ALPHA);
//printf("error %i %s\n", __LINE__, gluErrorString(glGetError()));
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
pos = 0;
for(std::vector<element>::iterator it = _elements.begin(); it != _elements.end(); ++it) {
......
......@@ -13,7 +13,7 @@
#endif
class drawContextFltkStringTexture::queueString {
public :
public :
typedef struct {
std::string text;
GLfloat x, y, z;
......@@ -23,17 +23,16 @@ class drawContextFltkStringTexture::queueString {
int height;
} element;
private:
private:
std::vector<element> _elements;
int _totalWidth, _maxHeight;
public:
public:
queueString()
{
_totalWidth = 0;
_maxHeight = 0;
}
void append(const element &elem)
{
if (_totalWidth + elem.width > 1000)
......@@ -42,7 +41,6 @@ class drawContextFltkStringTexture::queueString {
_totalWidth += elem.width;
_maxHeight = std::max(_maxHeight, elem.height);
}
void flush()
{
//1000 should be _totalWidth but it does not work
......@@ -68,28 +66,28 @@ class drawContextFltkStringTexture::queueString {
//setup matrices
GLint matrixMode;
GLuint textureId;
glGetIntegerv (GL_MATRIX_MODE, &matrixMode);
glMatrixMode (GL_PROJECTION);
glGetIntegerv(GL_MATRIX_MODE, &matrixMode);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity ();
glMatrixMode (GL_MODELVIEW);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity ();
float winw = Fl_Window::current()->w();
float winh = Fl_Window::current()->h();
glScalef (2.0f / winw, 2.0f / winh, 1.0f);
glTranslatef (-winw / 2.0f, -winh / 2.0f, 0.0f);
glScalef(2.0f / winw, 2.0f / winh, 1.0f);
glTranslatef(-winw / 2.0f, -winh / 2.0f, 0.0f);
//write the texture on screen
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glEnable(GL_TEXTURE_RECTANGLE_ARB);
glPushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT | GL_COLOR_BUFFER_BIT);
glDisable(GL_LIGHTING);
glDisable (GL_DEPTH_TEST);
glEnable (GL_BLEND);
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glGenTextures (1, &textureId);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, textureId);
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_ALPHA, w, h, 0,
GL_ALPHA, GL_UNSIGNED_BYTE, data);
glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, textureId);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_ALPHA, w, h, 0,
GL_ALPHA, GL_UNSIGNED_BYTE, data);
//glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_SRC0_ALPHA);
//printf("error %i %s\n", __LINE__, gluErrorString(glGetError()));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
......@@ -100,7 +98,6 @@ class drawContextFltkStringTexture::queueString {
glColor4f(it->r, it->g, it->b, it->alpha);
int Lx = it->width;
int Ly = it->height;
glBegin (GL_QUADS);
glTexCoord2f(pos, 0);
glVertex2f(0.0f, Ly);
......@@ -110,7 +107,7 @@ class drawContextFltkStringTexture::queueString {
glVertex2f(Lx, 0.0f);
glTexCoord2f(pos, Ly);
glVertex2f(0.0f, 0.0f);
glEnd ();
glEnd();
pos += Lx;
glTranslatef(-it->x, -it->y, -it->z);
}
......@@ -122,7 +119,7 @@ class drawContextFltkStringTexture::queueString {
glPopMatrix(); // GL_MODELVIEW
glMatrixMode (GL_PROJECTION);
glPopMatrix();
glMatrixMode (matrixMode);
glMatrixMode(matrixMode);
_elements.clear();
_maxHeight = 0;
_totalWidth = 0;
......@@ -162,4 +159,3 @@ void drawContextFltkStringTexture::setFont(int fontid, int fontsize)
_currentFontId = fontid;
_currentFontSize = fontsize;
}
......@@ -21,6 +21,7 @@
#include "gl2ps.h"
#if defined(HAVE_FLTK)
#include <FL/Fl.h>
#include <FL/Fl_JPEG_Image.H>
#include <FL/Fl_PNG_Image.H>
#include <FL/gl.h>
......@@ -380,7 +381,7 @@ void drawContext::drawBackgroundImage(bool threeD)
return;
}
}
_bgImageTexture = gmshPopplerWrapper::getTextureForPage(800, 600);
_bgImageTexture = gmshPopplerWrapper::getTextureForPage(1024, 1024);
_bgImageW = gmshPopplerWrapper::width();
_bgImageH = gmshPopplerWrapper::height();
#endif
......@@ -394,15 +395,18 @@ void drawContext::drawBackgroundImage(bool threeD)
else if(ext == ".png" || ext == ".PNG")
img = new Fl_PNG_Image(name.c_str());
if(img){
Fl_RGB_Image *img2 = (Fl_RGB_Image*)img->copy(1024, 1024);
glGenTextures(1, &_bgImageTexture);
glBindTexture(GL_TEXTURE_2D, _bgImageTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img->w(), img->h(), 0,
GL_RGB, GL_UNSIGNED_BYTE, img->array);
_bgImageW = img->w();
_bgImageH = img->h();
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img2->w(), img2->h(), 0,
(img2->d() == 4) ? GL_RGBA : GL_RGB,
GL_UNSIGNED_BYTE, img2->array);
_bgImageW = img2->w();
_bgImageH = img2->h();
delete img;
delete img2;
}
else{
Msg::Error("Could not load background image '%s'", name.c_str());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment