FS2_Open
Open source remastering of the Freespace 2 engine
bm_examples.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8  */
9 
15 #include "bmpman/bmpman.h"
16 #include "graphics/2d.h"
17 
19  static int test_inited = 0;
20  static int test_bmp;
21  static uint test_bmp_data[128 * 64];
22 
23  if (!test_inited) {
24  test_inited = 1;
25  // Create the new bitmap and fill in its data.
26  // When you're done with it completely, call
27  // bm_release to free up the bitmap handle
28  test_bmp = bm_create(32, 128, 64, test_bmp_data);
29  int i, j;
30  for (i = 0; i < 64; i++) {
31  for (j = 0; j < 64; j++) {
32  uint r = i * 4;
33  test_bmp_data[j + i * 128] = r;
34  }
35  }
36  }
37 
38  // page out the data, so that the next bm_lock will convert the new data to
39  // the correct bpp
40  bm_unload(test_bmp);
41 
42  // put in new data
43  int x, y;
44  gr_reset_clip();
45  for (y = 0; y < 64; y++) {
46  for (x = 0; x < 128; x++) {
47  test_bmp_data[y * 128 + x] = 15;
48  }
49  }
50 
51  // Draw the bitmap, the upper left corner is the origin (0, 0)
52  gr_set_bitmap(test_bmp);
53  gr_bitmap(0, 0);
54 }
int i
Definition: multi_pxo.cpp:466
void gr_set_bitmap(int bitmap_num, int alphablend_mode, int bitblt_mode, float alpha)
Definition: 2d.cpp:2105
#define gr_reset_clip
Definition: 2d.h:745
GLdouble GLdouble GLdouble r
Definition: Glext.h:5337
unsigned int uint
Definition: pstypes.h:64
GLint GLint GLint GLint GLint x
Definition: Glext.h:5182
int bm_create(int bpp, int w, int h, void *data, int flags)
Definition: bmpman.cpp:469
void gr_bitmap(int _x, int _y, int resize_mode)
Definition: 2d.cpp:1303
void bm_create_example()
Definition: bm_examples.cpp:18
int bm_unload(int handle, int clear_render_targets, bool nodebug)
Unloads a bitmap's data, but not the bitmap info.
Definition: bmpman.cpp:2890
GLint y
Definition: Gl.h:1505