mirror of
https://github.com/bradgrantham/apple2e.git
synced 2024-09-28 17:55:19 +00:00
separate out opengl_texture
This commit is contained in:
parent
bb30c33d2d
commit
f2b28839e4
15
glwidget.cpp
15
glwidget.cpp
@ -126,3 +126,18 @@ bool CheckProgramLink(GLuint program)
|
||||
return false;
|
||||
}
|
||||
|
||||
opengl_texture initialize_texture(int w, int h, unsigned char *pixels)
|
||||
{
|
||||
GLuint tex;
|
||||
|
||||
glGenTextures(1, &tex);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
CheckOpenGL(__FILE__, __LINE__);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, pixels);
|
||||
CheckOpenGL(__FILE__, __LINE__);
|
||||
return {w, h, tex};
|
||||
}
|
||||
|
||||
|
10
glwidget.h
10
glwidget.h
@ -90,4 +90,14 @@ struct render_target
|
||||
}
|
||||
};
|
||||
|
||||
struct opengl_texture
|
||||
{
|
||||
int w;
|
||||
int h;
|
||||
GLuint t;
|
||||
operator GLuint() const { return t; }
|
||||
};
|
||||
|
||||
opengl_texture initialize_texture(int w, int h, unsigned char *pixels = NULL);
|
||||
|
||||
#endif /* __GLWIDGET_H__ */
|
||||
|
@ -90,29 +90,6 @@ event dequeue_event()
|
||||
return {NONE, 0};
|
||||
}
|
||||
|
||||
struct opengl_texture
|
||||
{
|
||||
int w;
|
||||
int h;
|
||||
GLuint t;
|
||||
operator GLuint() const { return t; }
|
||||
};
|
||||
|
||||
opengl_texture initialize_texture(int w, int h, unsigned char *pixels = NULL)
|
||||
{
|
||||
GLuint tex;
|
||||
|
||||
glGenTextures(1, &tex);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
CheckOpenGL(__FILE__, __LINE__);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, pixels);
|
||||
CheckOpenGL(__FILE__, __LINE__);
|
||||
return {w, h, tex};
|
||||
}
|
||||
|
||||
opengl_texture font_texture;
|
||||
const int fonttexture_w = 7;
|
||||
const int fonttexture_h = 8 * 96;
|
||||
|
Loading…
Reference in New Issue
Block a user