|
@@ -13,8 +13,9 @@
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "pandaFramework.h"
|
|
#include "pandaFramework.h"
|
|
|
-#include "geomQuad.h"
|
|
|
|
|
-#include "textureAttrib.h"
|
|
|
|
|
|
|
+#include "cardMaker.h"
|
|
|
|
|
+#include "texture.h"
|
|
|
|
|
+#include "pnmImage.h"
|
|
|
#include "cmath.h"
|
|
#include "cmath.h"
|
|
|
#include "mathNumbers.h"
|
|
#include "mathNumbers.h"
|
|
|
|
|
|
|
@@ -22,12 +23,10 @@ NodePath bogus_scene;
|
|
|
NodePath old_bogus_scene;
|
|
NodePath old_bogus_scene;
|
|
|
|
|
|
|
|
void
|
|
void
|
|
|
-event_T(CPT_Event, void *data) {
|
|
|
|
|
|
|
+event_T(const Event *, void *data) {
|
|
|
PandaFramework *framework = (PandaFramework *)data;
|
|
PandaFramework *framework = (PandaFramework *)data;
|
|
|
WindowFramework *wf = framework->get_window(0);
|
|
WindowFramework *wf = framework->get_window(0);
|
|
|
|
|
|
|
|
- GraphicsStateGuardian *gsg = wf->get_graphics_window()->get_gsg();
|
|
|
|
|
- Camera *camera = wf->get_camera(0);
|
|
|
|
|
NodePath models = framework->get_models();
|
|
NodePath models = framework->get_models();
|
|
|
NodePath render = wf->get_render();
|
|
NodePath render = wf->get_render();
|
|
|
|
|
|
|
@@ -54,14 +53,9 @@ event_T(CPT_Event, void *data) {
|
|
|
cerr << "Loading " << num_quads_side * num_quads_side << " textures at "
|
|
cerr << "Loading " << num_quads_side * num_quads_side << " textures at "
|
|
|
<< tex_x_size << ", " << tex_y_size << "\n";
|
|
<< tex_x_size << ", " << tex_y_size << "\n";
|
|
|
|
|
|
|
|
- GeomNode *gnode = new GeomNode("quads");
|
|
|
|
|
- bogus_scene.attach_new_node(gnode);
|
|
|
|
|
-
|
|
|
|
|
PNMImage white_center(tex_x_size / 4, tex_y_size / 4);
|
|
PNMImage white_center(tex_x_size / 4, tex_y_size / 4);
|
|
|
white_center.fill(1.0f, 1.0f, 1.0f);
|
|
white_center.fill(1.0f, 1.0f, 1.0f);
|
|
|
|
|
|
|
|
- PTA_Colorf colors;
|
|
|
|
|
- colors.push_back(Colorf(1.0f, 1.0f, 1.0f, 1.0f));
|
|
|
|
|
for (int yi = 0; yi < num_quads_side; yi++) {
|
|
for (int yi = 0; yi < num_quads_side; yi++) {
|
|
|
float y0 = (float)yi / (float)num_quads_side;
|
|
float y0 = (float)yi / (float)num_quads_side;
|
|
|
float y1 = (float)(yi + 1) / (float)num_quads_side;
|
|
float y1 = (float)(yi + 1) / (float)num_quads_side;
|
|
@@ -90,23 +84,13 @@ event_T(CPT_Event, void *data) {
|
|
|
tex->set_minfilter(Texture::FT_linear_mipmap_linear);
|
|
tex->set_minfilter(Texture::FT_linear_mipmap_linear);
|
|
|
tex->load(bogus_image);
|
|
tex->load(bogus_image);
|
|
|
|
|
|
|
|
- PTA_Vertexf coords;
|
|
|
|
|
- PTA_TexCoordf uvs;
|
|
|
|
|
- coords.push_back(Vertexf(hx0 * px0, hy0 * px0, py0));
|
|
|
|
|
- coords.push_back(Vertexf(hx1 * px0, hy1 * px0, py0));
|
|
|
|
|
- coords.push_back(Vertexf(hx1 * px1, hy1 * px1, py1));
|
|
|
|
|
- coords.push_back(Vertexf(hx0 * px1, hy0 * px1, py1));
|
|
|
|
|
- uvs.push_back(TexCoordf(0.0f, 0.0f));
|
|
|
|
|
- uvs.push_back(TexCoordf(1.0f, 0.0f));
|
|
|
|
|
- uvs.push_back(TexCoordf(1.0f, 1.0f));
|
|
|
|
|
- uvs.push_back(TexCoordf(0.0f, 1.0f));
|
|
|
|
|
-
|
|
|
|
|
- PT(GeomQuad) quad = new GeomQuad;
|
|
|
|
|
- quad->set_coords(coords);
|
|
|
|
|
- quad->set_colors(colors, G_OVERALL);
|
|
|
|
|
- quad->set_num_prims(1);
|
|
|
|
|
- quad->set_texcoords(uvs, G_PER_VERTEX);
|
|
|
|
|
- gnode->add_geom(quad, RenderState::make(TextureAttrib::make(tex)));
|
|
|
|
|
|
|
+ CardMaker cm("card");
|
|
|
|
|
+ cm.set_frame(Vertexf(hx0 * px0, hy0 * px0, py0),
|
|
|
|
|
+ Vertexf(hx1 * px0, hy1 * px0, py0),
|
|
|
|
|
+ Vertexf(hx1 * px1, hy1 * px1, py1),
|
|
|
|
|
+ Vertexf(hx0 * px1, hy0 * px1, py1));
|
|
|
|
|
+ NodePath card = bogus_scene.attach_new_node(cm.generate());
|
|
|
|
|
+ card.set_texture(tex);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
cerr << "Done.\n";
|
|
cerr << "Done.\n";
|
|
@@ -134,7 +118,7 @@ main(int argc, char *argv[]) {
|
|
|
window->loop_animations();
|
|
window->loop_animations();
|
|
|
|
|
|
|
|
framework.enable_default_keys();
|
|
framework.enable_default_keys();
|
|
|
- framework.get_event_handler().add_hook("shift-t", event_T, &framework);
|
|
|
|
|
|
|
+ framework.define_key("shift-t", "test texture memory", event_T, &framework);
|
|
|
framework.main_loop();
|
|
framework.main_loop();
|
|
|
}
|
|
}
|
|
|
|
|
|