本文整理汇总了C++中CL_GraphicContext::get_height方法的典型用法代码示例。如果您正苦于以下问题:C++ CL_GraphicContext::get_height方法的具体用法?C++ CL_GraphicContext::get_height怎么用?C++ CL_GraphicContext::get_height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CL_GraphicContext
的用法示例。
在下文中一共展示了CL_GraphicContext::get_height方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_cur_y
void TileMap::set_cur_y(CL_GraphicContext& gc, int y) {
if (y < 0)
y = 0;
else if (get_height() - y < gc.get_height())
y = get_height() - gc.get_height();
cur_map_y = y;
}
示例2: resizeGLScene
//Fonction à appeller à chaque changement de résolution
void Game::resizeGLScene()
{
CL_GraphicContext *gc = CL_Display::get_current_window()->get_gc();
glViewport(0, 0, (GLsizei) gc->get_width(), (GLsizei) gc->get_height());
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (GLfloat) gc->get_width() / (GLfloat) gc->get_height(), 0.1f, 500.f);
glMatrixMode(GL_MODELVIEW);
}
示例3: render
void App::render(CL_GraphicContext &gc)
{
gc.clear(CL_Colorf(0.0f, 0.0f, 0.0f, 1.0f));
scene.gs->image_grid.draw(gc, 420.0f, 120.0f); // Draw a grid in the backgound
gc.set_map_mode(cl_user_projection);
CL_Rect viewport_rect(0, 0, CL_Size(gc.get_width(), gc.get_height()));
gc.set_viewport(viewport_rect);
gc.set_projection(scene.gs->camera_projection);
CL_BufferControl buffer_control;
buffer_control.set_depth_compare_function(cl_comparefunc_lequal);
buffer_control.enable_depth_write(true);
buffer_control.enable_depth_test(true);
buffer_control.enable_stencil_test(false);
buffer_control.enable_color_write(true);
gc.set_buffer_control(buffer_control);
gc.clear_depth(1.0f);
CL_Mat4f modelview_matrix = scene.gs->camera_modelview;
scene.Draw(modelview_matrix, gc);
gc.reset_program_object();
}
示例4: prepareGC
void Viewport::prepareGC(CL_GraphicContext &p_gc) {
p_gc.push_modelview();
if (m_impl->m_attachPoint != NULL) {
// calculate world clip rect
const int stageWidth = Gfx::Stage::getWidth();
const int stageHeight = Gfx::Stage::getHeight();
m_impl->m_worldClipRect.left =
m_impl->m_attachPoint->x - stageWidth / 2 / m_impl->m_scale;
m_impl->m_worldClipRect.top =
m_impl->m_attachPoint->y - stageHeight / 2 / m_impl->m_scale;
m_impl->m_worldClipRect.right =
m_impl->m_worldClipRect.left + stageWidth / m_impl->m_scale;
m_impl->m_worldClipRect.bottom =
m_impl->m_worldClipRect.top + stageHeight / m_impl->m_scale;
}
// apply new scale
const float horizScale = p_gc.get_width() / m_impl->m_worldClipRect.get_width();
const float vertScale = p_gc.get_height() / m_impl->m_worldClipRect.get_height();
p_gc.mult_scale(horizScale, vertScale);
// apply translations
p_gc.mult_translate(-m_impl->m_worldClipRect.left, -m_impl->m_worldClipRect.top);
}
示例5: GSGame
GSLobby::GSLobby(CL_GraphicContext& gc, CL_ResourceManager& resources)
: m_gsgame(new GSGame(gc, resources)){
CL_FontDescription desc;
desc.set_typeface_name("tahoma");
desc.set_height(32);
m_font.reset(new CL_Font_System(gc, desc));
m_xpos = gc.get_width()/2-100;
m_ypos = gc.get_height()/4;
m_playbtn.initialize(gc, resources, "game_lobby/play_btn",
CL_Vec2<float>(m_xpos, m_ypos+100));
m_backbtn.initialize(gc, resources, "game_lobby/back_btn",
CL_Vec2<float>(m_xpos, m_ypos+200));
}
示例6: draw_text
void ExampleText::draw_text(CL_GraphicContext &gc, CL_Texture &texture, CL_Angle angle)
{
gc.set_texture(0, texture);
gc.push_modelview();
gc.mult_translate(gc.get_width()/2.0f, gc.get_height()/2.0f);
gc.mult_rotate(angle, 0.0f, 0.0f, 1.0f);
CL_Draw::texture(gc, CL_Rectf(-300.0f, -300.0f, 300.0f, 300.0f), CL_Colorf(1.0f, 1.0f, 1.0f, 0.7f));
gc.pop_modelview();
gc.reset_texture(0);
}
示例7: render_gaussian_blur
void App::render_gaussian_blur(CL_GraphicContext &gc, float blur_amount, CL_Texture &source_texture, CL_ProgramObject &program_object, float dx, float dy)
{
int sampleCount = 15;
float *sampleWeights = new float[sampleCount];
CL_Vec2f *sampleOffsets = new CL_Vec2f[sampleCount];
sampleWeights[0] = compute_gaussian(0, blur_amount);
sampleOffsets[0] = CL_Vec2f(0.0, 0.0);
float totalWeights = sampleWeights[0];
for (int i = 0; i < sampleCount / 2; i++)
{
float weight = compute_gaussian(i + 1.0f, blur_amount);
sampleWeights[i * 2 + 1] = weight;
sampleWeights[i * 2 + 2] = weight;
totalWeights += weight * 2;
float sampleOffset = i * 2 + 1.5f;
CL_Vec2f delta = CL_Vec2f(dx * sampleOffset, dy * sampleOffset);
sampleOffsets[i * 2 + 1] = delta;
sampleOffsets[i * 2 + 2] = CL_Vec2f(-delta.x, -delta.y);
}
for (int i = 0; i < sampleCount; i++)
{
sampleWeights[i] /= totalWeights;
}
program_object.set_uniform1i("SourceTexture", 0);
program_object.set_uniformfv("SampleOffsets", 2, sampleCount, (float *)sampleOffsets);
program_object.set_uniformfv("SampleWeights", 1, sampleCount, sampleWeights);
gc.set_texture(0, source_texture);
gc.set_program_object(program_object, cl_program_matrix_modelview_projection);
draw_texture(gc, CL_Rectf(0,0,gc.get_width(),gc.get_height()), CL_Colorf::white, CL_Rectf(0.0f, 0.0f, 1.0f, 1.0f));
gc.reset_program_object();
gc.reset_texture(0);
}
示例8: draw
void TileMap::draw(CL_GraphicContext &gc)
{
int screen_width = gc.get_width();
int screen_height = gc.get_height();
int start_tile_x = cl_max(0, current_map_position_x / tile_width);
int start_tile_y = cl_max(0, current_map_position_y / tile_height);
int scrolling_pixel_offset_x = current_map_position_x - start_tile_x * tile_width;
int scrolling_pixel_offset_y = current_map_position_y - start_tile_y * tile_height;
int tiles_on_screen_horizontally = screen_width / tile_width + 1;
int tiles_on_screen_vertically = screen_height / tile_height + 1;
// since we might show half tiles on edges, make sure we display one more tile to fill screen
tiles_on_screen_horizontally++;
tiles_on_screen_vertically++;
// make sure we don't draw more than the level size
if(tiles_on_screen_horizontally + start_tile_x > map_width)
tiles_on_screen_horizontally = map_width - start_tile_x;
if(tiles_on_screen_vertically + start_tile_y > map_height)
tiles_on_screen_vertically = map_height - start_tile_y;
for(size_t l = 0; l < layers.size(); ++l)
{
for(int current_tile_y = 0; current_tile_y < tiles_on_screen_vertically; ++current_tile_y)
{
for(int current_tile_x = 0; current_tile_x < tiles_on_screen_horizontally; ++current_tile_x)
{
int index = (start_tile_y + current_tile_y) * map_width + (start_tile_x + current_tile_x);
int sprite_index = layers[l].map[index];
int tile_position_screen_x = current_tile_x * tile_width - scrolling_pixel_offset_x;
int tile_position_screen_y = current_tile_y * tile_height - scrolling_pixel_offset_y;
sprite_tiles.set_frame(sprite_index);
sprite_tiles.draw(gc, tile_position_screen_x, tile_position_screen_y);
}
}
}
}
示例9: run
bool GUI::run()
{
static int total_time = 0, fps_count = 0, last_fps= 0;
static int start_time = 0;
if (start_time == 0)
{
start_time = CL_System::get_time();
}
CL_GraphicContext gc = app->get_window()->get_gc();
gc.set_map_mode(CL_MapMode(cl_map_2d_upper_left));
CL_Draw::gradient_fill(gc, app->get_window()->get_viewport(), CL_Gradient(CL_Colorf(0.4f, 0.4f, 0.4f, 1.0f), CL_Colorf(0.0f, 0.0f, 0.0f, 1.0f)));
run_manager(gc);
CL_String fps = cl_format("FPS: %1", last_fps);
fps_font.draw_text(gc, gc.get_width() - 100 - 2, 24 - 2, fps, CL_Colorf(0.0f, 0.0f, 0.0f, 1.0f));
fps_font.draw_text(gc, gc.get_width() - 100, 24, fps, CL_Colorf::white);
fps_font.draw_text(gc, 24, gc.get_height() - 16, "Rendering GUI onto a CL_Texture, then onto the display window.", CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f));
fps_count++;
int time = CL_System::get_time();
total_time += time - start_time;
start_time = time;
if(total_time >= 1000)
{
last_fps = fps_count;
total_time -= 1000;
fps_count = 0;
}
balls.Run(gc);
CL_KeepAlive::process();
app->get_window()->flip(0);
return true;
}
示例10: calculate_matrix
void App::calculate_matrix(CL_GraphicContext &gc)
{
float lens_zoom = 3.2f;
float lens_near = 0.1f;
float lens_far = 10000.0f;
float lens_aspect = 1.0f;
float fov = 2.0f * atan2(1.0f, lens_zoom);
float aspect = 1.0f;
float width = (float) gc.get_width();
float height = (float) gc.get_height();
if (height)
aspect = ( width * lens_aspect) / height;
fov = (fov * 180.0f) / CL_PI;
projection_matrix = CL_Mat4f::perspective( fov, aspect, lens_near, lens_far);
modelview_matrix = CL_Mat4f::identity();
modelview_matrix.matrix[2 + (4*2)] = -1.0f;
}
示例11: prepareGC
void Viewport::prepareGC(CL_GraphicContext &p_gc) {
p_gc.push_modelview();
if (m_attachPoint != NULL) {
const int stageWidth = Gfx::Stage::getWidth();
const int stageHeight = Gfx::Stage::getHeight();
m_x = m_attachPoint->x - stageWidth / 2 / m_scale;
m_y = m_attachPoint->y - stageHeight / 2 / m_scale;
m_width = stageWidth / m_scale;
m_height = stageHeight / m_scale;
}
const float horizScale = p_gc.get_width() / m_width;
const float vertScale = p_gc.get_height() / m_height;
p_gc.mult_scale(horizScale, vertScale);
p_gc.mult_translate(-m_x, -m_y);
}
示例12: create_shooter
void App::create_shooter( const CL_InputEvent &key, const CL_StringRef &str, bool use_red, bool use_green, bool use_blue)
{
// Set the firing line
CL_Vec3f vector(0.0f, 0.0f, 20.0f);
CL_GraphicContext gc = window.get_gc();
float width = (float) gc.get_width();
float height = (float) gc.get_height();
vector.x = ((key.mouse_pos.x - width/2)* 10.0f) / width;
vector.y = -((key.mouse_pos.y - height/2) * 10.0f) / height;
// Create the text offset
TextShooter shooter(vector_font, str);
shooter.set_start_time(CL_System::get_time());
shooter.set_duration(2 * 1000);
shooter.set_initial_white_time(1000);
shooter.set_end_fade_time(1000);
shooter.set_start_position(CL_Vec3f(0.0f, 0.0f, 0.2f));
shooter.set_end_position(vector);
shooter.set_color_component(use_red, use_green, use_blue);
text_shooter.push_back(shooter);
}
示例13: get_stencil
CL_Image App::get_stencil(CL_GraphicContext &gc, CL_Rect rect)
{
// For an unknown reason, stencil reads should be a multiple of 32
rect.left = 32 * ((rect.left + 31) / 32);
rect.top = 32 * ((rect.top + 31) / 32);
rect.right = 32 * ((rect.right + 31) / 32);
rect.bottom = 32 * ((rect.bottom + 31) / 32);
int rect_width = rect.get_width();
int rect_height = rect.get_height();
std::vector<unsigned char> buffer;
buffer.resize(rect_width * rect_height);
clReadPixels(rect.left, gc.get_height()- rect.bottom, rect_width, rect_height, CL_STENCIL_INDEX, CL_UNSIGNED_BYTE, &buffer[0]);
CL_PixelBuffer pbuf(rect_width, rect_height, cl_abgr8);
unsigned int *pdata = (unsigned int *) pbuf.get_data();
unsigned char *rdata = &buffer[0];
for (int ycnt=0; ycnt < rect_height; ycnt++)
{
for (int xcnt=0; xcnt < rect_width; xcnt++)
{
int value = *(rdata++);
if (value == 0)
{
*(pdata++) = 0xFF005500;
}
else
{
value = value * 16;
value = 0xFF000000 | value | (value << 8) | (value << 16);
*(pdata++) = value;
}
}
}
pbuf.flip_vertical();
return CL_Image(gc, pbuf, pbuf.get_size());
}
示例14: render_night_vision
void App::render_night_vision(CL_GraphicContext &gc, CL_Texture &source_texture, CL_Texture &mask_texture, CL_Texture &noise_texture, CL_ProgramObject &program_object)
{
program_object.set_uniform1i("sceneBuffer", 0);
program_object.set_uniform1i("noiseTex", 1);
program_object.set_uniform1i("maskTex", 2);
program_object.set_uniform1f("elapsedTime", elapsedTime);
program_object.set_uniform1f("luminanceThreshold", luminanceThreshold);
program_object.set_uniform1f("colorAmplification", colorAmplification);
program_object.set_uniform1f("effectCoverage", effectCoverage);
gc.set_texture(0, source_texture);
gc.set_texture(1, noise_texture);
gc.set_texture(2, mask_texture);
gc.set_program_object(program_object, cl_program_matrix_modelview_projection);
draw_texture(gc, CL_Rectf(0,0,gc.get_width(),gc.get_height()), CL_Colorf::white, CL_Rectf(0.0f, 0.0f, 1.0f, 1.0f));
gc.reset_program_object();
gc.reset_texture(2);
gc.reset_texture(1);
gc.reset_texture(0);
}
示例15: draw
void TileMap::draw(CL_GraphicContext& gc) {
int screen_width = gc.get_width();
int screen_height = gc.get_height();
int horiz_tiles = screen_width / tile_width + 1;
int vert_tiles = screen_height / tile_height + 1;
// avoid half tiles by increasing by one
horiz_tiles++;
vert_tiles++;
int start_tilex = cl_max(0, cur_map_x / tile_width);
int start_tiley = cl_max(0, cur_map_y / tile_height);
int scroll_offsetx = cur_map_x - start_tilex * tile_width;
int scroll_offsety = cur_map_y - start_tiley * tile_width;
if (horiz_tiles + start_tilex > map_width)
horiz_tiles = map_width - start_tilex;
if (vert_tiles + start_tiley > map_height)
vert_tiles = map_height - start_tiley;
for (MapLayer& layer : layers) {
for (int cur_y = 0; cur_y < vert_tiles; ++cur_y) {
for (int cur_x = 0; cur_x < horiz_tiles; ++cur_x) {
int idx = (start_tiley + cur_y) * map_width + start_tilex + cur_x;
int sprite_idx = layer.map[idx];
int tile_xpos = cur_x * tile_width - scroll_offsetx;
int tile_ypos = cur_y * tile_height - scroll_offsety;
tiles.set_frame(sprite_idx);
tiles.draw(gc, tile_xpos, tile_ypos);
}
}
}
}